Files
app_Settings/tests/robotests/src/com/android/settings/inputmethod/KeyboardAccessibilitySlowKeysDialogFragmentTest.java
shaoweishen 4da457f8a9 [Physical Keyboard] Update Input Setting Dialog
1. update button style to use custom one
2. use scrollview so it won't be truncated in shorter screen

Bug:389973784
Flag: com.android.settings.keyboard.keyboard_and_touchpad_a11y_new_page_enabled
Test: atest
packages/apps/Settings/tests/robotests/src/com/android/settings/inputmethod/

Change-Id: I57765e88751b6090606d56bbe2335813ef7fd2fc
2025-02-21 07:10:40 +00:00

84 lines
3.2 KiB
Java

/*
* Copyright 2025 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 com.android.settings.inputmethod.KeyboardAccessibilityKeysDialogFragment.EXTRA_SUBTITLE_RES;
import static com.android.settings.inputmethod.KeyboardAccessibilityKeysDialogFragment.EXTRA_TITLE_RES;
import static com.google.common.truth.Truth.assertThat;
import android.app.AlertDialog;
import android.hardware.input.InputSettings;
import android.os.Bundle;
import android.widget.Button;
import android.widget.RadioGroup;
import androidx.fragment.app.testing.FragmentScenario;
import androidx.lifecycle.Lifecycle;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowLooper;
@RunWith(RobolectricTestRunner.class)
public class KeyboardAccessibilitySlowKeysDialogFragmentTest {
private AlertDialog mAlertDialog;
@Before
public void setUp() {
Bundle bundle = new Bundle();
bundle.putInt(EXTRA_TITLE_RES, R.string.slow_keys);
bundle.putInt(EXTRA_SUBTITLE_RES, R.string.slow_keys_summary);
FragmentScenario<KeyboardAccessibilitySlowKeysDialogFragment> mFragmentScenario =
FragmentScenario.launch(
KeyboardAccessibilitySlowKeysDialogFragment.class,
bundle,
R.style.Theme_AlertDialog_SettingsLib,
Lifecycle.State.INITIALIZED);
mFragmentScenario.moveToState(Lifecycle.State.RESUMED);
mFragmentScenario.onFragment(fragment -> {
assertThat(fragment.getDialog()).isNotNull();
assertThat(fragment.requireDialog().isShowing()).isTrue();
assertThat(fragment.requireDialog()).isInstanceOf(AlertDialog.class);
mAlertDialog = (AlertDialog) fragment.requireDialog();
});
}
@Test
public void handlePreferenceTreeClick_performClickOn200_updatesSlowKeysThreshold() {
assertThat(mAlertDialog.isShowing()).isTrue();
RadioGroup radioGroup = mAlertDialog.findViewById(R.id.input_setting_keys_value_group);
radioGroup.check(R.id.input_setting_keys_value_200);
Button doneButton = mAlertDialog.findViewById(R.id.done_button);
doneButton.performClick();
ShadowLooper.idleMainLooper();
assertThat(mAlertDialog.isShowing()).isFalse();
int threshold = InputSettings.getAccessibilitySlowKeysThreshold(
ApplicationProvider.getApplicationContext());
assertThat(threshold).isEqualTo(200);
}
}