Merge "include integration test for open settings menu from workspace" into ub-launcher3-master
This commit is contained in:
commit
108cc51e03
|
@ -47,7 +47,6 @@ import com.android.launcher3.widget.WidgetsFullSheet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Popup shown on long pressing an empty space in launcher
|
* Popup shown on long pressing an empty space in launcher
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,6 +18,9 @@ package com.android.launcher3.ui;
|
||||||
|
|
||||||
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
import static androidx.test.InstrumentationRegistry.getInstrumentation;
|
||||||
|
|
||||||
|
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
||||||
|
import static com.android.launcher3.util.rule.TestStabilityRule.UNBUNDLED_POSTSUBMIT;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
@ -36,6 +39,7 @@ import com.android.launcher3.tapl.AppIconMenu;
|
||||||
import com.android.launcher3.tapl.AppIconMenuItem;
|
import com.android.launcher3.tapl.AppIconMenuItem;
|
||||||
import com.android.launcher3.tapl.Widgets;
|
import com.android.launcher3.tapl.Widgets;
|
||||||
import com.android.launcher3.tapl.Workspace;
|
import com.android.launcher3.tapl.Workspace;
|
||||||
|
import com.android.launcher3.util.rule.TestStabilityRule.Stability;
|
||||||
import com.android.launcher3.views.OptionsPopupView;
|
import com.android.launcher3.views.OptionsPopupView;
|
||||||
import com.android.launcher3.widget.WidgetsFullSheet;
|
import com.android.launcher3.widget.WidgetsFullSheet;
|
||||||
import com.android.launcher3.widget.WidgetsRecyclerView;
|
import com.android.launcher3.widget.WidgetsRecyclerView;
|
||||||
|
@ -100,6 +104,16 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
|
||||||
mLauncher.pressHome();
|
mLauncher.pressHome();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// b/146432215: remove @Stability after 1/1/2020 if this test doesn't flake
|
||||||
|
@Test
|
||||||
|
@Stability(flavors = LOCAL | UNBUNDLED_POSTSUBMIT)
|
||||||
|
public void testOpenHomeSettingsFromWorkspace() {
|
||||||
|
mDevice.pressMenu();
|
||||||
|
mDevice.waitForIdle();
|
||||||
|
mLauncher.getWorkspace().getMenu().getMenuItem("Home settings").launch(
|
||||||
|
"com.google.android.apps.nexuslauncher");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void testPressHomeOnAllAppsContextMenu() throws Exception {
|
public void testPressHomeOnAllAppsContextMenu() throws Exception {
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
|
|
||||||
package com.android.launcher3.tapl;
|
package com.android.launcher3.tapl;
|
||||||
|
|
||||||
import android.graphics.Point;
|
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.test.uiautomator.By;
|
import androidx.test.uiautomator.By;
|
||||||
|
@ -41,14 +38,8 @@ public final class AppIcon extends Launchable {
|
||||||
* Long-clicks the icon to open its menu.
|
* Long-clicks the icon to open its menu.
|
||||||
*/
|
*/
|
||||||
public AppIconMenu openMenu() {
|
public AppIconMenu openMenu() {
|
||||||
final Point iconCenter = mObject.getVisibleCenter();
|
return new AppIconMenu(mLauncher, mLauncher.clickAndGet(
|
||||||
final long downTime = SystemClock.uptimeMillis();
|
mObject, "deep_shortcuts_container"));
|
||||||
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, iconCenter);
|
|
||||||
final UiObject2 deepShortcutsContainer = mLauncher.waitForLauncherObject(
|
|
||||||
"deep_shortcuts_container");
|
|
||||||
mLauncher.sendPointer(
|
|
||||||
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, iconCenter);
|
|
||||||
return new AppIconMenu(mLauncher, deepShortcutsContainer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -989,6 +989,16 @@ public final class LauncherInstrumentation {
|
||||||
return getSystemIntegerRes(context, "config_navBarInteractionMode");
|
return getSystemIntegerRes(context, "config_navBarInteractionMode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public UiObject2 clickAndGet(@NonNull final UiObject2 target, @NonNull String resName) {
|
||||||
|
final Point targetCenter = target.getVisibleCenter();
|
||||||
|
final long downTime = SystemClock.uptimeMillis();
|
||||||
|
sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, targetCenter);
|
||||||
|
final UiObject2 result = waitForLauncherObject(resName);
|
||||||
|
sendPointer(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, targetCenter);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private static int getSystemIntegerRes(Context context, String resName) {
|
private static int getSystemIntegerRes(Context context, String resName) {
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
int resId = res.getIdentifier(resName, "integer", "android");
|
int resId = res.getIdentifier(resName, "integer", "android");
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* 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.annotation.NonNull;
|
||||||
|
import androidx.test.uiautomator.UiObject2;
|
||||||
|
|
||||||
|
public class OptionsPopupMenu {
|
||||||
|
|
||||||
|
private final LauncherInstrumentation mLauncher;
|
||||||
|
private final UiObject2 mDeepShortcutsContainer;
|
||||||
|
|
||||||
|
OptionsPopupMenu(LauncherInstrumentation launcher,
|
||||||
|
UiObject2 deepShortcutsContainer) {
|
||||||
|
mLauncher = launcher;
|
||||||
|
mDeepShortcutsContainer = deepShortcutsContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a menu item with a given label. Fails if it doesn't exist.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public OptionsPopupMenuItem getMenuItem(@NonNull final String label) {
|
||||||
|
final UiObject2 obj = mLauncher
|
||||||
|
.getObjectsInContainer(mDeepShortcutsContainer, "bubble_text").stream()
|
||||||
|
.filter(menuItem -> label.equals(menuItem.getText())).findFirst().orElseThrow(() ->
|
||||||
|
new IllegalStateException("Cannot find option with label: " + label));
|
||||||
|
return new OptionsPopupMenuItem(mLauncher, obj);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* 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.annotation.NonNull;
|
||||||
|
import androidx.test.uiautomator.By;
|
||||||
|
import androidx.test.uiautomator.UiObject2;
|
||||||
|
import androidx.test.uiautomator.Until;
|
||||||
|
|
||||||
|
public class OptionsPopupMenuItem {
|
||||||
|
|
||||||
|
private final LauncherInstrumentation mLauncher;
|
||||||
|
private final UiObject2 mObject;
|
||||||
|
|
||||||
|
OptionsPopupMenuItem(@NonNull LauncherInstrumentation launcher, @NonNull UiObject2 shortcut) {
|
||||||
|
mLauncher = launcher;
|
||||||
|
mObject = shortcut;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clicks the option.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public void launch(@NonNull String expectedPackageName) {
|
||||||
|
LauncherInstrumentation.log("OptionsPopupMenuItem before click "
|
||||||
|
+ mObject.getVisibleCenter() + " in " + mObject.getVisibleBounds());
|
||||||
|
mObject.click();
|
||||||
|
mLauncher.assertTrue(
|
||||||
|
"App didn't start: " + By.pkg(expectedPackageName),
|
||||||
|
mLauncher.getDevice().wait(Until.hasObject(By.pkg(expectedPackageName)),
|
||||||
|
LauncherInstrumentation.WAIT_TIME_MS));
|
||||||
|
}
|
||||||
|
}
|
|
@ -276,4 +276,15 @@ public final class Workspace extends Home {
|
||||||
By.clazz("com.android.launcher3.widget.PendingAppWidgetHostView"), timeout);
|
By.clazz("com.android.launcher3.widget.PendingAppWidgetHostView"), timeout);
|
||||||
return widget != null ? new Widget(mLauncher, widget) : null;
|
return widget != null ? new Widget(mLauncher, widget) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Long-clicks the workspace to open menu.
|
||||||
|
*/
|
||||||
|
public OptionsPopupMenu getMenu() {
|
||||||
|
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||||
|
"want to open menu from workspace")) {
|
||||||
|
return new OptionsPopupMenu(mLauncher, mLauncher.waitForLauncherObject(
|
||||||
|
"deep_shortcuts_container"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue