Use flag to control the hierarchy tree changes

This change includes these:
Regional preferences
-Temperature
-First day of week
-Numbering system
-Footer preference

Bug: 379962955
Flag: com.android.settings.flags.regional_preferences_api_enabled
Test: check hsv and atest FirstDayOfWeekControllerTest, NumberingSystemControllerTest, TemperatureUnitControllerTest
Change-Id: Icb628640c05f1f4bb974416c35dce16a14f84a6c
This commit is contained in:
danielwbhuang
2024-11-25 18:02:54 +08:00
parent 9571a0d353
commit d53777f96d
12 changed files with 447 additions and 1 deletions

View File

@@ -19,14 +19,18 @@ package com.android.settings.regionalpreferences;
import static org.junit.Assert.assertEquals;
import android.content.Context;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.flags.Flags;
import com.android.settings.testutils.ResourcesUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.util.Locale;
@@ -37,6 +41,8 @@ public class FirstDayOfWeekControllerTest {
private String mCacheProviderContent = "";
private Locale mCacheLocale;
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Before
public void setUp() throws Exception {
mApplicationContext = ApplicationProvider.getApplicationContext();
@@ -54,6 +60,7 @@ public class FirstDayOfWeekControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_hasProviderValue_resultIsWed() {
RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, "und-u-fw-wed");
@@ -64,6 +71,7 @@ public class FirstDayOfWeekControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_hasProviderValue_resultIsSat() {
RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, "und-u-fw-sat");
@@ -74,6 +82,7 @@ public class FirstDayOfWeekControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_noProviderValueButHasDefaultLocaleWithSubtag_resultIsSat() {
RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, "");
Locale.setDefault(Locale.forLanguageTag("en-US-u-fw-sat"));
@@ -85,6 +94,7 @@ public class FirstDayOfWeekControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_noProviderValueAndDefaultLocaleWithoutSubtag_resultIsdefault() {
RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, "");
Locale.setDefault(Locale.forLanguageTag("en-US"));

View File

@@ -23,22 +23,30 @@ import static org.junit.Assert.assertEquals;
import android.content.Context;
import android.os.LocaleList;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.flags.Flags;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
public class NumberingSystemControllerTest {
private Context mApplicationContext;
private NumberingSystemController mController;
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Before
public void setUp() throws Exception {
mApplicationContext = ApplicationProvider.getApplicationContext();
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getAvailabilityStatus_noLocale_unavailable() {
LocaleList.setDefault(LocaleList.forLanguageTags("en-US,zh-Hant-TW"));
mController = new NumberingSystemController(mApplicationContext, "key");
@@ -49,6 +57,7 @@ public class NumberingSystemControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getAvailabilityStatus_hasLocaleWithNumberingSystems_available() {
// ar-JO has different numbering system.
LocaleList.setDefault(LocaleList.forLanguageTags("en-US,zh-Hant-TW,ar-JO"));

View File

@@ -19,14 +19,18 @@ package com.android.settings.regionalpreferences;
import static org.junit.Assert.assertEquals;
import android.content.Context;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.flags.Flags;
import com.android.settings.testutils.ResourcesUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.util.Locale;
@@ -37,6 +41,8 @@ public class TemperatureUnitControllerTest {
private String mCacheProviderContent = "";
private Locale mCacheLocale;
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Before
public void setUp() throws Exception {
mApplicationContext = ApplicationProvider.getApplicationContext();
@@ -54,6 +60,7 @@ public class TemperatureUnitControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_hasProviderValue_resultIsCelsius() {
RegionalPreferenceTestUtils.setSettingsProviderContent(
mApplicationContext, "und-u-mu-celsius");
@@ -65,6 +72,7 @@ public class TemperatureUnitControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_hasProviderValue_resultIsFahrenheit() {
RegionalPreferenceTestUtils.setSettingsProviderContent(
mApplicationContext, "und-u-mu-fahrenhe");
@@ -76,6 +84,7 @@ public class TemperatureUnitControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_noProviderValueButHasDefaultLocaleWithSubtag_resultIsFahrenheit() {
RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, "");
Locale.setDefault(Locale.forLanguageTag("en-US-u-mu-fahrenhe"));
@@ -87,6 +96,7 @@ public class TemperatureUnitControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_noProviderValueAndDefaultLocaleWithoutSubtag_resultIsDefault() {
RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, "");
Locale.setDefault(Locale.forLanguageTag("en-US"));