Merge "[i18n] Fix tests for RegionalPreference and TickButtonPreference" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
6b6aa30bdc
@@ -22,7 +22,9 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.app.GrammaticalInflectionManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.android.settings.widget.TickButtonPreference;
|
||||
@@ -58,6 +60,7 @@ public class TermsOfAddressFeminineControllerTest {
|
||||
private TickButtonPreference mMasculinePreference;
|
||||
private TickButtonPreference mNotSpecifiedPreference;
|
||||
private TickButtonPreference mNeutralPreference;
|
||||
private GrammaticalInflectionManager mGrammaticalInflectionManager;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -68,6 +71,8 @@ public class TermsOfAddressFeminineControllerTest {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
mGrammaticalInflectionManager = mContext.getSystemService(
|
||||
GrammaticalInflectionManager.class);
|
||||
mPreferenceManager = new PreferenceManager(mContext);
|
||||
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
|
||||
mPreferenceCategory = new PreferenceCategory(mContext);
|
||||
@@ -93,12 +98,10 @@ public class TermsOfAddressFeminineControllerTest {
|
||||
public void displayPreference_setGrammaticalGenderIsFeminine_FeminineIsSelected() {
|
||||
TickButtonPreference selectedPreference =
|
||||
(TickButtonPreference) mPreferenceScreen.getPreference(2);
|
||||
TickButtonPreference pref = (TickButtonPreference) mPreferenceScreen.getPreference(1);
|
||||
|
||||
selectedPreference.performClick();
|
||||
|
||||
assertThat(selectedPreference.getKey()).isEqualTo(KEY_FEMININE);
|
||||
assertThat(selectedPreference.isSelected()).isTrue();
|
||||
assertThat(pref.isSelected()).isFalse();
|
||||
assertThat(mGrammaticalInflectionManager.getSystemGrammaticalGender()).isEqualTo(
|
||||
Configuration.GRAMMATICAL_GENDER_FEMININE);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.app.GrammaticalInflectionManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.android.settings.widget.TickButtonPreference;
|
||||
@@ -58,6 +60,7 @@ public class TermsOfAddressMasculineControllerTest {
|
||||
private TickButtonPreference mMasculinePreference;
|
||||
private TickButtonPreference mNotSpecifiedPreference;
|
||||
private TickButtonPreference mNeutralPreference;
|
||||
private GrammaticalInflectionManager mGrammaticalInflectionManager;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -68,6 +71,8 @@ public class TermsOfAddressMasculineControllerTest {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
mGrammaticalInflectionManager = mContext.getSystemService(
|
||||
GrammaticalInflectionManager.class);
|
||||
mPreferenceManager = new PreferenceManager(mContext);
|
||||
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
|
||||
mPreferenceCategory = new PreferenceCategory(mContext);
|
||||
@@ -93,12 +98,10 @@ public class TermsOfAddressMasculineControllerTest {
|
||||
public void displayPreference_setGrammaticalGenderIsMasculine_MasculineIsSelected() {
|
||||
TickButtonPreference selectedPreference =
|
||||
(TickButtonPreference) mPreferenceScreen.getPreference(3);
|
||||
TickButtonPreference pref = (TickButtonPreference) mPreferenceScreen.getPreference(1);
|
||||
|
||||
selectedPreference.performClick();
|
||||
|
||||
assertThat(selectedPreference.getKey()).isEqualTo(KEY_MASCULINE);
|
||||
assertThat(selectedPreference.isSelected()).isTrue();
|
||||
assertThat(pref.isSelected()).isFalse();
|
||||
assertThat(mGrammaticalInflectionManager.getSystemGrammaticalGender()).isEqualTo(
|
||||
Configuration.GRAMMATICAL_GENDER_MASCULINE);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.app.GrammaticalInflectionManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.android.settings.widget.TickButtonPreference;
|
||||
@@ -58,6 +60,7 @@ public class TermsOfAddressNeutralControllerTest {
|
||||
private TickButtonPreference mMasculinePreference;
|
||||
private TickButtonPreference mNotSpecifiedPreference;
|
||||
private TickButtonPreference mNeutralPreference;
|
||||
private GrammaticalInflectionManager mGrammaticalInflectionManager;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -68,6 +71,8 @@ public class TermsOfAddressNeutralControllerTest {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
mGrammaticalInflectionManager = mContext.getSystemService(
|
||||
GrammaticalInflectionManager.class);
|
||||
mPreferenceManager = new PreferenceManager(mContext);
|
||||
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
|
||||
mPreferenceCategory = new PreferenceCategory(mContext);
|
||||
@@ -93,12 +98,10 @@ public class TermsOfAddressNeutralControllerTest {
|
||||
public void displayPreference_setGrammaticalGenderIsNotSpecified_NotSpecifiedIsSelected() {
|
||||
TickButtonPreference selectedPreference =
|
||||
(TickButtonPreference) mPreferenceScreen.getPreference(4);
|
||||
TickButtonPreference pref = (TickButtonPreference) mPreferenceScreen.getPreference(1);
|
||||
|
||||
selectedPreference.performClick();
|
||||
|
||||
assertThat(selectedPreference.getKey()).isEqualTo(KEY_NEUTRAL);
|
||||
assertThat(selectedPreference.isSelected()).isTrue();
|
||||
assertThat(pref.isSelected()).isFalse();
|
||||
assertThat(mGrammaticalInflectionManager.getSystemGrammaticalGender()).isEqualTo(
|
||||
Configuration.GRAMMATICAL_GENDER_NEUTRAL);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.app.GrammaticalInflectionManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.android.settings.widget.TickButtonPreference;
|
||||
@@ -58,6 +60,7 @@ public class TermsOfAddressNotSpecifiedControllerTest {
|
||||
private TickButtonPreference mMasculinePreference;
|
||||
private TickButtonPreference mNotSpecifiedPreference;
|
||||
private TickButtonPreference mNeutralPreference;
|
||||
private GrammaticalInflectionManager mGrammaticalInflectionManager;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -68,6 +71,8 @@ public class TermsOfAddressNotSpecifiedControllerTest {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
mGrammaticalInflectionManager = mContext.getSystemService(
|
||||
GrammaticalInflectionManager.class);
|
||||
mPreferenceManager = new PreferenceManager(mContext);
|
||||
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
|
||||
mPreferenceCategory = new PreferenceCategory(mContext);
|
||||
@@ -93,12 +98,10 @@ public class TermsOfAddressNotSpecifiedControllerTest {
|
||||
public void displayPreference_setGrammaticalGenderIsNotSpecified_NotSpecifiedIsSelected() {
|
||||
TickButtonPreference selectedPreference =
|
||||
(TickButtonPreference) mPreferenceScreen.getPreference(1);
|
||||
TickButtonPreference pref = (TickButtonPreference) mPreferenceScreen.getPreference(2);
|
||||
|
||||
selectedPreference.performClick();
|
||||
|
||||
assertThat(selectedPreference.getKey()).isEqualTo(KEY_NOT_SPECIFIED);
|
||||
assertThat(selectedPreference.isSelected()).isTrue();
|
||||
assertThat(pref.isSelected()).isFalse();
|
||||
assertThat(mGrammaticalInflectionManager.getSystemGrammaticalGender()).isEqualTo(
|
||||
Configuration.GRAMMATICAL_GENDER_NOT_SPECIFIED);
|
||||
}
|
||||
}
|
||||
|
@@ -97,7 +97,8 @@ public class FirstDayOfWeekItemListControllerTest {
|
||||
mContext.getContentResolver(), Settings.System.LOCALE_PREFERENCES);
|
||||
|
||||
assertThat(pref.getKey()).isEqualTo("default");
|
||||
assertThat(record).contains("default");
|
||||
assertThat(
|
||||
RegionalPreferencesDataUtils.dayConverter(mContext, record)).contains("default");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -94,7 +94,9 @@ public class TemperatureUnitListControllerTest {
|
||||
mContext.getContentResolver(), Settings.System.LOCALE_PREFERENCES);
|
||||
|
||||
assertThat(pref.getKey()).isEqualTo("default");
|
||||
assertThat(record).contains("default");
|
||||
assertThat(
|
||||
RegionalPreferencesDataUtils.temperatureUnitsConverter(mContext, record))
|
||||
.contains("default");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user