Merge "Add rule to press home before ImeOpenCloseStressTest and AutoShowTest"

This commit is contained in:
Ziqi Chen
2023-02-07 04:59:07 +00:00
committed by Android (Google) Code Review
3 changed files with 50 additions and 10 deletions

View File

@@ -60,12 +60,15 @@ import java.util.List;
@RunWith(Parameterized.class)
public final class AutoShowTest {
@Rule public UnlockScreenRule mUnlockScreenRule = new UnlockScreenRule();
@Rule public ScreenCaptureRule mScreenCaptureRule =
new ScreenCaptureRule("/sdcard/InputMethodStressTest");
@Rule public DisableLockScreenRule mDisableLockScreenRule = new DisableLockScreenRule();
@Rule public ScreenOrientationRule mScreenOrientationRule =
@Rule(order = 0) public DisableLockScreenRule mDisableLockScreenRule =
new DisableLockScreenRule();
@Rule(order = 1) public UnlockScreenRule mUnlockScreenRule = new UnlockScreenRule();
@Rule(order = 2) public ScreenOrientationRule mScreenOrientationRule =
new ScreenOrientationRule(true /* isPortrait */);
@Rule(order = 3) public PressHomeBeforeTestRule mPressHomeBeforeTestRule =
new PressHomeBeforeTestRule();
@Rule(order = 4) public ScreenCaptureRule mScreenCaptureRule =
new ScreenCaptureRule("/sdcard/InputMethodStressTest");
// TODO(b/240359838): add test case {@code Configuration.SCREENLAYOUT_SIZE_LARGE}.
@Parameterized.Parameters(

View File

@@ -68,12 +68,15 @@ public final class ImeOpenCloseStressTest {
private static final String TAG = "ImeOpenCloseStressTest";
private static final int NUM_TEST_ITERATIONS = 10;
@Rule public UnlockScreenRule mUnlockScreenRule = new UnlockScreenRule();
@Rule public ScreenCaptureRule mScreenCaptureRule =
new ScreenCaptureRule("/sdcard/InputMethodStressTest");
@Rule public DisableLockScreenRule mDisableLockScreenRule = new DisableLockScreenRule();
@Rule public ScreenOrientationRule mScreenOrientationRule =
@Rule(order = 0) public DisableLockScreenRule mDisableLockScreenRule =
new DisableLockScreenRule();
@Rule(order = 1) public UnlockScreenRule mUnlockScreenRule = new UnlockScreenRule();
@Rule(order = 2) public ScreenOrientationRule mScreenOrientationRule =
new ScreenOrientationRule(true /* isPortrait */);
@Rule(order = 3) public PressHomeBeforeTestRule mPressHomeBeforeTestRule =
new PressHomeBeforeTestRule();
@Rule(order = 4) public ScreenCaptureRule mScreenCaptureRule =
new ScreenCaptureRule("/sdcard/InputMethodStressTest");
private final Instrumentation mInstrumentation;
private final int mSoftInputFlags;

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2023 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.inputmethod.stresstest;
import android.support.test.uiautomator.UiDevice;
import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
/** This rule will press home before a test case. */
public class PressHomeBeforeTestRule extends TestWatcher {
private final UiDevice mUiDevice =
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
@Override
protected void starting(Description description) {
mUiDevice.pressHome();
}
}