Merge "Clean up SubscriptionInfoEntity unused fields" into main
diff --git a/res/layout/pointer_icon_stroke_style_layout.xml b/res/layout/pointer_icon_stroke_style_layout.xml
new file mode 100644
index 0000000..acf919a
--- /dev/null
+++ b/res/layout/pointer_icon_stroke_style_layout.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ Copyright 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:orientation="vertical"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart">
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/pointer_stroke_style_padding"
+ android:text="@string/pointer_stroke_style"
+ android:textAlignment="viewStart"
+ android:textAppearance="?android:attr/textAppearanceListItem" />
+
+ <RadioGroup
+ android:id="@+id/button_holder"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_marginTop="@dimen/pointer_stroke_style_padding"
+ android:layout_marginBottom="@dimen/pointer_stroke_style_padding"
+ android:padding="@dimen/pointer_stroke_style_padding">
+ <RadioButton android:id="@+id/stroke_style_white"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/pointer_stroke_style_padding"
+ android:text="@string/pointer_stroke_style_name_white"/>
+ <RadioButton android:id="@+id/stroke_style_black"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/pointer_stroke_style_padding"
+ android:text="@string/pointer_stroke_style_name_black"/>
+ <RadioButton android:id="@+id/stroke_style_none"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/pointer_stroke_style_padding"
+ android:text="@string/pointer_stroke_style_name_none"/>
+ </RadioGroup>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/private_space_education_screen.xml b/res/layout/private_space_education_screen.xml
index 4df92b7..3afe7f9 100644
--- a/res/layout/private_space_education_screen.xml
+++ b/res/layout/private_space_education_screen.xml
@@ -53,7 +53,7 @@
android:src="@drawable/counter_1_24dp" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
- android:layout_toRightOf="@+id/lockIcon"
+ android:layout_toEndOf="@+id/lockIcon"
android:text="@string/private_space_separate_account_text"/>
</RelativeLayout>
<RelativeLayout
@@ -64,7 +64,7 @@
android:src="@drawable/counter_2_24dp" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
- android:layout_toRightOf="@+id/bellIcon"
+ android:layout_toEndOf="@+id/bellIcon"
android:text="@string/private_space_protected_lock_text"/>
</RelativeLayout>
<RelativeLayout
@@ -77,7 +77,7 @@
android:src="@drawable/counter_3_24dp" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
- android:layout_toRightOf="@+id/appsIcon"
+ android:layout_toEndOf="@+id/appsIcon"
android:text="@string/private_space_install_apps_text"/>
</RelativeLayout>
<TextView
@@ -94,7 +94,7 @@
android:src="@drawable/ic_private_space_edu_icon" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
- android:layout_toRightOf="@+id/eduIcon"
+ android:layout_toEndOf="@+id/eduIcon"
android:text="@string/private_space_apps_stopped_text"/>
</RelativeLayout>
<Space
@@ -112,13 +112,13 @@
android:id="@+id/info"
style="@style/PrivateSpaceBulletPointTextFontStyle"
android:textSize = "14sp"
- android:layout_toRightOf="@+id/infoIcon"
+ android:layout_toEndOf="@+id/infoIcon"
android:text="@string/private_space_apps_permission_text"/>
<TextView
android:id="@+id/learn_more"
style="@style/PrivateSpaceSetupSubHeaderStyle"
android:layout_below="@id/info"
- android:layout_alignLeft="@+id/info"
+ android:layout_alignStart="@+id/info"
android:paddingTop="24dp"
android:paddingLeft="16dp"
android:text="@string/private_space_learn_more_text"/>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ce48720..8a96727 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -179,6 +179,7 @@
<dimen name="pointer_fill_style_circle_padding">8dp</dimen>
<dimen name="pointer_fill_style_shape_default_stroke">1dp</dimen>
<dimen name="pointer_fill_style_shape_hovered_stroke">3dp</dimen>
+ <dimen name="pointer_stroke_style_padding">8dp</dimen>
<dimen name="pointer_scale_padding">8dp</dimen>
<item name="pointer_scale_size_start" format="float" type="dimen">1.0</item>
<item name="pointer_scale_size_end" format="float" type="dimen">2.5</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6481193..3063f77 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4501,6 +4501,14 @@
<string name="pointer_fill_style_pink_button">Change pointer fill style to pink</string>
<!-- Content description for blue pointer fill style. [CHAR LIMIT=60] -->
<string name="pointer_fill_style_blue_button">Change pointer fill style to blue</string>
+ <!-- Title text for mouse pointer stroke style. [CHAR LIMIT=35] -->
+ <string name="pointer_stroke_style">Pointer stroke style</string>
+ <!-- White value for pointer stroke style. [CHAR LIMIT=35] -->
+ <string name="pointer_stroke_style_name_white">White</string>
+ <!-- Black value pointer stroke style. [CHAR LIMIT=35] -->
+ <string name="pointer_stroke_style_name_black">Black</string>
+ <!-- None value for pointer stroke style. [CHAR LIMIT=35] -->
+ <string name="pointer_stroke_style_name_none">None</string>
<!-- Title for the button to trigger the 'touch gesture' education. [CHAR LIMIT=35] -->
<string name="trackpad_touch_gesture">Learn touchpad gestures</string>
<!-- Search keywords for "touchpad" -->
@@ -9339,8 +9347,6 @@
<string name="zen_mode_apps_priority_apps">Selected apps</string>
<!-- [CHAR LIMIT=60] Zen mode settings: no apps will be able to bypass dnd -->
<string name="zen_mode_apps_none_apps">None</string>
- <!-- [CHAR LIMIT=60] Zen mode settings: all apps will be able to bypass dnd -->
- <string name="zen_mode_apps_all_apps">All</string>
<!-- [CHAR LIMIT=NONE] Zen mode settings: Lists apps that can bypass DND. For example, "Nest, Messages, and 2 more can interrupt". -->
<string name="zen_mode_apps_subtext">
{count, plural, offset:2
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0bd0406..2d40af0 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -982,14 +982,15 @@
</style>
<style name="PrivateSpaceBulletPointTextFontStyle" parent="@style/PrivateSpaceSetupTextFontStyle">
- <item name="android:paddingLeft">16dp</item>
+ <item name="android:paddingStart">16dp</item>
<item name="android:textSize">16sp</item>
+ <item name="android:textAlignment">viewStart</item>
</style>
<style name="PrivateSpaceBulletPointIconStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
- <item name="android:layout_alignParentLeft">true</item>
+ <item name="android:layout_alignParentStart">true</item>
<item name="android:layout_alignParentTop">true</item>
</style>
diff --git a/res/xml/trackpad_settings.xml b/res/xml/trackpad_settings.xml
index 04422dd..a479e17 100644
--- a/res/xml/trackpad_settings.xml
+++ b/res/xml/trackpad_settings.xml
@@ -68,6 +68,12 @@
android:order="50"
settings:controller="com.android.settings.inputmethod.PointerFillStylePreferenceController"/>
+ <com.android.settings.inputmethod.PointerStrokeStylePreference
+ android:key="pointer_stroke_style"
+ android:title="@string/pointer_stroke_style"
+ android:order="60"
+ settings:controller="com.android.settings.inputmethod.PointerStrokeStylePreferenceController"/>
+
<com.android.settings.widget.LabeledSeekBarPreference
android:key="pointer_scale"
android:title="@string/pointer_scale"
diff --git a/res/xml/zen_mode_apps_settings.xml b/res/xml/zen_mode_apps_settings.xml
index 4ee14e4..a452143 100644
--- a/res/xml/zen_mode_apps_settings.xml
+++ b/res/xml/zen_mode_apps_settings.xml
@@ -34,11 +34,6 @@
android:title="@string/zen_mode_apps_none_apps"
settings:searchable="false"/>
- <com.android.settingslib.widget.SelectorWithWidgetPreference
- android:key="zen_mode_apps_all"
- android:title="@string/zen_mode_apps_all_apps"
- settings:searchable="false"/>
-
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/inputmethod/PointerStrokeStylePreference.java b/src/com/android/settings/inputmethod/PointerStrokeStylePreference.java
new file mode 100644
index 0000000..1c02332
--- /dev/null
+++ b/src/com/android/settings/inputmethod/PointerStrokeStylePreference.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.inputmethod;
+
+import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_STROKE_BLACK;
+import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_STROKE_NONE;
+import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_STROKE_WHITE;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.util.AttributeSet;
+import android.view.PointerIcon;
+import android.widget.LinearLayout;
+import android.widget.RadioButton;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settings.R;
+
+public class PointerStrokeStylePreference extends Preference {
+
+ public PointerStrokeStylePreference(@NonNull Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ setLayoutResource(R.layout.pointer_icon_stroke_style_layout);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+
+ LinearLayout buttonHolder = (LinearLayout) holder.findViewById(R.id.button_holder);
+ // Intercept hover events so setting row does not highlight when hovering buttons.
+ buttonHolder.setOnHoverListener((v, e) -> true);
+
+ int currentStroke = getPreferenceDataStore().getInt(Settings.System.POINTER_STROKE_STYLE,
+ POINTER_ICON_VECTOR_STYLE_STROKE_WHITE);
+ initRadioButton(holder, R.id.stroke_style_white, POINTER_ICON_VECTOR_STYLE_STROKE_WHITE,
+ currentStroke);
+ initRadioButton(holder, R.id.stroke_style_black, POINTER_ICON_VECTOR_STYLE_STROKE_BLACK,
+ currentStroke);
+ initRadioButton(holder, R.id.stroke_style_none, POINTER_ICON_VECTOR_STYLE_STROKE_NONE,
+ currentStroke);
+ }
+
+ private void initRadioButton(@NonNull PreferenceViewHolder holder, int id, int strokeStyle,
+ int currentStroke) {
+ RadioButton radioButton = (RadioButton) holder.findViewById(id);
+ if (radioButton == null) {
+ return;
+ }
+ radioButton.setOnCheckedChangeListener((v, isChecked) -> {
+ if (isChecked) {
+ getPreferenceDataStore().putInt(Settings.System.POINTER_STROKE_STYLE, strokeStyle);
+ }
+ });
+ radioButton.setChecked(currentStroke == strokeStyle);
+ radioButton.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_ARROW));
+ }
+}
diff --git a/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceController.java b/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceController.java
new file mode 100644
index 0000000..e4ea996
--- /dev/null
+++ b/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceController.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.inputmethod;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceDataStore;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.core.BasePreferenceController;
+
+public class PointerStrokeStylePreferenceController extends BasePreferenceController {
+
+ @VisibleForTesting
+ static final String KEY_POINTER_STROKE_STYLE = "pointer_stroke_style";
+
+ public PointerStrokeStylePreferenceController(@NonNull Context context) {
+ super(context, KEY_POINTER_STROKE_STYLE);
+ }
+
+ @AvailabilityStatus
+ public int getAvailabilityStatus() {
+ return android.view.flags.Flags.enableVectorCursorA11ySettings() ? AVAILABLE
+ : CONDITIONALLY_UNAVAILABLE;
+ }
+
+ @Override
+ public void displayPreference(@NonNull PreferenceScreen screen) {
+ super.displayPreference(screen);
+ Preference pointerStrokeStylePreference = screen.findPreference(KEY_POINTER_STROKE_STYLE);
+ if (pointerStrokeStylePreference == null) {
+ return;
+ }
+ pointerStrokeStylePreference.setPreferenceDataStore(new PreferenceDataStore() {
+ @Override
+ public void putInt(@NonNull String key, int value) {
+ Settings.System.putIntForUser(mContext.getContentResolver(), key, value,
+ UserHandle.USER_CURRENT);
+ }
+
+ @Override
+ public int getInt(@NonNull String key, int defValue) {
+ return Settings.System.getIntForUser(mContext.getContentResolver(), key, defValue,
+ UserHandle.USER_CURRENT);
+ }
+ });
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/MainClearTest.java b/tests/robotests/src/com/android/settings/MainClearTest.java
index 1136d94..187fce1 100644
--- a/tests/robotests/src/com/android/settings/MainClearTest.java
+++ b/tests/robotests/src/com/android/settings/MainClearTest.java
@@ -138,7 +138,11 @@
// Make scrollView only have one child
when(mScrollView.getChildAt(0)).thenReturn(mLinearLayout);
when(mScrollView.getChildCount()).thenReturn(1);
- doReturn(mActivity).when(mMainClear).getActivity();
+ doReturn(mMockActivity).when(mMainClear).getActivity();
+ when(mMockActivity.getSystemService(BiometricManager.class)).thenReturn(mBiometricManager);
+ when(mBiometricManager.canAuthenticate(
+ BiometricManager.Authenticators.MANDATORY_BIOMETRICS))
+ .thenReturn(BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE);
}
@After
diff --git a/tests/robotests/src/com/android/settings/biometrics/combination/CombinedBiometricProfileSettingsTest.java b/tests/robotests/src/com/android/settings/biometrics/combination/CombinedBiometricProfileSettingsTest.java
index a0ef57f..8593860 100644
--- a/tests/robotests/src/com/android/settings/biometrics/combination/CombinedBiometricProfileSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/combination/CombinedBiometricProfileSettingsTest.java
@@ -31,9 +31,11 @@
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.Intent;
+import android.hardware.biometrics.BiometricManager;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
@@ -102,6 +104,8 @@
private FaceStatusPreferenceController mFaceStatusPreferenceController;
@Mock
private FaceManager mFaceManager;
+ @Mock
+ private BiometricManager mBiometricManager;
@Before
public void setUp() {
@@ -114,6 +118,10 @@
mContext = spy(ApplicationProvider.getApplicationContext());
mFragment = spy(new TestCombinedBiometricProfileSettings(mContext));
doReturn(mActivity).when(mFragment).getActivity();
+ doReturn(mBiometricManager).when(mActivity).getSystemService(BiometricManager.class);
+ when(mBiometricManager.canAuthenticate(
+ BiometricManager.Authenticators.MANDATORY_BIOMETRICS))
+ .thenReturn(BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE);
ReflectionHelpers.setField(mFragment, "mDashboardFeatureProvider",
FakeFeatureFactory.setupForTest().dashboardFeatureProvider);
diff --git a/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceControllerTest.java
new file mode 100644
index 0000000..9b4d5ef
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceControllerTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.inputmethod;
+
+import static android.view.flags.Flags.enableVectorCursorA11ySettings;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.inputmethod.PointerStrokeStylePreferenceController.KEY_POINTER_STROKE_STYLE;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assume.assumeTrue;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link PointerStrokeStylePreferenceController} */
+@RunWith(RobolectricTestRunner.class)
+public class PointerStrokeStylePreferenceControllerTest {
+ @Rule
+ public MockitoRule mMockitoRule = MockitoJUnit.rule();
+
+ @Mock
+ PreferenceScreen mPreferenceScreen;
+
+ private Context mContext;
+ private PointerStrokeStylePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mController = new PointerStrokeStylePreferenceController(mContext);
+ }
+
+ @Test
+ public void displayPreference_initializeDataStore() {
+ Preference strokePreference = new Preference(mContext);
+ strokePreference.setKey(KEY_POINTER_STROKE_STYLE);
+ when(mPreferenceScreen.findPreference(eq(KEY_POINTER_STROKE_STYLE))).thenReturn(
+ strokePreference);
+
+ mController.displayPreference(mPreferenceScreen);
+
+ assertNotNull(strokePreference.getPreferenceDataStore());
+ }
+
+ @Test
+ public void getAvailabilityStatus_flagEnabled() {
+ assumeTrue(enableVectorCursorA11ySettings());
+
+ assertEquals(mController.getAvailabilityStatus(), AVAILABLE);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceTest.java b/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceTest.java
new file mode 100644
index 0000000..33b8592
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.inputmethod;
+
+import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_STROKE_BLACK;
+import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_STROKE_WHITE;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.view.View;
+import android.widget.RadioButton;
+
+import androidx.preference.PreferenceDataStore;
+import androidx.preference.PreferenceViewHolder;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link PointerStrokeStylePreference} */
+@RunWith(RobolectricTestRunner.class)
+public class PointerStrokeStylePreferenceTest {
+ @Rule
+ public MockitoRule mMockitoRule = MockitoJUnit.rule();
+
+ @Mock
+ PreferenceDataStore mPreferenceDataStore;
+
+ private Context mContext;
+ private PreferenceViewHolder mViewHolder;
+ private PointerStrokeStylePreference mPreference;
+
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mPreference = new PointerStrokeStylePreference(mContext, null);
+ }
+
+ @Test
+ public void onBindViewHolder_getCurrentStrokeStyleFromDataStore() {
+ final View view = spy(View.inflate(mContext, mPreference.getLayoutResource(), null));
+ mViewHolder = PreferenceViewHolder.createInstanceForTests(view);
+ mPreference.setPreferenceDataStore(mPreferenceDataStore);
+
+ mPreference.onBindViewHolder(mViewHolder);
+
+ verify(mPreferenceDataStore).getInt(Settings.System.POINTER_STROKE_STYLE,
+ POINTER_ICON_VECTOR_STYLE_STROKE_WHITE);
+ }
+
+ @Test
+ public void setChecked_radioButtonUpdatesDataStore() {
+ final View view = spy(View.inflate(mContext, mPreference.getLayoutResource(), null));
+ mViewHolder = PreferenceViewHolder.createInstanceForTests(view);
+ mPreference.setPreferenceDataStore(mPreferenceDataStore);
+ RadioButton radioButton = (RadioButton) view.findViewById(R.id.stroke_style_black);
+ mPreference.onBindViewHolder(mViewHolder);
+
+ radioButton.setChecked(true);
+
+ verify(mPreferenceDataStore).getInt(Settings.System.POINTER_STROKE_STYLE,
+ POINTER_ICON_VECTOR_STYLE_STROKE_WHITE);
+ verify(mPreferenceDataStore).putInt(Settings.System.POINTER_STROKE_STYLE,
+ POINTER_ICON_VECTOR_STYLE_STROKE_BLACK);
+ }
+}