From 9dbb27c09c49807108891459962f4520dfff84fa Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 17 Jul 2019 15:12:56 -0700 Subject: Moving some utilities methods to separate class Change-Id: I5094b22ddc77c45590cea1a5f5dead0dc7580abf --- tests/src/com/android/launcher3/model/LoaderCursorTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/model/LoaderCursorTest.java b/tests/src/com/android/launcher3/model/LoaderCursorTest.java index 7d60ad65b..64df8e0e9 100644 --- a/tests/src/com/android/launcher3/model/LoaderCursorTest.java +++ b/tests/src/com/android/launcher3/model/LoaderCursorTest.java @@ -15,9 +15,9 @@ import com.android.launcher3.icons.IconCache; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.ItemInfo; import com.android.launcher3.LauncherAppState; -import com.android.launcher3.Utilities; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.icons.BitmapInfo; +import com.android.launcher3.util.PackageManagerHelper; import org.junit.Before; import org.junit.Test; @@ -115,7 +115,7 @@ public class LoaderCursorTest { WorkspaceItemInfo info = mLoaderCursor.getAppShortcutInfo( new Intent().setComponent(cn), false /* allowMissingTarget */, true); assertNotNull(info); - assertTrue(Utilities.isLauncherAppTarget(info.intent)); + assertTrue(PackageManagerHelper.isLauncherAppTarget(info.intent)); } @Test @@ -127,7 +127,7 @@ public class LoaderCursorTest { WorkspaceItemInfo info = mLoaderCursor.getAppShortcutInfo( new Intent().setComponent(cn), true /* allowMissingTarget */, true); assertNotNull(info); - assertTrue(Utilities.isLauncherAppTarget(info.intent)); + assertTrue(PackageManagerHelper.isLauncherAppTarget(info.intent)); } @Test -- cgit v1.2.3 From a68fba3abf67af9d565c98735daad639561aa888 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Thu, 8 Aug 2019 00:58:05 -0700 Subject: Build rule cleanup Bug: 122333437 Change-Id: Iabb6dcc4e6615112fdf730f41fe39d34fdac8737 --- tests/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Android.mk b/tests/Android.mk index 0c412415c..02ead4ef4 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -27,7 +27,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ ifneq (,$(wildcard frameworks/base)) else - LOCAL_STATIC_JAVA_LIBRARIES += libSharedSystemUI + LOCAL_STATIC_JAVA_LIBRARIES += SystemUISharedLib LOCAL_SRC_FILES := $(call all-java-files-under, tapl) \ ../src/com/android/launcher3/ResourceUtils.java \ -- cgit v1.2.3 From 6fe3eec95cfb153ed7c16c6381623b7e762452c3 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 15 Aug 2019 14:53:41 -0700 Subject: Moving various common executors to a single location Change-Id: I44bca49b8adb6fa22c3b48d10f674e42c28d792c --- tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java | 6 +++--- tests/src/com/android/launcher3/util/Condition.java | 6 +++--- tests/src/com/android/launcher3/util/RaceConditionReproducer.java | 6 ++---- 3 files changed, 8 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index fc19baace..6d636cf69 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -19,12 +19,12 @@ import static androidx.test.InstrumentationRegistry.getInstrumentation; import static com.android.launcher3.tapl.LauncherInstrumentation.ContainerType; import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName; +import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static org.junit.Assert.assertTrue; import static java.lang.System.exit; -import android.app.Instrumentation; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -48,7 +48,6 @@ import com.android.launcher3.LauncherModel; import com.android.launcher3.LauncherSettings; import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager; -import com.android.launcher3.MainThreadExecutor; import com.android.launcher3.Utilities; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.model.AppLaunchTracker; @@ -56,6 +55,7 @@ import com.android.launcher3.tapl.LauncherInstrumentation; import com.android.launcher3.tapl.TestHelpers; import com.android.launcher3.testcomponent.TestCommandReceiver; import com.android.launcher3.testing.TestProtocol; +import com.android.launcher3.util.LooperExecutor; import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.Wait; import com.android.launcher3.util.rule.FailureWatcher; @@ -90,7 +90,7 @@ public abstract class AbstractLauncherUiTest { public static final long DEFAULT_UI_TIMEOUT = 60000; // b/136278866 private static final String TAG = "AbstractLauncherUiTest"; - protected MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor(); + protected LooperExecutor mMainThreadExecutor = MAIN_EXECUTOR; protected final UiDevice mDevice = UiDevice.getInstance(getInstrumentation()); protected final LauncherInstrumentation mLauncher = new LauncherInstrumentation(getInstrumentation()); diff --git a/tests/src/com/android/launcher3/util/Condition.java b/tests/src/com/android/launcher3/util/Condition.java index b564a1a87..d85dd3a2d 100644 --- a/tests/src/com/android/launcher3/util/Condition.java +++ b/tests/src/com/android/launcher3/util/Condition.java @@ -1,8 +1,8 @@ package com.android.launcher3.util; -import androidx.test.uiautomator.UiObject2; +import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; -import com.android.launcher3.MainThreadExecutor; +import androidx.test.uiautomator.UiObject2; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -16,7 +16,7 @@ public interface Condition { * Converts the condition to be run on UI thread. */ static Condition runOnUiThread(final Condition condition) { - final MainThreadExecutor executor = new MainThreadExecutor(); + final LooperExecutor executor = MAIN_EXECUTOR; return () -> { final AtomicBoolean value = new AtomicBoolean(false); final Throwable[] exceptions = new Throwable[1]; diff --git a/tests/src/com/android/launcher3/util/RaceConditionReproducer.java b/tests/src/com/android/launcher3/util/RaceConditionReproducer.java index 0235f95d0..8f8917320 100644 --- a/tests/src/com/android/launcher3/util/RaceConditionReproducer.java +++ b/tests/src/com/android/launcher3/util/RaceConditionReproducer.java @@ -16,6 +16,7 @@ package com.android.launcher3.util; +import static com.android.launcher3.util.Executors.createAndStartNewLooper; import static com.android.launcher3.util.RaceConditionTracker.ENTER_POSTFIX; import static com.android.launcher3.util.RaceConditionTracker.EXIT_POSTFIX; @@ -23,7 +24,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import android.os.Handler; -import android.os.HandlerThread; import android.util.Log; import java.util.ArrayList; @@ -72,9 +72,7 @@ public class RaceConditionReproducer implements RaceConditionTracker.EventProces private static final Handler POSTPONED_EVENT_RESUME_HANDLER = createEventResumeHandler(); private static Handler createEventResumeHandler() { - final HandlerThread thread = new HandlerThread("RaceConditionEventResumer"); - thread.start(); - return new Handler(thread.getLooper()); + return new Handler(createAndStartNewLooper("RaceConditionEventResumer")); } /** -- cgit v1.2.3 From fead086f2dda3d0c965af3e3da995c04d393d69d Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 17 Sep 2019 19:27:26 -0700 Subject: Experimenting with detecting whether a test runs in presubmit Change-Id: I386c6ad29182170326c557252fe6e20a8d2af34a Merged-in: I386c6ad29182170326c557252fe6e20a8d2af34a --- .../launcher3/ui/AbstractLauncherUiTest.java | 4 +- .../android/launcher3/ui/TaplTestsLauncher3.java | 10 +- .../launcher3/util/rule/TestStabilityRule.java | 137 +++++++++++++++++++++ 3 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 tests/src/com/android/launcher3/util/rule/TestStabilityRule.java (limited to 'tests') diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index dc890bb00..840fdd26c 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -60,6 +60,7 @@ import com.android.launcher3.util.Wait; import com.android.launcher3.util.rule.FailureWatcher; import com.android.launcher3.util.rule.LauncherActivityRule; import com.android.launcher3.util.rule.ShellCommandRule; +import com.android.launcher3.util.rule.TestStabilityRule; import org.junit.After; import org.junit.Before; @@ -155,7 +156,8 @@ public abstract class AbstractLauncherUiTest { @Rule public TestRule mOrderSensitiveRules = RuleChain. - outerRule(mActivityMonitor). + outerRule(new TestStabilityRule()). + around(mActivityMonitor). around(getRulesInsideActivityMonitor()); public UiDevice getDevice() { diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index c2a3c1c52..2cf6c2ba7 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -24,6 +24,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import android.util.Log; + import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; @@ -34,9 +36,9 @@ import com.android.launcher3.tapl.AllApps; import com.android.launcher3.tapl.AppIcon; import com.android.launcher3.tapl.AppIconMenu; import com.android.launcher3.tapl.AppIconMenuItem; -import com.android.launcher3.tapl.TestHelpers; import com.android.launcher3.tapl.Widgets; import com.android.launcher3.tapl.Workspace; +import com.android.launcher3.util.rule.TestStabilityRule.Stability; import com.android.launcher3.views.OptionsPopupView; import com.android.launcher3.widget.WidgetsFullSheet; import com.android.launcher3.widget.WidgetsRecyclerView; @@ -343,4 +345,10 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { public static String getAppPackageName() { return getInstrumentation().getContext().getPackageName(); } + + @Test + @Stability + public void testTestStabilityAttribute() { + Log.d("TestStabilityRule", "Hello world!"); + } } diff --git a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java new file mode 100644 index 000000000..8391ae713 --- /dev/null +++ b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2019 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.launcher3.util.rule; + +import static androidx.test.InstrumentationRegistry.getInstrumentation; + +import android.os.Build; +import android.util.Log; + +import androidx.test.uiautomator.UiDevice; + +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TestStabilityRule implements TestRule { + private static final String TAG = "TestStabilityRule"; + private static final Pattern LAUNCHER_BUILD = + Pattern.compile("^(" + + "(?BuildFromAndroidStudio)|" + + "(?[0-9]+-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+)|" + + "(?[0-9]+-P[0-9]+)|" + + "(?[0-9]+-[0-9]+|" + + "(?[0-9]+))" + + ")$"); + private static final Pattern PLATFORM_BUILD = + Pattern.compile("^(" + + "(?eng\\.[a-z]+\\.[0-9]+\\.[0-9]+)|" + + "(?P[0-9]+)|" + + "(?[0-9]+)" + + ")$"); + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public @interface Stability { + } + + @Override + public Statement apply(Statement base, Description description) { + if (description.getAnnotation(Stability.class) != null) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + final String launcherVersion = + getInstrumentation(). + getContext(). + getPackageManager(). + getPackageInfo( + UiDevice.getInstance(getInstrumentation()). + getLauncherPackageName(), + 0). + versionName; + + final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion); + + boolean launcherLocalBuild = false; + boolean launcherUnbundledPresubmit = false; + boolean launcherUnbundledPostsubmit = false; + boolean launcherPlatform = false; + + if (!launcherBuildMatcher.find()) { + Log.e(TAG, "Match not found"); + } else if (launcherBuildMatcher.group("androidStudio") != null + || launcherBuildMatcher.group("commandLine") != null) { + launcherLocalBuild = true; + } else if (launcherBuildMatcher.group("presubmit") != null) { + launcherUnbundledPresubmit = true; + } else if (launcherBuildMatcher.group("postsubmit") != null) { + launcherUnbundledPostsubmit = true; + } else if (launcherBuildMatcher.group("platform") != null) { + launcherPlatform = true; + } else { + Log.e(TAG, "ERROR1"); + } + + boolean platformLocalBuild = false; + boolean platformPresubmit = false; + boolean platformPostsubmit = false; + + final String platformVersion = Build.VERSION.INCREMENTAL; + final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion); + if (!platformBuildMatcher.find()) { + Log.e(TAG, "Match not found"); + } else if (platformBuildMatcher.group("commandLine") != null) { + platformLocalBuild = true; + } else if (platformBuildMatcher.group("presubmit") != null) { + platformPresubmit = true; + } else if (platformBuildMatcher.group("postsubmit") != null) { + platformPostsubmit = true; + } else { + Log.e(TAG, "ERROR2"); + } + + Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion); + + if (launcherLocalBuild && (platformLocalBuild || platformPostsubmit)) { + Log.d(TAG, "LOCAL RUN"); + } else if (launcherUnbundledPresubmit && platformPostsubmit) { + Log.d(TAG, "UNBUNDLED PRESUBMIT"); + } else if (launcherUnbundledPostsubmit && platformPostsubmit) { + Log.d(TAG, "UNBUNDLED POSTSUBMIT"); + } else if (launcherPlatform && platformPresubmit) { + Log.d(TAG, "PLATFORM PRESUBMIT"); + } else if (launcherPlatform && platformPostsubmit) { + Log.d(TAG, "PLATFORM POSTSUBMIT"); + } else { + Log.e(TAG, "ERROR3"); + } + + base.evaluate(); + } + }; + } else { + return base; + } + } +} -- cgit v1.2.3 From fc041efe92c40f0c53c8f02b88a5753fcb7a2a38 Mon Sep 17 00:00:00 2001 From: vadimt Date: Fri, 20 Sep 2019 17:23:11 -0700 Subject: Adding recognition of R launcher builds for test stability rule Change-Id: Icf1251c02d328e634bf4d5c951dd53f203905838 --- .../com/android/launcher3/util/rule/TestStabilityRule.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java index 8391ae713..8feadbee9 100644 --- a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java +++ b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java @@ -37,11 +37,11 @@ public class TestStabilityRule implements TestRule { private static final String TAG = "TestStabilityRule"; private static final Pattern LAUNCHER_BUILD = Pattern.compile("^(" - + "(?BuildFromAndroidStudio)|" - + "(?[0-9]+-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+)|" - + "(?[0-9]+-P[0-9]+)|" - + "(?[0-9]+-[0-9]+|" - + "(?[0-9]+))" + + "(?(BuildFromAndroidStudio|" + + "([0-9]+|[A-Z])-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+))|" + + "(?([0-9]+|[A-Z])-P[0-9]+)|" + + "(?([0-9]+|[A-Z])+-[0-9]+|" + + "(?([0-9]+|[A-Z])+))" + ")$"); private static final Pattern PLATFORM_BUILD = Pattern.compile("^(" @@ -80,8 +80,7 @@ public class TestStabilityRule implements TestRule { if (!launcherBuildMatcher.find()) { Log.e(TAG, "Match not found"); - } else if (launcherBuildMatcher.group("androidStudio") != null - || launcherBuildMatcher.group("commandLine") != null) { + } else if (launcherBuildMatcher.group("local") != null) { launcherLocalBuild = true; } else if (launcherBuildMatcher.group("presubmit") != null) { launcherUnbundledPresubmit = true; -- cgit v1.2.3 From 3bdba615428b384d5130cdaf775c315340c3afbd Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 19 Sep 2019 19:26:09 -0700 Subject: Not using dropbox entries before the test start for diagnostics Change-Id: Ieb48d969d86a855c91109f4ace0d636fa01aafc7 Merged-in: Ia060b5d2b98ea9ea3b6e61ae11d610f1a888d7a0 --- .../android/launcher3/testcomponent/TestCommandReceiver.java | 3 ++- .../src/com/android/launcher3/ui/AbstractLauncherUiTest.java | 5 +++-- .../com/android/launcher3/tapl/LauncherInstrumentation.java | 11 ++++++----- tests/tapl/com/android/launcher3/tapl/TestHelpers.java | 8 ++++---- 4 files changed, 15 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/testcomponent/TestCommandReceiver.java b/tests/src/com/android/launcher3/testcomponent/TestCommandReceiver.java index 6a6916eec..42460961b 100644 --- a/tests/src/com/android/launcher3/testcomponent/TestCommandReceiver.java +++ b/tests/src/com/android/launcher3/testcomponent/TestCommandReceiver.java @@ -104,7 +104,8 @@ public class TestCommandReceiver extends ContentProvider { case GET_SYSTEM_HEALTH_MESSAGE: { final Bundle response = new Bundle(); - response.putString("result", TestHelpers.getSystemHealthMessage(getContext())); + response.putString("result", + TestHelpers.getSystemHealthMessage(getContext(), Long.parseLong(arg))); return response; } } diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 840fdd26c..1f4ba1af0 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -105,8 +105,9 @@ public abstract class AbstractLauncherUiTest { } if (TestHelpers.isInLauncherProcess()) { Utilities.enableRunningInTestHarnessForTests(); - mLauncher.setSystemHealthSupplier(() -> TestCommandReceiver.callCommand( - TestCommandReceiver.GET_SYSTEM_HEALTH_MESSAGE).getString("result")); + mLauncher.setSystemHealthSupplier(startTime -> TestCommandReceiver.callCommand( + TestCommandReceiver.GET_SYSTEM_HEALTH_MESSAGE, startTime.toString()). + getString("result")); mLauncher.setOnSettledStateAction( containerType -> executeOnLauncher( launcher -> diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 15615fc6b..65208ceb5 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -73,7 +73,7 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.TimeoutException; import java.util.function.Consumer; -import java.util.function.Supplier; +import java.util.function.Function; /** * The main tapl object. The only object that can be explicitly constructed by the using code. It @@ -84,6 +84,7 @@ public final class LauncherInstrumentation { private static final String TAG = "Tapl"; private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 20; private static final int GESTURE_STEP_MS = 16; + private static long START_TIME = System.currentTimeMillis(); // Types for launcher containers that the user is interacting with. "Background" is a // pseudo-container corresponding to inactive launcher covered by another app. @@ -134,7 +135,7 @@ public final class LauncherInstrumentation { private int mExpectedRotation = Surface.ROTATION_0; private final Uri mTestProviderUri; private final Deque mDiagnosticContext = new LinkedList<>(); - private Supplier mSystemHealthSupplier; + private Function mSystemHealthSupplier; private Consumer mOnSettledStateAction; @@ -296,7 +297,7 @@ public final class LauncherInstrumentation { return "Background"; } - public void setSystemHealthSupplier(Supplier supplier) { + public void setSystemHealthSupplier(Function supplier) { this.mSystemHealthSupplier = supplier; } @@ -316,8 +317,8 @@ public final class LauncherInstrumentation { } return mSystemHealthSupplier != null - ? mSystemHealthSupplier.get() - : TestHelpers.getSystemHealthMessage(getContext()); + ? mSystemHealthSupplier.apply(START_TIME) + : TestHelpers.getSystemHealthMessage(getContext(), START_TIME); } private void fail(String message) { diff --git a/tests/tapl/com/android/launcher3/tapl/TestHelpers.java b/tests/tapl/com/android/launcher3/tapl/TestHelpers.java index a089a527e..05c987be2 100644 --- a/tests/tapl/com/android/launcher3/tapl/TestHelpers.java +++ b/tests/tapl/com/android/launcher3/tapl/TestHelpers.java @@ -101,11 +101,11 @@ public class TestHelpers { return ret.toString(); } - private static String checkCrash(Context context, String label) { + private static String checkCrash(Context context, String label, long startTime) { DropBoxManager dropbox = (DropBoxManager) context.getSystemService(Context.DROPBOX_SERVICE); Assert.assertNotNull("Unable access the DropBoxManager service", dropbox); - long timestamp = System.currentTimeMillis() - 5 * 60000; + long timestamp = startTime; DropBoxManager.Entry entry; StringBuilder errorDetails = new StringBuilder(); while (null != (entry = dropbox.getNextEntry(label, timestamp))) { @@ -123,7 +123,7 @@ public class TestHelpers { return errorDetails.length() != 0 ? errorDetails.toString() : null; } - public static String getSystemHealthMessage(Context context) { + public static String getSystemHealthMessage(Context context, long startTime) { try { StringBuilder errors = new StringBuilder(); @@ -139,7 +139,7 @@ public class TestHelpers { }; for (String label : labels) { - final String crash = checkCrash(context, label); + final String crash = checkCrash(context, label, startTime); if (crash != null) errors.append(crash); } -- cgit v1.2.3 From 7752023c08643554ef422447c8ed841476137f8f Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Wed, 18 Sep 2019 17:10:54 -0700 Subject: fix test for a11y change in supporting -1 page Bug: 140406263 Change-Id: I0a39db135a5e5b0fe570ace55a368a7f4b6cb453 Test: run TaplTestLauncher3 locally --- tests/tapl/com/android/launcher3/tapl/Workspace.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index 510ea1409..d556afc9b 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -22,6 +22,7 @@ import static junit.framework.TestCase.assertTrue; import android.graphics.Point; import android.graphics.Rect; +import android.os.Bundle; import android.os.SystemClock; import android.view.KeyEvent; import android.view.MotionEvent; @@ -125,7 +126,7 @@ public final class Workspace extends Home { */ public void ensureWorkspaceIsScrollable() { final UiObject2 workspace = verifyActiveContainer(); - if (!isWorkspaceScrollable(workspace)) { + if (!isWorkspaceScrollable()) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "dragging icon to a second page of workspace to make it scrollable")) { dragIconToWorkspace( @@ -137,12 +138,12 @@ public final class Workspace extends Home { verifyActiveContainer(); } } - assertTrue("Home screen workspace didn't become scrollable", - isWorkspaceScrollable(workspace)); + assertTrue("Home screen workspace didn't become scrollable", isWorkspaceScrollable()); } - private boolean isWorkspaceScrollable(UiObject2 workspace) { - return workspace.isScrollable(); + private boolean isWorkspaceScrollable() { + Bundle result = mLauncher.getTestInfo(TestProtocol.REQUEST_DOES_WORKSPACE_HAVE_SECOND_PAGE); + return result.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, false); } @NonNull -- cgit v1.2.3 From 926e29f8b6f27f86f064e016c935bed2c63d82c7 Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 24 Sep 2019 16:06:24 -0700 Subject: Removing temporary checks that tests are running on AVD Bug: 136278866 Change-Id: I2b7b63b7745936ea84b7cba599e21d954b682ba5 --- tests/tapl/com/android/launcher3/tapl/Workspace.java | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index 510ea1409..da74b66f2 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -38,8 +38,6 @@ import com.android.launcher3.testing.TestProtocol; * Operations on the workspace screen. */ public final class Workspace extends Home { - private static final float FLING_SPEED = - LauncherInstrumentation.isAvd() ? 1500.0F : 3500.0F; private static final int DRAG_DURACTION = 2000; private static final int FLING_STEPS = 10; private final UiObject2 mHotseat; -- cgit v1.2.3 From 39eb7ec87783dfc473adb8e76806cd7f08074373 Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 24 Sep 2019 18:13:45 -0700 Subject: Removing unused method isAvd Bug: 136278866 Change-Id: I06396a60e44d25cd2b532f6ce31c2ce965263817 --- tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 65208ceb5..b200a27a0 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -37,7 +37,6 @@ import android.content.res.Resources; import android.graphics.Point; import android.graphics.Rect; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Parcelable; import android.os.SystemClock; @@ -239,10 +238,6 @@ public final class LauncherInstrumentation { return null; } - public static boolean isAvd() { - return Build.MODEL.contains("Cuttlefish"); - } - static void log(String message) { Log.d(TAG, message); } -- cgit v1.2.3 From 5f660f40c7998abc42c6df4b1aae5ca4cb5e1a4a Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 24 Sep 2019 18:18:35 -0700 Subject: Remove unused getDisplayDensity Change-Id: I4c63f4f8c0b0d8596e6b2db9839af059961157a8 --- tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 65208ceb5..93bf9af87 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -845,10 +845,6 @@ public final class LauncherInstrumentation { mDevice.waitForIdle(); } - float getDisplayDensity() { - return mInstrumentation.getTargetContext().getResources().getDisplayMetrics().density; - } - int getTouchSlop() { return ViewConfiguration.get(getContext()).getScaledTouchSlop(); } -- cgit v1.2.3 From 7ad1026cad1029ca12e95f51f8b7322617f46806 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 25 Sep 2019 13:59:37 -0700 Subject: Continuing experiments with test stability attribute Change-Id: I7ada0a7f4f0e0e9ca90a3d44ae88fc00d54d74df --- .../launcher3/util/rule/TestStabilityRule.java | 115 +++++++++------------ 1 file changed, 49 insertions(+), 66 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java index 8feadbee9..d7f41bf04 100644 --- a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java +++ b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java @@ -40,8 +40,8 @@ public class TestStabilityRule implements TestRule { + "(?(BuildFromAndroidStudio|" + "([0-9]+|[A-Z])-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+))|" + "(?([0-9]+|[A-Z])-P[0-9]+)|" - + "(?([0-9]+|[A-Z])+-[0-9]+|" - + "(?([0-9]+|[A-Z])+))" + + "(?([0-9]+|[A-Z])-[0-9]+)|" + + "(?[0-9]+|[A-Z])" + ")$"); private static final Pattern PLATFORM_BUILD = Pattern.compile("^(" @@ -61,70 +61,7 @@ public class TestStabilityRule implements TestRule { return new Statement() { @Override public void evaluate() throws Throwable { - final String launcherVersion = - getInstrumentation(). - getContext(). - getPackageManager(). - getPackageInfo( - UiDevice.getInstance(getInstrumentation()). - getLauncherPackageName(), - 0). - versionName; - - final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion); - - boolean launcherLocalBuild = false; - boolean launcherUnbundledPresubmit = false; - boolean launcherUnbundledPostsubmit = false; - boolean launcherPlatform = false; - - if (!launcherBuildMatcher.find()) { - Log.e(TAG, "Match not found"); - } else if (launcherBuildMatcher.group("local") != null) { - launcherLocalBuild = true; - } else if (launcherBuildMatcher.group("presubmit") != null) { - launcherUnbundledPresubmit = true; - } else if (launcherBuildMatcher.group("postsubmit") != null) { - launcherUnbundledPostsubmit = true; - } else if (launcherBuildMatcher.group("platform") != null) { - launcherPlatform = true; - } else { - Log.e(TAG, "ERROR1"); - } - - boolean platformLocalBuild = false; - boolean platformPresubmit = false; - boolean platformPostsubmit = false; - - final String platformVersion = Build.VERSION.INCREMENTAL; - final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion); - if (!platformBuildMatcher.find()) { - Log.e(TAG, "Match not found"); - } else if (platformBuildMatcher.group("commandLine") != null) { - platformLocalBuild = true; - } else if (platformBuildMatcher.group("presubmit") != null) { - platformPresubmit = true; - } else if (platformBuildMatcher.group("postsubmit") != null) { - platformPostsubmit = true; - } else { - Log.e(TAG, "ERROR2"); - } - - Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion); - - if (launcherLocalBuild && (platformLocalBuild || platformPostsubmit)) { - Log.d(TAG, "LOCAL RUN"); - } else if (launcherUnbundledPresubmit && platformPostsubmit) { - Log.d(TAG, "UNBUNDLED PRESUBMIT"); - } else if (launcherUnbundledPostsubmit && platformPostsubmit) { - Log.d(TAG, "UNBUNDLED POSTSUBMIT"); - } else if (launcherPlatform && platformPresubmit) { - Log.d(TAG, "PLATFORM PRESUBMIT"); - } else if (launcherPlatform && platformPostsubmit) { - Log.d(TAG, "PLATFORM POSTSUBMIT"); - } else { - Log.e(TAG, "ERROR3"); - } + getRunFlavor(); base.evaluate(); } @@ -133,4 +70,50 @@ public class TestStabilityRule implements TestRule { return base; } } + + private static void getRunFlavor() throws Exception { + final String launcherVersion = getInstrumentation(). + getContext(). + getPackageManager(). + getPackageInfo( + UiDevice.getInstance(getInstrumentation()). + getLauncherPackageName(), + 0). + versionName; + + final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion); + + if (!launcherBuildMatcher.find()) { + Log.e(TAG, "Match not found"); + } + + final String platformVersion = Build.VERSION.INCREMENTAL; + final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion); + + if (!platformBuildMatcher.find()) { + Log.e(TAG, "Match not found"); + } + + Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion); + + if (launcherBuildMatcher.group("local") != null && ( + platformBuildMatcher.group("commandLine") != null || + platformBuildMatcher.group("postsubmit") != null)) { + Log.d(TAG, "LOCAL RUN"); + } else if (launcherBuildMatcher.group("presubmit") != null + && platformBuildMatcher.group("postsubmit") != null) { + Log.d(TAG, "UNBUNDLED PRESUBMIT"); + } else if (launcherBuildMatcher.group("postsubmit") != null + && platformBuildMatcher.group("postsubmit") != null) { + Log.d(TAG, "UNBUNDLED POSTSUBMIT"); + } else if (launcherBuildMatcher.group("platform") != null + && platformBuildMatcher.group("presubmit") != null) { + Log.d(TAG, "PLATFORM PRESUBMIT"); + } else if (launcherBuildMatcher.group("platform") != null + && platformBuildMatcher.group("postsubmit") != null) { + Log.d(TAG, "PLATFORM POSTSUBMIT"); + } else { + Log.e(TAG, "ERROR3"); + } + } } -- cgit v1.2.3 From 7bd93b16393573f15dadc8df39760cee1d3a29dc Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 25 Sep 2019 18:13:23 -0700 Subject: Reducing usage of magic constants in TAPL's widgets Bug: 123904290 Change-Id: I5f158eb06ab5d40825cc975e798296ab06fc1f1f --- tests/tapl/com/android/launcher3/tapl/Widgets.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java index 7d308afb9..af7d5d7cd 100644 --- a/tests/tapl/com/android/launcher3/tapl/Widgets.java +++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java @@ -48,7 +48,12 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { "want to fling forward in widgets")) { LauncherInstrumentation.log("Widgets.flingForward enter"); final UiObject2 widgetsContainer = verifyActiveContainer(); - mLauncher.scroll(widgetsContainer, Direction.DOWN, 1f, MARGINS, FLING_STEPS); + final int margin = widgetsContainer.getVisibleBounds().bottom - + mLauncher.getRealDisplaySize().y + + ResourceUtils.getNavbarSize( + ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()); + mLauncher.scroll( + widgetsContainer, Direction.DOWN, 1f, new Rect(0, 0, 0, margin), FLING_STEPS); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung forward")) { verifyActiveContainer(); } -- cgit v1.2.3 From 3887500f8e550a4817208ae7426bf80f77765b4d Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 25 Sep 2019 18:31:36 -0700 Subject: Reducing usage of magic constants in TAPL's widgets (fling back) Bug: 123904290 Change-Id: I398ff2ebd418551e3fed825edf79398e32025859 --- tests/tapl/com/android/launcher3/tapl/Widgets.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java index 7d308afb9..6593bb196 100644 --- a/tests/tapl/com/android/launcher3/tapl/Widgets.java +++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java @@ -64,7 +64,7 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { "want to fling backwards in widgets")) { LauncherInstrumentation.log("Widgets.flingBackward enter"); final UiObject2 widgetsContainer = verifyActiveContainer(); - mLauncher.scroll(widgetsContainer, Direction.UP, 1f, MARGINS, FLING_STEPS); + mLauncher.scroll(widgetsContainer, Direction.UP, 1f, null, FLING_STEPS); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung back")) { verifyActiveContainer(); } -- cgit v1.2.3 From 46f3999fb3edf447868ec806bfba433e8797ca11 Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 26 Sep 2019 12:30:25 -0700 Subject: Avoiding swiping down from the from the extended touchable region around the notch in Widgets Bug: 141697444 Change-Id: I8edd6a05e34c8a7e91dab1757938d40efffb766f --- tests/tapl/com/android/launcher3/tapl/Widgets.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java index 2a04d46cb..54f730e25 100644 --- a/tests/tapl/com/android/launcher3/tapl/Widgets.java +++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java @@ -69,7 +69,12 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { "want to fling backwards in widgets")) { LauncherInstrumentation.log("Widgets.flingBackward enter"); final UiObject2 widgetsContainer = verifyActiveContainer(); - mLauncher.scroll(widgetsContainer, Direction.UP, 1f, null, FLING_STEPS); + mLauncher.scroll( + widgetsContainer, + Direction.UP, + 1f, + new Rect(0, 0, widgetsContainer.getVisibleBounds().width(), 0), + FLING_STEPS); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung back")) { verifyActiveContainer(); } -- cgit v1.2.3 From aca7e6da5b46bb02b08bf54fb5f62e61a3b21bf6 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 25 Sep 2019 18:13:23 -0700 Subject: Removing magic constants from TAPL/Widgets Bug: 123904290 Change-Id: I8abc6cde6be8a51b38782f5c94749fe0c33384c1 --- .../launcher3/ui/widget/AddConfigWidgetTest.java | 6 +- .../android/launcher3/ui/widget/AddWidgetTest.java | 5 +- tests/tapl/com/android/launcher3/tapl/Widgets.java | 64 +++++++++++++++------- 3 files changed, 49 insertions(+), 26 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java index 3f35a3a73..e1b3edeb5 100644 --- a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java +++ b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java @@ -41,7 +41,6 @@ import com.android.launcher3.util.Wait; import com.android.launcher3.util.rule.ShellCommandRule; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -53,7 +52,8 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class AddConfigWidgetTest extends AbstractLauncherUiTest { - @Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind(); + @Rule + public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind(); private LauncherAppWidgetProviderInfo mWidgetInfo; private AppWidgetManager mAppWidgetManager; @@ -70,14 +70,12 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest { @Test @PortraitLandscape - @org.junit.Ignore public void testWidgetConfig() throws Throwable { runTest(true); } @Test @PortraitLandscape - @org.junit.Ignore public void testConfigCancelled() throws Throwable { runTest(false); } diff --git a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java index 1edce22ec..b8ca5ded3 100644 --- a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java +++ b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java @@ -30,7 +30,6 @@ import com.android.launcher3.ui.AbstractLauncherUiTest; import com.android.launcher3.ui.TestViewHelpers; import com.android.launcher3.util.rule.ShellCommandRule; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -42,11 +41,11 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class AddWidgetTest extends AbstractLauncherUiTest { - @Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind(); + @Rule + public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind(); @Test @PortraitLandscape - @org.junit.Ignore public void testDragIcon() throws Throwable { clearHomescreen(); mDevice.pressHome(); diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java index 2a04d46cb..0cd6c385f 100644 --- a/tests/tapl/com/android/launcher3/tapl/Widgets.java +++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java @@ -16,8 +16,6 @@ package com.android.launcher3.tapl; -import static org.junit.Assert.fail; - import android.graphics.Point; import android.graphics.Rect; @@ -28,11 +26,13 @@ import androidx.test.uiautomator.UiObject2; import com.android.launcher3.ResourceUtils; +import java.util.Collection; +import java.util.Collections; + /** * All widgets container. */ public final class Widgets extends LauncherInstrumentation.VisibleContainer { - private static final Rect MARGINS = new Rect(100, 100, 100, 100); private static final int FLING_STEPS = 10; Widgets(LauncherInstrumentation launcher) { @@ -48,12 +48,12 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { "want to fling forward in widgets")) { LauncherInstrumentation.log("Widgets.flingForward enter"); final UiObject2 widgetsContainer = verifyActiveContainer(); - final int margin = widgetsContainer.getVisibleBounds().bottom - - mLauncher.getRealDisplaySize().y + - ResourceUtils.getNavbarSize( - ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()); mLauncher.scroll( - widgetsContainer, Direction.DOWN, 1f, new Rect(0, 0, 0, margin), FLING_STEPS); + widgetsContainer, + Direction.DOWN, + 1f, + new Rect(0, 0, 0, getBottomGestureMargin(widgetsContainer)), + FLING_STEPS); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung forward")) { verifyActiveContainer(); } @@ -61,6 +61,16 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { } } + private int getBottomGestureMargin(UiObject2 widgetsContainer) { + return widgetsContainer.getVisibleBounds().bottom - mLauncher.getRealDisplaySize().y + + getBottomGestureSize(); + } + + private int getBottomGestureSize() { + return ResourceUtils.getNavbarSize( + ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1; + } + /** * Flings backward (up) and waits the fling's end. */ @@ -83,32 +93,48 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { } public Widget getWidget(String labelText) { - final int margin = ResourceUtils.getNavbarSize( - ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1; final UiObject2 widgetsContainer = verifyActiveContainer(); - widgetsContainer.setGestureMargins(0, 0, 0, margin); - final Point displaySize = mLauncher.getRealDisplaySize(); + final BySelector labelSelector = By.clazz("android.widget.TextView").text(labelText); int i = 0; - final BySelector selector = By.clazz("android.widget.TextView").text(labelText); - for (; ; ) { - final UiObject2 label = mLauncher.tryWaitForLauncherObject(selector, 300); - if (label != null) { + final Collection cells = mLauncher.getObjectsInContainer( + widgetsContainer, "widgets_cell_list_container"); + mLauncher.assertTrue("Widgets doesn't have 2 rows", cells.size() >= 2); + for (UiObject2 cell : cells) { + final UiObject2 label = cell.findObject(labelSelector); + if (label == null) continue; + final UiObject2 widget = label.getParent().getParent(); mLauncher.assertEquals( "View is not WidgetCell", "com.android.launcher3.widget.WidgetCell", widget.getClassName()); - if (widget.getVisibleBounds().bottom <= displaySize.y - margin) { + if (widget.getVisibleBounds().bottom <= displaySize.y - getBottomGestureSize()) { return new Widget(mLauncher, widget); } } - if (++i > 40) fail("Too many attempts"); - mLauncher.scroll(widgetsContainer, Direction.DOWN, 0.7f, MARGINS, 50); + mLauncher.assertTrue("Too many attempts", ++i <= 40); + final UiObject2 lowestCell = Collections.max(cells, (c1, c2) -> + Integer.compare(c1.getVisibleBounds().top, c2.getVisibleBounds().top)); + + final int gestureStart = lowestCell.getVisibleBounds().top + mLauncher.getTouchSlop(); + final int distance = gestureStart - widgetsContainer.getVisibleBounds().top; + final int bottomMargin = widgetsContainer.getVisibleBounds().height() - distance; + + mLauncher.scroll( + widgetsContainer, + Direction.DOWN, + 1f, + new Rect( + 0, + 0, + 0, + Math.max(bottomMargin, getBottomGestureMargin(widgetsContainer))), + 150); } } } -- cgit v1.2.3 From 7028b10c547445f0ea05ce395edc54944e93a6a7 Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 26 Sep 2019 14:17:44 -0700 Subject: Removing magic constant 0.8f from AllApps Bug: 123904290 Change-Id: I52aeb3c0452175ba37b2524d632e8069ba0911c9 Merged-in: I91ff4d4f962eefea787989362c32d987f546e84d --- tests/tapl/com/android/launcher3/tapl/AllApps.java | 7 ++++- .../launcher3/tapl/LauncherInstrumentation.java | 33 ++++++++++++++++++++ tests/tapl/com/android/launcher3/tapl/Widgets.java | 36 +++------------------- 3 files changed, 43 insertions(+), 33 deletions(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java index f070280ea..f63612dd1 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java @@ -90,6 +90,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { final UiObject2 allAppsContainer = verifyActiveContainer(); final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer, "apps_list_view"); + final UiObject2 searchBox = getSearchBox(allAppsContainer); allAppsContainer.setGestureMargins( 0, getSearchBox(allAppsContainer).getVisibleBounds().bottom + 1, @@ -103,7 +104,11 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { int scroll = getScroll(allAppsContainer); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled")) { while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector)) { - mLauncher.scroll(allAppsContainer, Direction.DOWN, 0.8f, null, 50); + mLauncher.scrollToLastVisibleRow( + allAppsContainer, + mLauncher.getObjectsInContainer(allAppsContainer, "icon"), + searchBox.getVisibleBounds().bottom - + allAppsContainer.getVisibleBounds().top); final int newScroll = getScroll(allAppsContainer); if (newScroll == scroll) break; diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 306fe4870..1c8f92e91 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -59,6 +59,7 @@ import androidx.test.uiautomator.UiDevice; import androidx.test.uiautomator.UiObject2; import androidx.test.uiautomator.Until; +import com.android.launcher3.ResourceUtils; import com.android.launcher3.testing.TestProtocol; import com.android.systemui.shared.system.QuickStepContract; @@ -67,6 +68,8 @@ import org.junit.Assert; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.ref.WeakReference; +import java.util.Collection; +import java.util.Collections; import java.util.Deque; import java.util.LinkedList; import java.util.List; @@ -765,6 +768,36 @@ public final class LauncherInstrumentation { TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD))); } + int getBottomGestureSize() { + return ResourceUtils.getNavbarSize( + ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getResources()) + 1; + } + + int getBottomGestureMargin(UiObject2 container) { + return container.getVisibleBounds().bottom - getRealDisplaySize().y + + getBottomGestureSize(); + } + + void scrollToLastVisibleRow(UiObject2 container, Collection items, int topPadding) { + final UiObject2 lowestItem = Collections.max(items, (i1, i2) -> + Integer.compare(i1.getVisibleBounds().top, i2.getVisibleBounds().top)); + + final int gestureStart = lowestItem.getVisibleBounds().top + getTouchSlop(); + final int distance = gestureStart - container.getVisibleBounds().top - topPadding; + final int bottomMargin = container.getVisibleBounds().height() - distance; + + scroll( + container, + Direction.DOWN, + 1f, + new Rect( + 0, + 0, + 0, + Math.max(bottomMargin, getBottomGestureMargin(container))), + 150); + } + void scroll(UiObject2 container, Direction direction, float percent, Rect margins, int steps) { final Rect rect = container.getVisibleBounds(); if (margins != null) { diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java index 39cb0bf7a..aabcac282 100644 --- a/tests/tapl/com/android/launcher3/tapl/Widgets.java +++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java @@ -24,10 +24,7 @@ import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.Direction; import androidx.test.uiautomator.UiObject2; -import com.android.launcher3.ResourceUtils; - import java.util.Collection; -import java.util.Collections; /** * All widgets container. @@ -52,7 +49,7 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { widgetsContainer, Direction.DOWN, 1f, - new Rect(0, 0, 0, getBottomGestureMargin(widgetsContainer)), + new Rect(0, 0, 0, mLauncher.getBottomGestureMargin(widgetsContainer)), FLING_STEPS); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung forward")) { verifyActiveContainer(); @@ -61,16 +58,6 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { } } - private int getBottomGestureMargin(UiObject2 widgetsContainer) { - return widgetsContainer.getVisibleBounds().bottom - mLauncher.getRealDisplaySize().y + - getBottomGestureSize(); - } - - private int getBottomGestureSize() { - return ResourceUtils.getNavbarSize( - ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1; - } - /** * Flings backward (up) and waits the fling's end. */ @@ -117,29 +104,14 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { "com.android.launcher3.widget.WidgetCell", widget.getClassName()); - if (widget.getVisibleBounds().bottom <= displaySize.y - getBottomGestureSize()) { + if (widget.getVisibleBounds().bottom <= + displaySize.y - mLauncher.getBottomGestureSize()) { return new Widget(mLauncher, widget); } } mLauncher.assertTrue("Too many attempts", ++i <= 40); - final UiObject2 lowestCell = Collections.max(cells, (c1, c2) -> - Integer.compare(c1.getVisibleBounds().top, c2.getVisibleBounds().top)); - - final int gestureStart = lowestCell.getVisibleBounds().top + mLauncher.getTouchSlop(); - final int distance = gestureStart - widgetsContainer.getVisibleBounds().top; - final int bottomMargin = widgetsContainer.getVisibleBounds().height() - distance; - - mLauncher.scroll( - widgetsContainer, - Direction.DOWN, - 1f, - new Rect( - 0, - 0, - 0, - Math.max(bottomMargin, getBottomGestureMargin(widgetsContainer))), - 150); + mLauncher.scrollToLastVisibleRow(widgetsContainer, cells, 0); } } } -- cgit v1.2.3 From 83b03b08de944510917e6ee1ebdbea631d5fb4d4 Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 26 Sep 2019 17:52:32 -0700 Subject: Removing a 'percent' parameter for scroll It's an invitation to use magic constants. Bug: 123904290 Change-Id: I485abbbb868c41949dddd6e2c4cf363cc44a5ccd --- tests/tapl/com/android/launcher3/tapl/AllApps.java | 6 +++--- tests/tapl/com/android/launcher3/tapl/BaseOverview.java | 4 ++-- .../com/android/launcher3/tapl/LauncherInstrumentation.java | 11 +++++------ tests/tapl/com/android/launcher3/tapl/Widgets.java | 2 -- tests/tapl/com/android/launcher3/tapl/Workspace.java | 4 ++-- 5 files changed, 12 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java index f63612dd1..6dced8c8c 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java @@ -150,7 +150,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { "Exceeded max scroll attempts: " + MAX_SCROLL_ATTEMPTS, ++attempts <= MAX_SCROLL_ATTEMPTS); - mLauncher.scroll(allAppsContainer, Direction.UP, 1, margins, 50); + mLauncher.scroll(allAppsContainer, Direction.UP, margins, 50); } try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled up")) { @@ -177,7 +177,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { final UiObject2 allAppsContainer = verifyActiveContainer(); // Start the gesture in the center to avoid starting at elements near the top. mLauncher.scroll( - allAppsContainer, Direction.DOWN, 1, new Rect(0, 0, 0, mHeight / 2), 10); + allAppsContainer, Direction.DOWN, new Rect(0, 0, 0, mHeight / 2), 10); verifyActiveContainer(); } } @@ -191,7 +191,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { final UiObject2 allAppsContainer = verifyActiveContainer(); // Start the gesture in the center, for symmetry with forward. mLauncher.scroll( - allAppsContainer, Direction.UP, 1, new Rect(0, mHeight / 2, 0, 0), 10); + allAppsContainer, Direction.UP, new Rect(0, mHeight / 2, 0, 0), 10); verifyActiveContainer(); } } diff --git a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java index 25e6e8c8f..49c0c8908 100644 --- a/tests/tapl/com/android/launcher3/tapl/BaseOverview.java +++ b/tests/tapl/com/android/launcher3/tapl/BaseOverview.java @@ -55,7 +55,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { final int leftMargin = mLauncher.getTestInfo( TestProtocol.REQUEST_OVERVIEW_LEFT_GESTURE_MARGIN). getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); - mLauncher.scroll(overview, Direction.LEFT, 1, new Rect(leftMargin, 0, 0, 0), 20); + mLauncher.scroll(overview, Direction.LEFT, new Rect(leftMargin, 0, 0, 0), 20); verifyActiveContainer(); } } @@ -93,7 +93,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer { final int rightMargin = mLauncher.getTestInfo( TestProtocol.REQUEST_OVERVIEW_RIGHT_GESTURE_MARGIN). getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); - mLauncher.scroll(overview, Direction.RIGHT, 1, new Rect(0, 0, rightMargin, 0), 20); + mLauncher.scroll(overview, Direction.RIGHT, new Rect(0, 0, rightMargin, 0), 20); verifyActiveContainer(); } } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 1c8f92e91..98a7a36d5 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -789,7 +789,6 @@ public final class LauncherInstrumentation { scroll( container, Direction.DOWN, - 1f, new Rect( 0, 0, @@ -798,7 +797,7 @@ public final class LauncherInstrumentation { 150); } - void scroll(UiObject2 container, Direction direction, float percent, Rect margins, int steps) { + void scroll(UiObject2 container, Direction direction, Rect margins, int steps) { final Rect rect = container.getVisibleBounds(); if (margins != null) { rect.left += margins.left; @@ -816,7 +815,7 @@ public final class LauncherInstrumentation { case UP: { startX = endX = rect.centerX(); final int vertCenter = rect.centerY(); - final float halfGestureHeight = rect.height() * percent / 2.0f; + final float halfGestureHeight = rect.height() / 2.0f; startY = (int) (vertCenter - halfGestureHeight) + 1; endY = (int) (vertCenter + halfGestureHeight); } @@ -824,7 +823,7 @@ public final class LauncherInstrumentation { case DOWN: { startX = endX = rect.centerX(); final int vertCenter = rect.centerY(); - final float halfGestureHeight = rect.height() * percent / 2.0f; + final float halfGestureHeight = rect.height() / 2.0f; startY = (int) (vertCenter + halfGestureHeight) - 1; endY = (int) (vertCenter - halfGestureHeight); } @@ -832,7 +831,7 @@ public final class LauncherInstrumentation { case LEFT: { startY = endY = rect.centerY(); final int horizCenter = rect.centerX(); - final float halfGestureWidth = rect.width() * percent / 2.0f; + final float halfGestureWidth = rect.width() / 2.0f; startX = (int) (horizCenter - halfGestureWidth) + 1; endX = (int) (horizCenter + halfGestureWidth); } @@ -840,7 +839,7 @@ public final class LauncherInstrumentation { case RIGHT: { startY = endY = rect.centerY(); final int horizCenter = rect.centerX(); - final float halfGestureWidth = rect.width() * percent / 2.0f; + final float halfGestureWidth = rect.width() / 2.0f; startX = (int) (horizCenter + halfGestureWidth) - 1; endX = (int) (horizCenter - halfGestureWidth); } diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java index aabcac282..51239c9ac 100644 --- a/tests/tapl/com/android/launcher3/tapl/Widgets.java +++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java @@ -48,7 +48,6 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { mLauncher.scroll( widgetsContainer, Direction.DOWN, - 1f, new Rect(0, 0, 0, mLauncher.getBottomGestureMargin(widgetsContainer)), FLING_STEPS); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung forward")) { @@ -69,7 +68,6 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer { mLauncher.scroll( widgetsContainer, Direction.UP, - 1f, new Rect(0, 0, widgetsContainer.getVisibleBounds().width(), 0), FLING_STEPS); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung back")) { diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index da74b66f2..01edcc27d 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -180,7 +180,7 @@ public final class Workspace extends Home { */ public void flingForward() { final UiObject2 workspace = verifyActiveContainer(); - mLauncher.scroll(workspace, Direction.RIGHT, 1f, + mLauncher.scroll(workspace, Direction.RIGHT, new Rect(0, 0, mLauncher.getEdgeSensitivityWidth(), 0), FLING_STEPS); verifyActiveContainer(); @@ -192,7 +192,7 @@ public final class Workspace extends Home { */ public void flingBackward() { final UiObject2 workspace = verifyActiveContainer(); - mLauncher.scroll(workspace, Direction.LEFT, 1f, + mLauncher.scroll(workspace, Direction.LEFT, new Rect(mLauncher.getEdgeSensitivityWidth(), 0, 0, 0), FLING_STEPS); verifyActiveContainer(); -- cgit v1.2.3 From 2611d79f69a5d9250c90db0d57fea6fda84ab105 Mon Sep 17 00:00:00 2001 From: vadimt Date: Fri, 27 Sep 2019 12:00:09 -0700 Subject: Deprecating LauncherInstrumentation constructor with parameter Change-Id: I779b4a8fde2db73cced8133f12d1356ad0b8729e --- tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java | 3 +-- .../com/android/launcher3/tapl/LauncherInstrumentation.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 1f4ba1af0..b20fae431 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -92,8 +92,7 @@ public abstract class AbstractLauncherUiTest { protected MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor(); protected final UiDevice mDevice = UiDevice.getInstance(getInstrumentation()); - protected final LauncherInstrumentation mLauncher = - new LauncherInstrumentation(getInstrumentation()); + protected final LauncherInstrumentation mLauncher = new LauncherInstrumentation(); protected Context mTargetContext; protected String mTargetPackage; diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 1c8f92e91..49d7c7989 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -51,6 +51,7 @@ import android.view.accessibility.AccessibilityEvent; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.test.InstrumentationRegistry; import androidx.test.uiautomator.By; import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.Configurator; @@ -144,6 +145,15 @@ public final class LauncherInstrumentation { /** * Constructs the root of TAPL hierarchy. You get all other objects from it. */ + public LauncherInstrumentation() { + this(InstrumentationRegistry.getInstrumentation()); + } + + /** + * Constructs the root of TAPL hierarchy. You get all other objects from it. + * Deprecated: use the constructor without parameters instead. + */ + @Deprecated public LauncherInstrumentation(Instrumentation instrumentation) { mInstrumentation = instrumentation; mDevice = UiDevice.getInstance(instrumentation); -- cgit v1.2.3 From 41390b8eea6a4b363d8824949665b18a3c9606c3 Mon Sep 17 00:00:00 2001 From: vadimt Date: Fri, 27 Sep 2019 14:24:46 -0700 Subject: Removing a too noisy dropbox diag Change-Id: Ia4dee0b3f20533754b24a91a4a8d2a837bb8e60f --- tests/tapl/com/android/launcher3/tapl/TestHelpers.java | 1 - 1 file changed, 1 deletion(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/TestHelpers.java b/tests/tapl/com/android/launcher3/tapl/TestHelpers.java index 05c987be2..0c9fda321 100644 --- a/tests/tapl/com/android/launcher3/tapl/TestHelpers.java +++ b/tests/tapl/com/android/launcher3/tapl/TestHelpers.java @@ -131,7 +131,6 @@ public class TestHelpers { "system_app_anr", "system_app_crash", "system_app_native_crash", - "system_app_wtf", "system_server_anr", "system_server_crash", "system_server_native_crash", -- cgit v1.2.3 From ea38c25854e87b0fe564cff465038a91f4156be2 Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Tue, 24 Sep 2019 15:32:18 -0700 Subject: removed extra test protocol for unit test Bug: 140406263 Test: run TaplTestsLauncher3 Change-Id: I73b3098bd3aa92fed41d22a94cb58fd07263d26a --- tests/tapl/com/android/launcher3/tapl/Workspace.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java index ad2feb4b5..0aa36ddbb 100644 --- a/tests/tapl/com/android/launcher3/tapl/Workspace.java +++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java @@ -22,7 +22,6 @@ import static junit.framework.TestCase.assertTrue; import android.graphics.Point; import android.graphics.Rect; -import android.os.Bundle; import android.os.SystemClock; import android.view.KeyEvent; import android.view.MotionEvent; @@ -124,7 +123,7 @@ public final class Workspace extends Home { */ public void ensureWorkspaceIsScrollable() { final UiObject2 workspace = verifyActiveContainer(); - if (!isWorkspaceScrollable()) { + if (!isWorkspaceScrollable(workspace)) { try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "dragging icon to a second page of workspace to make it scrollable")) { dragIconToWorkspace( @@ -136,12 +135,12 @@ public final class Workspace extends Home { verifyActiveContainer(); } } - assertTrue("Home screen workspace didn't become scrollable", isWorkspaceScrollable()); + assertTrue("Home screen workspace didn't become scrollable", + isWorkspaceScrollable(workspace)); } - private boolean isWorkspaceScrollable() { - Bundle result = mLauncher.getTestInfo(TestProtocol.REQUEST_DOES_WORKSPACE_HAVE_SECOND_PAGE); - return result.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, false); + private boolean isWorkspaceScrollable(UiObject2 workspace) { + return workspace.getChildCount() > 1; } @NonNull -- cgit v1.2.3 From 5d58d25ea3e335b4f5e118ac3b5da5ec6800b501 Mon Sep 17 00:00:00 2001 From: vadimt Date: Mon, 30 Sep 2019 12:22:01 -0700 Subject: fixingtypo Change-Id: I0d9d9f3f712fc90e82e7660c14ea31779648614a --- tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index d89ec8b5d..52971d92f 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -550,7 +550,7 @@ public final class LauncherInstrumentation { displaySize.x / 2, displaySize.y - 1, displaySize.x / 2, 0, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME); - assertTrue("Context menu is still visible afterswiping up to home", + assertTrue("Context menu is still visible after swiping up to home", !hasLauncherObject("deep_shortcuts_container")); } if (hasLauncherObject(WORKSPACE_RES_ID)) { -- cgit v1.2.3 From ee3db65eccaa2df62b2fb09932fe6ce3625e31a6 Mon Sep 17 00:00:00 2001 From: vadimt Date: Mon, 30 Sep 2019 12:48:47 -0700 Subject: Not unlocking phone on the test start Somehow tests unlock the phone anyways. Bug: 141772190 Change-Id: I66de70ec10a7e9ae05ba942570bf9eff9d9e7a82 --- tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index b20fae431..843fd33c6 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -171,8 +171,6 @@ public abstract class AbstractLauncherUiTest { mTargetContext = InstrumentationRegistry.getTargetContext(); mTargetPackage = mTargetContext.getPackageName(); - // Unlock the phone - mDevice.executeShellCommand("input keyevent 82"); } @After -- cgit v1.2.3 From 7371e4da6846e532592ac14f3a9ab12576a29a1c Mon Sep 17 00:00:00 2001 From: vadimt Date: Fri, 27 Sep 2019 18:44:04 -0700 Subject: Waiting for Launcher model load in out-of-proc tests. Not doing this seems to have caused flakes. Bug: 141770616 Change-Id: Ia9caf20e4a2d93298adf4249ca815ad79bced802 Merged-in: Ia9caf20e4a2d93298adf4249ca815ad79bced802 --- tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java | 3 --- tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java | 1 - 2 files changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java b/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java index a76b4a488..ff21880d0 100644 --- a/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java +++ b/tests/src/com/android/launcher3/ui/DefaultLayoutProviderTest.java @@ -73,7 +73,6 @@ public class DefaultLayoutProviderTest extends AbstractLauncherUiTest { // Launch the home activity mDevice.pressHome(); - waitForModelLoaded(); mLauncher.getWorkspace().getHotseatAppIcon(getSettingsApp().getLabel().toString()); } @@ -89,7 +88,6 @@ public class DefaultLayoutProviderTest extends AbstractLauncherUiTest { // Launch the home activity mDevice.pressHome(); - waitForModelLoaded(); // Verify widget present assertTrue("Widget is not present", @@ -106,7 +104,6 @@ public class DefaultLayoutProviderTest extends AbstractLauncherUiTest { // Launch the home activity mDevice.pressHome(); - waitForModelLoaded(); mLauncher.getWorkspace().getHotseatFolder("Folder: Copy"); } diff --git a/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java index e6348d9c0..f42bf1f3c 100644 --- a/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java +++ b/tests/src/com/android/launcher3/ui/widget/BindWidgetTest.java @@ -271,7 +271,6 @@ public class BindWidgetTest extends AbstractLauncherUiTest { // Launch the home activity mDevice.pressHome(); - waitForModelLoaded(); } private void verifyWidgetPresent(LauncherAppWidgetProviderInfo info) { -- cgit v1.2.3 From 769c795edfe77fe2a3f6472a5b60fd1a73618a13 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Tue, 1 Oct 2019 13:52:22 -0700 Subject: Some cleanup for SwipeDetector. It is now organized as follows: - private constants - public constants - private final fields - private variable fields - constructors - public methods - private methods - public interface/abstract class This is intended to be a functional no-op. Bug: 141939911 Change-Id: Iad5a9b3b73b35641f8a4f1d52ada6adef3825c47 Tested: Built and sanity checked manually. --- tests/src/com/android/launcher3/touch/SwipeDetectorTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java index e04235708..f209fae97 100644 --- a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java +++ b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java @@ -25,6 +25,10 @@ import static org.mockito.Mockito.verify; import android.util.Log; import android.view.ViewConfiguration; +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + import com.android.launcher3.testcomponent.TouchEventGenerator; import org.junit.Before; @@ -33,10 +37,6 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - @SmallTest @RunWith(AndroidJUnit4.class) public class SwipeDetectorTest { -- cgit v1.2.3 From 8ecf1b3dd3f944cc2488151111deed7f37fb81f6 Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 1 Oct 2019 18:28:46 -0700 Subject: Waiting until context menu goes away after attempting to close it. Bug: 141770616 Change-Id: I528072e830627d825906ce7c1e3dbb914e2c814e --- tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 52971d92f..ca15a3cf8 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -550,8 +550,10 @@ public final class LauncherInstrumentation { displaySize.x / 2, displaySize.y - 1, displaySize.x / 2, 0, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME); - assertTrue("Context menu is still visible after swiping up to home", - !hasLauncherObject("deep_shortcuts_container")); + try (LauncherInstrumentation.Closable c = addContextLayer( + "Swiped up from context menu to home")) { + waitUntilGone("deep_shortcuts_container"); + } } if (hasLauncherObject(WORKSPACE_RES_ID)) { log(action = "already at home"); -- cgit v1.2.3 From 7458d4aa4ac03536cf02cb06a678540c7b80cb94 Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 1 Oct 2019 18:40:24 -0700 Subject: Logging the initial state for swiping up to home Change-Id: Iff2003f7e6dfe4072613b775722166dc5fec9e02 --- tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 52971d92f..8a60db6f1 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -556,7 +556,7 @@ public final class LauncherInstrumentation { if (hasLauncherObject(WORKSPACE_RES_ID)) { log(action = "already at home"); } else { - log(action = "swiping up to home"); + log(action = "swiping up to home from " + getVisibleStateMessage()); final int finalState = mDevice.hasObject(By.pkg(getLauncherPackageName())) ? NORMAL_STATE_ORDINAL : BACKGROUND_APP_STATE_ORDINAL; -- cgit v1.2.3 From 233afe98e92935e2f5cf0813994a84fdc7763b4d Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 2 Oct 2019 17:10:02 -0700 Subject: Dump view hierarchy before swiping to home Bug: 141864547 Change-Id: Ifd444c4516f7f27b0dc19c0faa1d4c8716d2254a --- tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 2e9cb81f0..24d4964d5 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -558,6 +558,8 @@ public final class LauncherInstrumentation { if (hasLauncherObject(WORKSPACE_RES_ID)) { log(action = "already at home"); } else { + log("Hierarchy before swiping up to home"); + dumpViewHierarchy(); log(action = "swiping up to home from " + getVisibleStateMessage()); final int finalState = mDevice.hasObject(By.pkg(getLauncherPackageName())) ? NORMAL_STATE_ORDINAL : BACKGROUND_APP_STATE_ORDINAL; -- cgit v1.2.3 From d625e49552a96d384745174ff6a137f1dd7837b7 Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Wed, 2 Oct 2019 11:25:44 -0700 Subject: include integration test for adding shortcut widget this integration test help us catching app crashes when adding shortcut widgets to the workplace. see b/141568904 for more context. Bug: 141934188 Change-Id: I4d33d6127793efe2071d0d146aef24db6b676360 --- tests/AndroidManifest-common.xml | 6 +++ .../ShortcutWidgetConfigActivity.java | 62 ++++++++++++++++++++++ .../android/launcher3/ui/TaplTestsLauncher3.java | 9 ++++ 3 files changed, 77 insertions(+) create mode 100644 tests/src/com/android/launcher3/testcomponent/ShortcutWidgetConfigActivity.java (limited to 'tests') diff --git a/tests/AndroidManifest-common.xml b/tests/AndroidManifest-common.xml index c6f55a717..6802152c7 100644 --- a/tests/AndroidManifest-common.xml +++ b/tests/AndroidManifest-common.xml @@ -62,6 +62,12 @@ + + + + + + Date: Thu, 3 Oct 2019 10:15:30 -0700 Subject: correct naming and add comments for test case of custom shortcut. Bug: 141934188 Change-Id: I69ce5f05214df10e2a376ff68c713efe8874df15 --- tests/AndroidManifest-common.xml | 2 +- .../CustomShortcutConfigActivity.java | 66 ++++++++++++++++++++++ .../ShortcutWidgetConfigActivity.java | 62 -------------------- .../android/launcher3/ui/TaplTestsLauncher3.java | 11 +++- 4 files changed, 76 insertions(+), 65 deletions(-) create mode 100644 tests/src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java delete mode 100644 tests/src/com/android/launcher3/testcomponent/ShortcutWidgetConfigActivity.java (limited to 'tests') diff --git a/tests/AndroidManifest-common.xml b/tests/AndroidManifest-common.xml index 6802152c7..ffa90b9c5 100644 --- a/tests/AndroidManifest-common.xml +++ b/tests/AndroidManifest-common.xml @@ -62,7 +62,7 @@ - + diff --git a/tests/src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java b/tests/src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java new file mode 100644 index 000000000..b673faa6f --- /dev/null +++ b/tests/src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2019 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.launcher3.testcomponent; + +import android.content.Context; +import android.content.Intent; +import android.content.pm.ShortcutInfo; +import android.content.pm.ShortcutManager; +import android.graphics.drawable.Icon; +import android.os.Bundle; + +import com.android.launcher3.R; + +import java.util.UUID; + +/** + * A custom shortcut is a 1x1 widget that launches a specific intent when user tap on it. + * Custom shortcuts are replaced by deep shortcuts after api 25. + */ +public class CustomShortcutConfigActivity extends BaseTestingActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent launchIntent = new Intent(this, BaseTestingActivity.class) + .setAction("com.android.launcher3.intent.action.test_shortcut"); + Intent shortcutIntent = createShortcutResultIntent( + this, UUID.randomUUID().toString(), "Shortcut", + R.drawable.ic_widget, launchIntent); + setResult(RESULT_OK, shortcutIntent); + finish(); + } + + private static Intent createShortcutResultIntent( + Context context, String uniqueId, String name, int iconId, Intent launchIntent) { + ShortcutInfo shortcutInfo = + createShortcutInfo(context, uniqueId, name, iconId, launchIntent); + ShortcutManager sm = context.getSystemService(ShortcutManager.class); + return sm.createShortcutResultIntent(shortcutInfo); + } + + private static ShortcutInfo createShortcutInfo( + Context context, String uniqueId, String name, int iconId, Intent launchIntent) { + return new ShortcutInfo.Builder(context, uniqueId) + .setShortLabel(name) + .setLongLabel(name) + .setIcon(Icon.createWithResource(context, iconId)) + .setIntent(launchIntent) + .build(); + } +} diff --git a/tests/src/com/android/launcher3/testcomponent/ShortcutWidgetConfigActivity.java b/tests/src/com/android/launcher3/testcomponent/ShortcutWidgetConfigActivity.java deleted file mode 100644 index f9d5f2d43..000000000 --- a/tests/src/com/android/launcher3/testcomponent/ShortcutWidgetConfigActivity.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2019 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.launcher3.testcomponent; - -import android.content.Context; -import android.content.Intent; -import android.content.pm.ShortcutInfo; -import android.content.pm.ShortcutManager; -import android.graphics.drawable.Icon; -import android.os.Bundle; - -import com.android.launcher3.R; - -import java.util.UUID; - -public class ShortcutWidgetConfigActivity extends BaseTestingActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - Intent launchIntent = new Intent(this, BaseTestingActivity.class) - .setAction("com.android.launcher3.intent.action.test_shortcut"); - Intent shortcutIntent = createShortcutResultIntent( - this, UUID.randomUUID().toString(), "Shortcut", - R.drawable.ic_widget, launchIntent); - setResult(RESULT_OK, shortcutIntent); - finish(); - } - - private static Intent createShortcutResultIntent( - Context context, String uniqueId, String name, int iconId, Intent launchIntent) { - ShortcutInfo shortcutInfo = - createShortcutInfo(context, uniqueId, name, iconId, launchIntent); - ShortcutManager sm = context.getSystemService(ShortcutManager.class); - return sm.createShortcutResultIntent(shortcutInfo); - } - - private static ShortcutInfo createShortcutInfo( - Context context, String uniqueId, String name, int iconId, Intent launchIntent) { - return new ShortcutInfo.Builder(context, uniqueId) - .setShortLabel(name) - .setLongLabel(name) - .setIcon(Icon.createWithResource(context, iconId)) - .setIntent(launchIntent) - .build(); - } -} diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 38dba1628..709822bbb 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -342,10 +342,17 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { } } + /** + * Test dragging a custom shortcut to the workspace and launch it. + * + * A custom shortcut is a 1x1 widget that launches a specific intent when user tap on it. + * Custom shortcuts are replaced by deep shortcuts after api 25. + */ @Test - public void testDragShortcutWidget() { + @PortraitLandscape + public void testDragCustomShortcut() { mLauncher.getWorkspace().openAllWidgets() - .getWidget("com.android.launcher3.testcomponent.ShortcutWidgetConfigActivity") + .getWidget("com.android.launcher3.testcomponent.CustomShortcutConfigActivity") .dragToWorkspace(); mLauncher.getWorkspace().getWorkspaceAppIcon("Shortcut") .launch(getAppPackageName()); -- cgit v1.2.3 From 43c3d2d40aded198d52dfdac731ef4f3ce1b7223 Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 3 Oct 2019 17:09:16 -0700 Subject: Diagnosing anomalies prior to swiping up to Home Bug: 141864547 Change-Id: I5f3814c6a90df85136484813ca4ee684da101016 --- tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 2e9cb81f0..28f57f0eb 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -543,6 +543,9 @@ public final class LauncherInstrumentation { // accessibility events prior to pressing Home. final String action; if (getNavigationModel() == NavigationModel.ZERO_BUTTON) { + final String anomaly = getAnomalyMessage(); + if (anomaly != null) fail("Can't swipe up to Home: " + anomaly); + final Point displaySize = getRealDisplaySize(); if (hasLauncherObject("deep_shortcuts_container")) { -- cgit v1.2.3 From 1e73e320b78adaac5dd74835ad6a51a3c5589fd3 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Mon, 7 Oct 2019 17:08:20 -0700 Subject: Add tests for quick switch from an app and home Bug: 140252765 Change-Id: I5621b614ae2d8cd3db03cae818cf8b8c1c6cb20f --- .../com/android/launcher3/tapl/Background.java | 41 ++++++++++++++++++++++ tests/tapl/com/android/launcher3/tapl/Home.java | 6 ++++ 2 files changed, 47 insertions(+) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java index bcce8ef57..0dd3e775c 100644 --- a/tests/tapl/com/android/launcher3/tapl/Background.java +++ b/tests/tapl/com/android/launcher3/tapl/Background.java @@ -23,6 +23,7 @@ import android.os.SystemClock; import android.view.MotionEvent; import androidx.annotation.NonNull; +import androidx.test.uiautomator.UiObject2; import com.android.launcher3.testing.TestProtocol; @@ -114,6 +115,46 @@ public class Background extends LauncherInstrumentation.VisibleContainer { } } + /** + * Swipes right or double presses the square button to switch to the previous app. + */ + public Background quickSwitchToPreviousApp() { + try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer( + "want to quick switch to the previous app")) { + verifyActiveContainer(); + quickSwitchToPreviousApp(getExpectedStateForQuickSwitch()); + return new Background(mLauncher); + } + } + + protected int getExpectedStateForQuickSwitch() { + return BACKGROUND_APP_STATE_ORDINAL; + } + + protected void quickSwitchToPreviousApp(int expectedState) { + switch (mLauncher.getNavigationModel()) { + case ZERO_BUTTON: + // Fall through, zero button and two button modes behave the same. + case TWO_BUTTON: { + // Swipe from the bottom left to the bottom right of the screen. + final int startX = 0; + final int startY = getSwipeStartY(); + final int endX = mLauncher.getDevice().getDisplayWidth(); + final int endY = startY; + mLauncher.swipeToState(startX, startY, endX, endY, 20, expectedState); + break; + } + + case THREE_BUTTON: + // Double press the recents button. + UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps"); + recentsButton.click(); + mLauncher.getOverview(); + recentsButton.click(); + break; + } + } + protected String getSwipeHeightRequestName() { return TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT; } diff --git a/tests/tapl/com/android/launcher3/tapl/Home.java b/tests/tapl/com/android/launcher3/tapl/Home.java index cfc43749d..e0fe933ee 100644 --- a/tests/tapl/com/android/launcher3/tapl/Home.java +++ b/tests/tapl/com/android/launcher3/tapl/Home.java @@ -17,6 +17,7 @@ package com.android.launcher3.tapl; import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL; +import static com.android.launcher3.testing.TestProtocol.QUICK_SWITCH_STATE_ORDINAL; import androidx.annotation.NonNull; @@ -58,4 +59,9 @@ public abstract class Home extends Background { } } } + + @Override + protected int getExpectedStateForQuickSwitch() { + return QUICK_SWITCH_STATE_ORDINAL; + } } \ No newline at end of file -- cgit v1.2.3 From a0f77c4449753490adca6863cbf97c509e70e17a Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 15 Oct 2019 15:24:39 -0700 Subject: Fix quick switch test gesture in landscape 2-button mode It should swipe from the bottom right to top right when the nav bar is on the right, rather than from the bottom left to bottom right. For now, disable testQuickSwitchFromApp() because it seems to have other failures as well. Bug: 140252765 Change-Id: I1f4989f3ea5456c18bb9cbf42ea4b157cee500d7 --- .../com/android/launcher3/tapl/Background.java | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java index 0dd3e775c..db3d846a0 100644 --- a/tests/tapl/com/android/launcher3/tapl/Background.java +++ b/tests/tapl/com/android/launcher3/tapl/Background.java @@ -132,15 +132,29 @@ public class Background extends LauncherInstrumentation.VisibleContainer { } protected void quickSwitchToPreviousApp(int expectedState) { + boolean transposeInLandscape = false; switch (mLauncher.getNavigationModel()) { - case ZERO_BUTTON: + case TWO_BUTTON: + transposeInLandscape = true; // Fall through, zero button and two button modes behave the same. - case TWO_BUTTON: { - // Swipe from the bottom left to the bottom right of the screen. - final int startX = 0; - final int startY = getSwipeStartY(); - final int endX = mLauncher.getDevice().getDisplayWidth(); - final int endY = startY; + case ZERO_BUTTON: { + final int startX; + final int startY; + final int endX; + final int endY; + if (mLauncher.getDevice().isNaturalOrientation() || !transposeInLandscape) { + // Swipe from the bottom left to the bottom right of the screen. + startX = 0; + startY = getSwipeStartY(); + endX = mLauncher.getDevice().getDisplayWidth(); + endY = startY; + } else { + // Swipe from the bottom right to the top right of the screen. + startX = getSwipeStartX(); + startY = mLauncher.getRealDisplaySize().y - 1; + endX = startX; + endY = 0; + } mLauncher.swipeToState(startX, startY, endX, endY, 20, expectedState); break; } -- cgit v1.2.3 From 476b7d4378937d0128edf60779cfbdb77aa799ed Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 16 Oct 2019 14:31:29 -0700 Subject: Fix testQuickSwitchFromApp Instead of starting getAppPackageName() and relying on it being our Test Pin Item activity, instead launch our own test activities with the FLAG_ACTIVITY_MULTIPLE_TASK and FLAG_ACTIVITY_NEW_DOCUMENT flags. Test: - Locally run testQuickSwitchFromApp() from Android Studio - flake -oop -t com.android.quickstep.TaplTestsQuickstep#testQuickSwitchFromApp Bug: 140252765 Change-Id: Ie137261ce65bfd3dd39df78d57784854a026e967 Merged-In: Ie137261ce65bfd3dd39df78d57784854a026e967 --- .../android/launcher3/ui/AbstractLauncherUiTest.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 0f5000944..9a894b1ee 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -15,8 +15,6 @@ */ package com.android.launcher3.ui; -import static androidx.test.InstrumentationRegistry.getInstrumentation; - import static com.android.launcher3.tapl.LauncherInstrumentation.ContainerType; import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; @@ -25,6 +23,8 @@ import static org.junit.Assert.assertTrue; import static java.lang.System.exit; +import static androidx.test.InstrumentationRegistry.getInstrumentation; + import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -348,7 +348,8 @@ public abstract class AbstractLauncherUiTest { startIntent( getInstrumentation().getContext().getPackageManager().getLaunchIntentForPackage( packageName), - By.pkg(packageName).depth(0)); + By.pkg(packageName).depth(0), + true /* newTask */); } protected void startTestActivity(int activityNumber) { @@ -357,12 +358,17 @@ public abstract class AbstractLauncherUiTest { getLaunchIntentForPackage(packageName); intent.setComponent(new ComponentName(packageName, "com.android.launcher3.tests.Activity" + activityNumber)); - startIntent(intent, By.pkg(packageName).text("TestActivity" + activityNumber)); + startIntent(intent, By.pkg(packageName).text("TestActivity" + activityNumber), + false /* newTask */); } - private void startIntent(Intent intent, BySelector selector) { + private void startIntent(Intent intent, BySelector selector, boolean newTask) { intent.addCategory(Intent.CATEGORY_LAUNCHER); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + if (newTask) { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + } else { + intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT); + } getInstrumentation().getTargetContext().startActivity(intent); assertTrue("App didn't start: " + selector, mDevice.wait(Until.hasObject(selector), DEFAULT_UI_TIMEOUT)); -- cgit v1.2.3 From eed585b0c3ac027719121ec064d22026f3930691 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 15 Aug 2019 17:24:07 -0700 Subject: Refactor SwipeDetector to track both axes Existing clients now use the SingleAxisSwipeDetector subclass. A followup CL will add BothAxesSwipeDetector, whose first client will be the quick switch from home controller. Bug: 126596417 Change-Id: I54c71088cfe99ff28cdc719a1eb7a7d06ac95d2d Merged-In: I54c71088cfe99ff28cdc719a1eb7a7d06ac95d2d --- .../touch/SingleAxisSwipeDetectorTest.java | 171 +++++++++++++++++++++ .../android/launcher3/touch/SwipeDetectorTest.java | 165 -------------------- 2 files changed, 171 insertions(+), 165 deletions(-) create mode 100644 tests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java delete mode 100644 tests/src/com/android/launcher3/touch/SwipeDetectorTest.java (limited to 'tests') diff --git a/tests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java b/tests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java new file mode 100644 index 000000000..5174e4dab --- /dev/null +++ b/tests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2017 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.launcher3.touch; + +import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_BOTH; +import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_NEGATIVE; +import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_POSITIVE; +import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL; +import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL; + +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.anyFloat; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + +import android.util.Log; +import android.view.ViewConfiguration; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import com.android.launcher3.testcomponent.TouchEventGenerator; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class SingleAxisSwipeDetectorTest { + + private static final String TAG = SingleAxisSwipeDetectorTest.class.getSimpleName(); + public static void L(String s, Object... parts) { + Log.d(TAG, (parts.length == 0) ? s : String.format(s, parts)); + } + + private TouchEventGenerator mGenerator; + private SingleAxisSwipeDetector mDetector; + private int mTouchSlop; + + @Mock + private SingleAxisSwipeDetector.Listener mMockListener; + + @Mock + private ViewConfiguration mMockConfig; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + mGenerator = new TouchEventGenerator((ev) -> mDetector.onTouchEvent(ev)); + ViewConfiguration orgConfig = ViewConfiguration + .get(InstrumentationRegistry.getTargetContext()); + doReturn(orgConfig.getScaledMaximumFlingVelocity()).when(mMockConfig) + .getScaledMaximumFlingVelocity(); + + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, VERTICAL, false); + mDetector.setDetectableScrollConditions(DIRECTION_BOTH, false); + mTouchSlop = orgConfig.getScaledTouchSlop(); + doReturn(mTouchSlop).when(mMockConfig).getScaledTouchSlop(); + + L("mTouchSlop=", mTouchSlop); + } + + @Test + public void testDragStart_verticalPositive() { + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, VERTICAL, false); + mDetector.setDetectableScrollConditions(DIRECTION_POSITIVE, false); + mGenerator.put(0, 100, 100); + mGenerator.move(0, 100, 100 - mTouchSlop); + // TODO: actually calculate the following parameters and do exact value checks. + verify(mMockListener).onDragStart(anyBoolean()); + } + + @Test + public void testDragStart_verticalNegative() { + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, VERTICAL, false); + mDetector.setDetectableScrollConditions(DIRECTION_NEGATIVE, false); + mGenerator.put(0, 100, 100); + mGenerator.move(0, 100, 100 + mTouchSlop); + // TODO: actually calculate the following parameters and do exact value checks. + verify(mMockListener).onDragStart(anyBoolean()); + } + + @Test + public void testDragStart_failed() { + mGenerator.put(0, 100, 100); + mGenerator.move(0, 100 + mTouchSlop, 100); + // TODO: actually calculate the following parameters and do exact value checks. + verify(mMockListener, never()).onDragStart(anyBoolean()); + } + + @Test + public void testDragStart_horizontalPositive() { + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, HORIZONTAL, false); + mDetector.setDetectableScrollConditions(DIRECTION_POSITIVE, false); + + mGenerator.put(0, 100, 100); + mGenerator.move(0, 100 + mTouchSlop, 100); + // TODO: actually calculate the following parameters and do exact value checks. + verify(mMockListener).onDragStart(anyBoolean()); + } + + @Test + public void testDragStart_horizontalNegative() { + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, HORIZONTAL, false); + mDetector.setDetectableScrollConditions(DIRECTION_NEGATIVE, false); + + mGenerator.put(0, 100, 100); + mGenerator.move(0, 100 - mTouchSlop, 100); + // TODO: actually calculate the following parameters and do exact value checks. + verify(mMockListener).onDragStart(anyBoolean()); + } + + @Test + public void testDragStart_horizontalRtlPositive() { + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, HORIZONTAL, true); + mDetector.setDetectableScrollConditions(DIRECTION_POSITIVE, false); + + mGenerator.put(0, 100, 100); + mGenerator.move(0, 100 - mTouchSlop, 100); + // TODO: actually calculate the following parameters and do exact value checks. + verify(mMockListener).onDragStart(anyBoolean()); + } + + @Test + public void testDragStart_horizontalRtlNegative() { + mDetector = new SingleAxisSwipeDetector(mMockConfig, mMockListener, HORIZONTAL, true); + mDetector.setDetectableScrollConditions(DIRECTION_NEGATIVE, false); + + mGenerator.put(0, 100, 100); + mGenerator.move(0, 100 + mTouchSlop, 100); + // TODO: actually calculate the following parameters and do exact value checks. + verify(mMockListener).onDragStart(anyBoolean()); + } + + @Test + public void testDrag() { + mGenerator.put(0, 100, 100); + mGenerator.move(0, 100, 100 + mTouchSlop); + // TODO: actually calculate the following parameters and do exact value checks. + verify(mMockListener).onDrag(anyFloat(), anyObject()); + } + + @Test + public void testDragEnd() { + mGenerator.put(0, 100, 100); + mGenerator.move(0, 100, 100 + mTouchSlop); + mGenerator.move(0, 100, 100 + mTouchSlop * 2); + mGenerator.lift(0); + // TODO: actually calculate the following parameters and do exact value checks. + verify(mMockListener).onDragEnd(anyFloat()); + } +} diff --git a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java deleted file mode 100644 index f209fae97..000000000 --- a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2017 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.launcher3.touch; - -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyFloat; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -import android.util.Log; -import android.view.ViewConfiguration; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import com.android.launcher3.testcomponent.TouchEventGenerator; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -@SmallTest -@RunWith(AndroidJUnit4.class) -public class SwipeDetectorTest { - - private static final String TAG = SwipeDetectorTest.class.getSimpleName(); - public static void L(String s, Object... parts) { - Log.d(TAG, (parts.length == 0) ? s : String.format(s, parts)); - } - - private TouchEventGenerator mGenerator; - private SwipeDetector mDetector; - private int mTouchSlop; - - @Mock - private SwipeDetector.Listener mMockListener; - - @Mock - private ViewConfiguration mMockConfig; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - mGenerator = new TouchEventGenerator((ev) -> mDetector.onTouchEvent(ev)); - ViewConfiguration orgConfig = ViewConfiguration - .get(InstrumentationRegistry.getTargetContext()); - doReturn(orgConfig.getScaledMaximumFlingVelocity()).when(mMockConfig) - .getScaledMaximumFlingVelocity(); - - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_BOTH, false); - mTouchSlop = orgConfig.getScaledTouchSlop(); - doReturn(mTouchSlop).when(mMockConfig).getScaledTouchSlop(); - - L("mTouchSlop=", mTouchSlop); - } - - @Test - public void testDragStart_verticalPositive() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false); - mGenerator.put(0, 100, 100); - mGenerator.move(0, 100, 100 - mTouchSlop); - // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener).onDragStart(anyBoolean()); - } - - @Test - public void testDragStart_verticalNegative() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, false); - mGenerator.put(0, 100, 100); - mGenerator.move(0, 100, 100 + mTouchSlop); - // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener).onDragStart(anyBoolean()); - } - - @Test - public void testDragStart_failed() { - mGenerator.put(0, 100, 100); - mGenerator.move(0, 100 + mTouchSlop, 100); - // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener, never()).onDragStart(anyBoolean()); - } - - @Test - public void testDragStart_horizontalPositive() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, false); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false); - - mGenerator.put(0, 100, 100); - mGenerator.move(0, 100 + mTouchSlop, 100); - // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener).onDragStart(anyBoolean()); - } - - @Test - public void testDragStart_horizontalNegative() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, false); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, false); - - mGenerator.put(0, 100, 100); - mGenerator.move(0, 100 - mTouchSlop, 100); - // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener).onDragStart(anyBoolean()); - } - - @Test - public void testDragStart_horizontalRtlPositive() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, true); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false); - - mGenerator.put(0, 100, 100); - mGenerator.move(0, 100 - mTouchSlop, 100); - // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener).onDragStart(anyBoolean()); - } - - @Test - public void testDragStart_horizontalRtlNegative() { - mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, true); - mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, false); - - mGenerator.put(0, 100, 100); - mGenerator.move(0, 100 + mTouchSlop, 100); - // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener).onDragStart(anyBoolean()); - } - - @Test - public void testDrag() { - mGenerator.put(0, 100, 100); - mGenerator.move(0, 100, 100 + mTouchSlop); - // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener).onDrag(anyFloat(), anyObject()); - } - - @Test - public void testDragEnd() { - mGenerator.put(0, 100, 100); - mGenerator.move(0, 100, 100 + mTouchSlop); - mGenerator.move(0, 100, 100 + mTouchSlop * 2); - mGenerator.lift(0); - // TODO: actually calculate the following parameters and do exact value checks. - verify(mMockListener).onDragEnd(anyFloat(), anyBoolean()); - } -} -- cgit v1.2.3 From d9dd8ef3babff6484d79859294682863dde37d39 Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Tue, 12 Nov 2019 16:27:15 -0800 Subject: disable custom shortcut test in oop Bug: 142154748 Change-Id: I08ec8f665a3cc45610f8f2b27a60f7334a2b1b24 --- tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 709822bbb..98a0a01a4 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -349,6 +349,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { * Custom shortcuts are replaced by deep shortcuts after api 25. */ @Test + @Ignore // b/143725213 @PortraitLandscape public void testDragCustomShortcut() { mLauncher.getWorkspace().openAllWidgets() -- cgit v1.2.3 From ec7c044c89fb9168d44b81c58325aaba3ec73606 Mon Sep 17 00:00:00 2001 From: vadimt Date: Tue, 12 Nov 2019 16:57:48 -0800 Subject: Tapl: AllApps: ensuring a minimal vertical size of an icon Clicking an icon within its padding area is ignored by Launcher. Hence, ensuring that the icon on AllApps is higher that 2 paddings. Bug: 141770616 Change-Id: I19e3ba7cfa25de75a47202845d0838bea46af92c Merged-In: I19e3ba7cfa25de75a47202845d0838bea46af92c --- tests/tapl/com/android/launcher3/tapl/AllApps.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java index 6dced8c8c..96e4b8c91 100644 --- a/tests/tapl/com/android/launcher3/tapl/AllApps.java +++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java @@ -36,6 +36,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { private static final int MAX_SCROLL_ATTEMPTS = 40; private final int mHeight; + private final int mIconHeight; AllApps(LauncherInstrumentation launcher) { super(launcher); @@ -46,6 +47,10 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { // Wait for the recycler to populate. mLauncher.waitForObjectInContainer(appListRecycler, By.clazz(TextView.class)); verifyNotFrozen("All apps freeze flags upon opening all apps"); + mIconHeight = mLauncher.getTestInfo( + TestProtocol.REQUEST_ICON_HEIGHT) + .getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD); + } @Override @@ -62,6 +67,10 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer { } final Rect iconBounds = icon.getVisibleBounds(); LauncherInstrumentation.log("hasClickableIcon: icon bounds: " + iconBounds); + if (iconBounds.height() < mIconHeight / 2) { + LauncherInstrumentation.log("hasClickableIcon: icon has insufficient height"); + return false; + } if (iconCenterInSearchBox(allAppsContainer, icon)) { LauncherInstrumentation.log("hasClickableIcon: icon center is under search box"); return false; -- cgit v1.2.3 From 838f4393b6a308a89b49eb1edb38ba98e0fac514 Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Thu, 14 Nov 2019 10:51:39 -0800 Subject: fix custom shortcut test Bug: 143725213 Change-Id: I296452faea67568b39a35968bb813dc4e51a51fc Merged-In: I296452faea67568b39a35968bb813dc4e51a51fc --- .../com/android/launcher3/ui/TaplTestsLauncher3.java | 17 ----------------- .../com/android/launcher3/ui/widget/AddWidgetTest.java | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 98a0a01a4..2cf6c2ba7 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -342,23 +342,6 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { } } - /** - * Test dragging a custom shortcut to the workspace and launch it. - * - * A custom shortcut is a 1x1 widget that launches a specific intent when user tap on it. - * Custom shortcuts are replaced by deep shortcuts after api 25. - */ - @Test - @Ignore // b/143725213 - @PortraitLandscape - public void testDragCustomShortcut() { - mLauncher.getWorkspace().openAllWidgets() - .getWidget("com.android.launcher3.testcomponent.CustomShortcutConfigActivity") - .dragToWorkspace(); - mLauncher.getWorkspace().getWorkspaceAppIcon("Shortcut") - .launch(getAppPackageName()); - } - public static String getAppPackageName() { return getInstrumentation().getContext().getPackageName(); } diff --git a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java index b8ca5ded3..f9d1d93b3 100644 --- a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java +++ b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java @@ -69,4 +69,22 @@ public class AddWidgetTest extends AbstractLauncherUiTest { assertNotNull("Widget not found on the workspace", widget); widget.launch(getAppPackageName()); } + + /** + * Test dragging a custom shortcut to the workspace and launch it. + * + * A custom shortcut is a 1x1 widget that launches a specific intent when user tap on it. + * Custom shortcuts are replaced by deep shortcuts after api 25. + */ + @Test + @PortraitLandscape + public void testDragCustomShortcut() throws Throwable { + clearHomescreen(); + mDevice.pressHome(); + mLauncher.getWorkspace().openAllWidgets() + .getWidget("com.android.launcher3.testcomponent.CustomShortcutConfigActivity") + .dragToWorkspace(); + mLauncher.getWorkspace().getWorkspaceAppIcon("Shortcut") + .launch(getAppPackageName()); + } } -- cgit v1.2.3