mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Make all tests pass on Android 6.0 (Marshmallow)
This commit is contained in:
@@ -34,7 +34,7 @@ public class WidgetTest extends BaseUserInterfaceTest
|
||||
@Test
|
||||
public void shouldCreateAndToggleCheckmarkWidget() throws Exception
|
||||
{
|
||||
dragCheckmarkWidgetToHomescreen();
|
||||
dragCheckmarkWidgetToHomeScreen();
|
||||
clickText("Wake up early");
|
||||
clickText("Save");
|
||||
verifyCheckmarkWidgetIsShown();
|
||||
|
||||
@@ -139,7 +139,7 @@ public class CommonSteps extends BaseUserInterfaceTest
|
||||
|
||||
public static void verifyOpensWebsite(String url) throws Exception
|
||||
{
|
||||
if(SDK_INT <= LOLLIPOP) {
|
||||
if(SDK_INT <= 23) {
|
||||
assertTrue(device.wait(Until.hasObject(By.pkg("com.android.browser")), 5000));
|
||||
} else {
|
||||
assertTrue(device.wait(Until.hasObject(By.pkg("com.android.chrome")), 5000));
|
||||
|
||||
@@ -21,78 +21,55 @@ package org.isoron.uhabits.acceptance.steps;
|
||||
|
||||
import android.support.test.uiautomator.*;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static junit.framework.Assert.*;
|
||||
import static org.isoron.uhabits.BaseUserInterfaceTest.*;
|
||||
|
||||
public class WidgetSteps
|
||||
{
|
||||
public static void clickCheckmarkWidget() throws Exception
|
||||
{
|
||||
device
|
||||
.findObject(
|
||||
new UiSelector().resourceId("org.isoron.uhabits:id/imageView"))
|
||||
.click();
|
||||
public class WidgetSteps {
|
||||
public static void clickCheckmarkWidget() throws Exception {
|
||||
String view_id = "org.isoron.uhabits:id/imageView";
|
||||
device.findObject(new UiSelector().resourceId(view_id)).click();
|
||||
}
|
||||
|
||||
public static void clickText(String s) throws Exception
|
||||
{
|
||||
public static void clickText(String s) throws Exception {
|
||||
device.findObject(new UiSelector().text(s)).click();
|
||||
}
|
||||
|
||||
public static void clickWidgets() throws Exception
|
||||
{
|
||||
device.findObject(new UiSelector().text("WIDGETS")).click();
|
||||
public static void dragCheckmarkWidgetToHomeScreen() throws Exception {
|
||||
openWidgetScreen();
|
||||
dragWidgetToHomeScreen();
|
||||
}
|
||||
|
||||
public static void dragWidgetToHomescreen() throws Exception
|
||||
{
|
||||
private static void dragWidgetToHomeScreen() throws Exception {
|
||||
int height = device.getDisplayHeight();
|
||||
int width = device.getDisplayWidth();
|
||||
device
|
||||
.findObject(new UiSelector().text("Checkmark"))
|
||||
device.findObject(new UiSelector().text("Checkmark"))
|
||||
.dragTo(width / 2, height / 2, 8);
|
||||
}
|
||||
|
||||
public static void longPressHomeScreen() throws Exception
|
||||
{
|
||||
device.pressHome();
|
||||
device.waitForIdle();
|
||||
device
|
||||
.findObject(new UiSelector().resourceId(
|
||||
"com.google.android.apps.nexuslauncher:id/workspace"))
|
||||
.longClick();
|
||||
}
|
||||
|
||||
public static void dragCheckmarkWidgetToHomescreen() throws Exception {
|
||||
int height = device.getDisplayHeight();
|
||||
int width = device.getDisplayWidth();
|
||||
private static void openWidgetScreen() throws Exception {
|
||||
int h = device.getDisplayHeight();
|
||||
int w = device.getDisplayWidth();
|
||||
if (SDK_INT <= 21) {
|
||||
device.pressHome();
|
||||
device.waitForIdle();
|
||||
device.findObject(new UiSelector().description("Apps")).click();
|
||||
device.findObject(new UiSelector().description("Apps")).click();
|
||||
device.findObject(new UiSelector().description("Widgets")).click();
|
||||
device.drag(width/2, height/2, 0, height/2, 8);
|
||||
device.findObject(new UiSelector().text("Checkmark"))
|
||||
.dragTo(width / 2, height / 2, 8);
|
||||
} else {
|
||||
String list_id = "com.android.launcher3:id/widgets_list_view";
|
||||
device.pressHome();
|
||||
device.waitForIdle();
|
||||
device.drag(w / 2, h / 2, w / 2, h / 2, 8);
|
||||
device.findObject(new UiSelector().text("Widgets")).click();
|
||||
new UiScrollable(new UiSelector().resourceId(list_id))
|
||||
.scrollIntoView(new UiSelector().text("Checkmark"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void scrollToHabits() throws Exception
|
||||
{
|
||||
new UiScrollable(new UiSelector().resourceId(
|
||||
"com.google.android.apps.nexuslauncher:id/widgets_list_view")).scrollIntoView(
|
||||
new UiSelector().text("Habits"));
|
||||
|
||||
}
|
||||
|
||||
public static void verifyCheckmarkWidgetIsShown() throws Exception
|
||||
{
|
||||
assertTrue(device
|
||||
.findObject(
|
||||
new UiSelector().resourceId("org.isoron.uhabits:id/imageView"))
|
||||
.exists());
|
||||
|
||||
assertFalse(device
|
||||
.findObject(new UiSelector().textStartsWith("Habit deleted"))
|
||||
.exists());
|
||||
public static void verifyCheckmarkWidgetIsShown() throws Exception {
|
||||
String view_id = "org.isoron.uhabits:id/imageView";
|
||||
assertTrue(device.findObject(new UiSelector().resourceId(view_id)).exists());
|
||||
assertFalse(device.findObject(new UiSelector().textStartsWith("Habit deleted")).exists());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user