Merge "Use ResourcesUtils to get the resource from the target application."

This commit is contained in:
Chun-Ku Lin
2023-05-25 18:32:45 +00:00
committed by Android (Google) Code Review

View File

@@ -23,8 +23,8 @@ import android.content.Context;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.R;
import com.android.settings.gestures.OneHandedSettingsUtils; import com.android.settings.gestures.OneHandedSettingsUtils;
import com.android.settings.testutils.ResourcesUtils;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -44,20 +44,35 @@ public final class OneHandedPreferenceControllerTest {
@Test @Test
public void getSummary_oneHandedEnabled_showsOnWithSummary() { public void getSummary_oneHandedEnabled_showsOnWithSummary() {
OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, true); OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, true);
// R.string.gesture_setting_on
String gestureSettingOn = ResourcesUtils.getResourcesString(mContext, "gesture_setting_on");
// R.string.one_handed_mode_intro_text
String oneHandedModeIntroText = ResourcesUtils.getResourcesString(mContext,
"one_handed_mode_intro_text");
// expect: On / $(summary)
assertThat(mController.getSummary().toString()).isEqualTo( assertThat(mController.getSummary().toString()).isEqualTo(
mContext.getString(R.string.preference_summary_default_combination, // R.string.preference_summary_default_combination
mContext.getText(R.string.gesture_setting_on), ResourcesUtils.getResourcesString(mContext,
mContext.getText(R.string.one_handed_mode_intro_text))); "preference_summary_default_combination", gestureSettingOn,
oneHandedModeIntroText));
} }
@Test @Test
public void getSummary_oneHandedDisabled_showsOffWithSummary() { public void getSummary_oneHandedDisabled_showsOffWithSummary() {
OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, false); OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, false);
// R.string.gesture_setting_off
String gestureSettingOff = ResourcesUtils.getResourcesString(mContext,
"gesture_setting_off");
// R.string.one_handed_mode_intro_text
String oneHandedModeIntroText = ResourcesUtils.getResourcesString(mContext,
"one_handed_mode_intro_text");
// expect: Off / $(summary)
assertThat(mController.getSummary().toString()).isEqualTo( assertThat(mController.getSummary().toString()).isEqualTo(
mContext.getString(R.string.preference_summary_default_combination, // R.string.preference_summary_default_combination
mContext.getText(R.string.gesture_setting_off), ResourcesUtils.getResourcesString(mContext,
mContext.getText(R.string.one_handed_mode_intro_text))); "preference_summary_default_combination", gestureSettingOff,
oneHandedModeIntroText));
} }
} }