summaryrefslogtreecommitdiffstats
path: root/tests/tapl/com
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tapl/com')
-rw-r--r--tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java32
-rw-r--r--tests/tapl/com/android/launcher3/tapl/Widget.java24
-rw-r--r--tests/tapl/com/android/launcher3/tapl/WidgetCell.java28
-rw-r--r--tests/tapl/com/android/launcher3/tapl/Workspace.java16
4 files changed, 89 insertions, 11 deletions
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 7171bf9ac..671e8fdf9 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -502,6 +502,13 @@ public final class LauncherInstrumentation {
}
}
+ @NonNull
+ public WidgetCell getWidgetCell() {
+ try (LauncherInstrumentation.Closable c = addContextLayer("want to get widget cell")) {
+ return new WidgetCell(this);
+ }
+ }
+
/**
* Gets the Overview object if the current state is showing the overview panel. Fails if the
* launcher is not in that state.
@@ -516,17 +523,6 @@ public final class LauncherInstrumentation {
}
/**
- * Gets the Base overview object if either Launcher is in overview state or the fallback
- * overview activity is showing. Fails otherwise.
- *
- * @return BaseOverview object.
- */
- @NonNull
- public BaseOverview getBaseOverview() {
- return new BaseOverview(this);
- }
-
- /**
* Gets the All Apps object if the current state is showing the all apps panel opened by swiping
* from workspace. Fails if the launcher is not in that state. Please don't call this method if
* App Apps was opened by swiping up from Overview, as it won't fail and will return an
@@ -617,6 +613,16 @@ public final class LauncherInstrumentation {
}
@NonNull
+ UiObject2 waitForLauncherObject(BySelector selector) {
+ return waitForObjectBySelector(selector.pkg(getLauncherPackageName()));
+ }
+
+ @NonNull
+ UiObject2 tryWaitForLauncherObject(BySelector selector, long timeout) {
+ return tryWaitForObjectBySelector(selector.pkg(getLauncherPackageName()), timeout);
+ }
+
+ @NonNull
UiObject2 waitForFallbackLauncherObject(String resName) {
return waitForObjectBySelector(getFallbackLauncherObjectSelector(resName));
}
@@ -627,6 +633,10 @@ public final class LauncherInstrumentation {
return object;
}
+ private UiObject2 tryWaitForObjectBySelector(BySelector selector, long timeout) {
+ return mDevice.wait(Until.findObject(selector), timeout);
+ }
+
BySelector getLauncherObjectSelector(String resName) {
return By.res(getLauncherPackageName(), resName);
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Widget.java b/tests/tapl/com/android/launcher3/tapl/Widget.java
new file mode 100644
index 000000000..128789dbc
--- /dev/null
+++ b/tests/tapl/com/android/launcher3/tapl/Widget.java
@@ -0,0 +1,24 @@
+/*
+ * 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.tapl;
+
+import androidx.test.uiautomator.UiObject2;
+
+public class Widget {
+ Widget(LauncherInstrumentation launcher, UiObject2 widget) {
+ }
+}
diff --git a/tests/tapl/com/android/launcher3/tapl/WidgetCell.java b/tests/tapl/com/android/launcher3/tapl/WidgetCell.java
new file mode 100644
index 000000000..adb69ec5b
--- /dev/null
+++ b/tests/tapl/com/android/launcher3/tapl/WidgetCell.java
@@ -0,0 +1,28 @@
+/*
+ * 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.tapl;
+
+import androidx.test.uiautomator.By;
+import androidx.test.uiautomator.UiObject2;
+
+public class WidgetCell {
+ WidgetCell(LauncherInstrumentation launcher) {
+ final UiObject2 widgetCell = launcher.waitForLauncherObject(By.clazz(
+ "com.android.launcher3.widget.WidgetCell"));
+ launcher.assertNotNull("Can't find widget cell object", widgetCell);
+ }
+}
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 62050b905..fc0a79329 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -27,6 +27,7 @@ import android.view.MotionEvent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.test.uiautomator.By;
import androidx.test.uiautomator.Direction;
import androidx.test.uiautomator.UiObject2;
@@ -215,4 +216,19 @@ public final class Workspace extends Home {
protected int getSwipeStartY() {
return mLauncher.getRealDisplaySize().y - 1;
}
+
+ @Nullable
+ public Widget tryGetWidget(String label, long timeout) {
+ final UiObject2 widget = mLauncher.tryWaitForLauncherObject(
+ By.clazz("com.android.launcher3.widget.LauncherAppWidgetHostView").desc(label),
+ timeout);
+ return widget != null ? new Widget(mLauncher, widget) : null;
+ }
+
+ @Nullable
+ public Widget tryGetPendingWidget(long timeout) {
+ final UiObject2 widget = mLauncher.tryWaitForLauncherObject(
+ By.clazz("com.android.launcher3.widget.PendingAppWidgetHostView"), timeout);
+ return widget != null ? new Widget(mLauncher, widget) : null;
+ }
} \ No newline at end of file