Fix Partner.getText
Test: ./gradlew test
Bug: 109781942
Change-Id: I06c3be06def30803e5dda3069686f0ff510b804d
(cherry picked from commit 466c50ab5c
)
This commit is contained in:
parent
30edb6eff7
commit
cd6650c958
|
@ -91,7 +91,7 @@ public class Partner {
|
||||||
*/
|
*/
|
||||||
public static CharSequence getText(Context context, @StringRes int id) {
|
public static CharSequence getText(Context context, @StringRes int id) {
|
||||||
final ResourceEntry entry = getResourceEntry(context, id);
|
final ResourceEntry entry = getResourceEntry(context, id);
|
||||||
return entry.resources.getText(id);
|
return entry.resources.getText(entry.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.android.setupwizardlib.util;
|
package com.android.setupwizardlib.util;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
@ -145,6 +147,19 @@ public class PartnerTest {
|
||||||
expectedPartnerColor, foundColor);
|
expectedPartnerColor, foundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getText_shouldReturnPartnerValueIfPresent() {
|
||||||
|
final CharSequence expectedPartnerText = "partner";
|
||||||
|
doReturn(12345).when(mPartnerResources)
|
||||||
|
.getIdentifier(eq("suw_next_button_label"), eq("string"), anyString());
|
||||||
|
doReturn(expectedPartnerText).when(mPartnerResources).getText(eq(12345));
|
||||||
|
mPackageManager.addResolveInfoForIntent(
|
||||||
|
new Intent(ACTION_PARTNER_CUSTOMIZATION),
|
||||||
|
Collections.singletonList(createResolveInfo("test.partner.package", true, true)));
|
||||||
|
final CharSequence partnerText = Partner.getText(mContext, R.string.suw_next_button_label);
|
||||||
|
assertThat(partnerText).isEqualTo(expectedPartnerText);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoadDefaultValue() {
|
public void testLoadDefaultValue() {
|
||||||
mPackageManager.addResolveInfoForIntent(
|
mPackageManager.addResolveInfoForIntent(
|
||||||
|
|
Loading…
Reference in a new issue