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
20 lines
558 B
Java
20 lines
558 B
Java
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");
|
|
}
|
|
}
|