Fix a crash in Storage Settings.
This prevents a NullPtrException when the DonutView attempts to shrink the percentage sign. By gracefully falling back when we don't understand the percentage sign, we can avoid a crash. Change-Id: I0b0770ce4b51eb30817dc556636f86476f4cd1bf Fixes: 77653937 Test: Robotest -- screenshot attached
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.android.settings.widget;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class DonutViewTest {
|
||||
@Test
|
||||
public void getPercentageStringSpannable_doesntCrashForMissingPercentage() {
|
||||
Context context = RuntimeEnvironment.application;
|
||||
|
||||
DonutView.getPercentageStringSpannable(context.getResources(), "50%", "h");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user