summaryrefslogtreecommitdiffstats
path: root/quickstep/tests/src
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2018-08-30 16:01:47 -0700
committervadimt <vadimt@google.com>2019-03-04 16:49:50 -0800
commit8675deee022efc28f16a95400a50d3954b445e00 (patch)
tree490cd3cd88a75739ff4a50f287e12cecca3b03f4 /quickstep/tests/src
parent3a4f503e5d96aea97b4c8ad4a47db7c7de431e8b (diff)
downloadandroid_packages_apps_Trebuchet-8675deee022efc28f16a95400a50d3954b445e00.tar.gz
android_packages_apps_Trebuchet-8675deee022efc28f16a95400a50d3954b445e00.tar.bz2
android_packages_apps_Trebuchet-8675deee022efc28f16a95400a50d3954b445e00.zip
Switching to setting QS on and off via writing settings.
We can do this now because we hav all 6 devices in the lab. Change-Id: I5d5fcd89086a3f945ed3fc204461cacbdde61a8a
Diffstat (limited to 'quickstep/tests/src')
-rw-r--r--quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java61
1 files changed, 40 insertions, 21 deletions
diff --git a/quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java b/quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java
index 72740909d..c5975a959 100644
--- a/quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java
+++ b/quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java
@@ -19,6 +19,11 @@ package com.android.quickstep;
import static com.android.quickstep.QuickStepOnOffRule.Mode.BOTH;
import static com.android.quickstep.QuickStepOnOffRule.Mode.OFF;
import static com.android.quickstep.QuickStepOnOffRule.Mode.ON;
+import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING_NAME;
+
+import static org.junit.Assert.assertTrue;
+
+import android.provider.Settings;
import androidx.test.InstrumentationRegistry;
@@ -69,37 +74,51 @@ public class QuickStepOnOffRule implements TestRule {
@Override
public void evaluate() throws Throwable {
try {
- if (mode == ON || mode == BOTH) {
- evaluateWithQuickstepOn();
- }
- if (mode == OFF || mode == BOTH) {
- evaluateWithQuickstepOff();
+ if (SwipeUpSetting.isSwipeUpSettingAvailable()) {
+ if (mode == ON || mode == BOTH) {
+ evaluateWithQuickstepOn();
+ }
+ if (mode == OFF || mode == BOTH) {
+ evaluateWithQuickstepOff();
+ }
+ } else {
+ // Execute without changing the setting, if the requested mode is
+ // compatible.
+ final boolean swipeUpEnabledDefaultValue =
+ SwipeUpSetting.isSwipeUpEnabledDefaultValue();
+ if (mode == BOTH ||
+ mode == ON && swipeUpEnabledDefaultValue ||
+ mode == OFF && !swipeUpEnabledDefaultValue) {
+ evaluateWithoutChangingSetting(base);
+ }
}
} finally {
- overrideSwipeUpEnabled(null);
+ setSwipeUpSetting(null);
+
}
}
- private void evaluateWithQuickstepOff() throws Throwable {
- overrideSwipeUpEnabled(false);
- base.evaluate();
+ public void setSwipeUpSetting(String value) {
+ assertTrue("Couldn't change Quickstep mode",
+ Settings.Secure.putString(
+ InstrumentationRegistry.getInstrumentation().getTargetContext().
+ getContentResolver(),
+ SWIPE_UP_SETTING_NAME,
+ value));
}
- private void evaluateWithQuickstepOn() throws Throwable {
- overrideSwipeUpEnabled(true);
+ public void evaluateWithoutChangingSetting(Statement base) throws Throwable {
base.evaluate();
}
- private void overrideSwipeUpEnabled(Boolean swipeUpEnabledOverride)
- throws Throwable {
- mLauncher.overrideSwipeUpEnabled(swipeUpEnabledOverride);
- mMainThreadExecutor.execute(() -> OverviewInteractionState.INSTANCE.get(
- InstrumentationRegistry.getInstrumentation().getTargetContext()).
- notifySwipeUpSettingChanged(mLauncher.isSwipeUpEnabled()));
- // TODO(b/124236673): avoid using sleep().
- mLauncher.getDevice().waitForIdle();
- Thread.sleep(2000);
- mLauncher.getDevice().waitForIdle();
+ private void evaluateWithQuickstepOff() throws Throwable {
+ setSwipeUpSetting("0");
+ evaluateWithoutChangingSetting(base);
+ }
+
+ private void evaluateWithQuickstepOn() throws Throwable {
+ setSwipeUpSetting("1");
+ base.evaluate();
}
};
} else {