mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 23:36:47 +00:00
Reenabling some widget tests am: 599b1fc4d3
am: 9c524db4c8
Change-Id: I51e3f50bb7f923894250a8fd0643e630b60e1380
This commit is contained in:
@@ -70,14 +70,12 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
@Ignore
|
||||
public void testWidgetConfig() throws Throwable {
|
||||
runTest(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
@Ignore
|
||||
public void testConfigCancelled() throws Throwable {
|
||||
runTest(false);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ public class AddWidgetTest extends AbstractLauncherUiTest {
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
@Ignore
|
||||
public void testDragIcon() throws Throwable {
|
||||
clearHomescreen();
|
||||
mDevice.pressHome();
|
||||
|
||||
@@ -368,7 +368,7 @@ public final class LauncherInstrumentation {
|
||||
}
|
||||
}
|
||||
|
||||
private void assertEquals(String message, String expected, String actual) {
|
||||
void assertEquals(String message, String expected, String actual) {
|
||||
if (!TextUtils.equals(expected, actual)) {
|
||||
fail(message + " expected: '" + expected + "' but was: '" + actual + "'");
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
|
||||
return LauncherInstrumentation.ContainerType.WIDGETS;
|
||||
}
|
||||
|
||||
public Widget getWidget(String label) {
|
||||
public Widget getWidget(String labelText) {
|
||||
final int margin = ResourceUtils.getNavbarSize(
|
||||
ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1;
|
||||
final UiObject2 widgetsContainer = verifyActiveContainer();
|
||||
@@ -86,17 +86,24 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
|
||||
final Point displaySize = mLauncher.getRealDisplaySize();
|
||||
|
||||
int i = 0;
|
||||
final BySelector selector = By.
|
||||
clazz("com.android.launcher3.widget.WidgetCell").
|
||||
hasDescendant(By.text(label));
|
||||
final BySelector selector = By.clazz("android.widget.TextView").text(labelText);
|
||||
|
||||
for (; ; ) {
|
||||
final UiObject2 widget = mLauncher.tryWaitForLauncherObject(selector, 300);
|
||||
if (widget != null && widget.getVisibleBounds().bottom <= displaySize.y - margin) {
|
||||
return new Widget(mLauncher, widget);
|
||||
final UiObject2 label = mLauncher.tryWaitForLauncherObject(selector, 300);
|
||||
if (label != null) {
|
||||
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) {
|
||||
return new Widget(mLauncher, widget);
|
||||
}
|
||||
}
|
||||
|
||||
if (++i > 40) fail("Too many attempts");
|
||||
mLauncher.scroll(widgetsContainer, Direction.DOWN, 1f, MARGINS, 50);
|
||||
mLauncher.scroll(widgetsContainer, Direction.DOWN, 0.8f, MARGINS, 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user