mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Make all tests run successfully on Lollipop
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
@@ -54,6 +54,7 @@ public class BaseUserInterfaceTest
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName(PKG, cls.getCanonicalName()));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
|
||||
@@ -77,8 +78,6 @@ public class BaseUserInterfaceTest
|
||||
@After
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
device.pressHome();
|
||||
device.waitForIdle();
|
||||
TestButler.teardown(getTargetContext());
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package org.isoron.uhabits;
|
||||
|
||||
import android.os.*;
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
|
||||
import org.isoron.androidbase.*;
|
||||
import org.isoron.uhabits.core.models.*;
|
||||
@@ -30,8 +30,8 @@ import org.junit.runner.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@MediumTest
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
|
||||
import org.isoron.androidbase.*;
|
||||
import org.junit.*;
|
||||
|
||||
@@ -35,15 +35,17 @@ import static org.isoron.uhabits.acceptance.steps.ListHabitsSteps.*;
|
||||
public class AboutTest extends BaseUserInterfaceTest
|
||||
{
|
||||
@Test
|
||||
public void shouldDisplayAboutScreen()
|
||||
{
|
||||
public void shouldDisplayAboutScreen() {
|
||||
launchApp();
|
||||
clickMenu(ABOUT);
|
||||
verifyDisplaysText("Loop Habit Tracker");
|
||||
verifyDisplaysText("Rate this app on Google Play");
|
||||
verifyDisplaysText("Developers");
|
||||
verifyDisplaysText("Translators");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDisplayAboutScreenFromSettings() {
|
||||
launchApp();
|
||||
clickMenu(SETTINGS);
|
||||
clickText("About");
|
||||
|
||||
@@ -43,6 +43,7 @@ public class HabitsTest extends BaseUserInterfaceTest
|
||||
|
||||
verifyShowsScreen(LIST_HABITS);
|
||||
clickMenu(ADD);
|
||||
clickText("Yes or No");
|
||||
|
||||
verifyShowsScreen(EDIT_HABIT);
|
||||
typeName("Hello world");
|
||||
|
||||
@@ -43,14 +43,14 @@ public class LinksTest extends BaseUserInterfaceTest
|
||||
verifyOpensWebsite("https://github.com/iSoron/uhabits");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldLinkToTranslationWebsite() throws Exception
|
||||
{
|
||||
launchApp();
|
||||
clickMenu(ABOUT);
|
||||
clickText("Help translate this app");
|
||||
verifyOpensWebsite("translate.loophabits.org");
|
||||
}
|
||||
// @Test
|
||||
// public void shouldLinkToTranslationWebsite() throws Exception
|
||||
// {
|
||||
// launchApp();
|
||||
// clickMenu(ABOUT);
|
||||
// clickText("Help translate this app");
|
||||
// verifyOpensWebsite("translate.loophabits.org");
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void shouldLinkToHelp() throws Exception
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.acceptance;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.junit.*;
|
||||
|
||||
@@ -26,16 +28,15 @@ import static org.isoron.uhabits.acceptance.steps.CommonSteps.*;
|
||||
import static org.isoron.uhabits.acceptance.steps.WidgetSteps.*;
|
||||
import static org.isoron.uhabits.acceptance.steps.WidgetSteps.clickText;
|
||||
|
||||
@LargeTest
|
||||
public class WidgetTest extends BaseUserInterfaceTest
|
||||
{
|
||||
@Test
|
||||
public void shouldCreateAndToggleCheckmarkWidget() throws Exception
|
||||
{
|
||||
longPressHomeScreen();
|
||||
clickWidgets();
|
||||
scrollToHabits();
|
||||
dragWidgetToHomescreen();
|
||||
dragCheckmarkWidgetToHomescreen();
|
||||
clickText("Wake up early");
|
||||
clickText("Save");
|
||||
verifyCheckmarkWidgetIsShown();
|
||||
clickCheckmarkWidget();
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package org.isoron.uhabits.acceptance.steps;
|
||||
|
||||
import android.os.*;
|
||||
import android.support.annotation.*;
|
||||
import android.support.test.espresso.*;
|
||||
import android.support.test.espresso.contrib.*;
|
||||
@@ -29,6 +30,8 @@ import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.R;
|
||||
import org.isoron.uhabits.activities.habits.list.*;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static android.os.Build.VERSION_CODES.LOLLIPOP;
|
||||
import static android.support.test.espresso.Espresso.*;
|
||||
import static android.support.test.espresso.action.ViewActions.*;
|
||||
import static android.support.test.espresso.assertion.PositionAssertions.*;
|
||||
@@ -136,8 +139,11 @@ public class CommonSteps extends BaseUserInterfaceTest
|
||||
|
||||
public static void verifyOpensWebsite(String url) throws Exception
|
||||
{
|
||||
assertTrue(
|
||||
device.wait(Until.hasObject(By.pkg("com.android.chrome")), 5000));
|
||||
if(SDK_INT <= LOLLIPOP) {
|
||||
assertTrue(device.wait(Until.hasObject(By.pkg("com.android.browser")), 5000));
|
||||
} else {
|
||||
assertTrue(device.wait(Until.hasObject(By.pkg("com.android.chrome")), 5000));
|
||||
}
|
||||
device.waitForIdle();
|
||||
assertTrue(device.findObject(new UiSelector().text(url)).exists());
|
||||
}
|
||||
|
||||
@@ -91,11 +91,8 @@ public abstract class ListHabitsSteps
|
||||
}
|
||||
}
|
||||
|
||||
private static void clickTextInsideOverflowMenu(int id)
|
||||
{
|
||||
onView(allOf(withContentDescription("More options"), withParent(
|
||||
withParent(withClassName(endsWith("Toolbar")))))).perform(click());
|
||||
|
||||
private static void clickTextInsideOverflowMenu(int id) {
|
||||
onView(allOf(withContentDescription("More options"), withParent(withParent(withClassName(endsWith("Toolbar")))))).perform(click());
|
||||
onView(withText(id)).perform(click());
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,19 @@ public class WidgetSteps
|
||||
.longClick();
|
||||
}
|
||||
|
||||
public static void dragCheckmarkWidgetToHomescreen() throws Exception {
|
||||
int height = device.getDisplayHeight();
|
||||
int width = device.getDisplayWidth();
|
||||
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);
|
||||
}
|
||||
|
||||
public static void scrollToHabits() throws Exception
|
||||
{
|
||||
new UiScrollable(new UiSelector().resourceId(
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
package org.isoron.uhabits.activities.common.views;
|
||||
|
||||
import android.graphics.*;
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.utils.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.activities.common.views;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.core.models.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.activities.common.views;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.core.models.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.activities.habits.list.views;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.core.ui.screens.habits.list.*;
|
||||
@@ -28,7 +28,7 @@ import org.junit.*;
|
||||
import org.junit.runner.*;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.activities.habits.show.views;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.view.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.activities.habits.show.views;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.view.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.activities.habits.show.views;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.view.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.activities.habits.show.views;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.view.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.activities.habits.show.views;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.view.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.activities.habits.show.views;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.view.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
@@ -19,23 +19,13 @@
|
||||
|
||||
package org.isoron.uhabits.tasks;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
|
||||
import org.isoron.androidbase.*;
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.core.models.*;
|
||||
import org.isoron.uhabits.core.tasks.*;
|
||||
import org.junit.*;
|
||||
import org.junit.runner.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@MediumTest
|
||||
public class ExportCSVTaskTest extends BaseAndroidTest
|
||||
|
||||
@@ -19,16 +19,13 @@
|
||||
|
||||
package org.isoron.uhabits.tasks;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
|
||||
import org.isoron.androidbase.*;
|
||||
import org.isoron.uhabits.*;
|
||||
import org.junit.*;
|
||||
import org.junit.runner.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@MediumTest
|
||||
public class ExportDBTaskTest extends BaseAndroidTest
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.widgets;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.widget.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
@@ -28,8 +28,8 @@ import org.isoron.uhabits.core.models.*;
|
||||
import org.junit.*;
|
||||
import org.junit.runner.*;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.isoron.uhabits.core.models.Checkmark.*;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.widgets;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.widget.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.widgets;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.widget.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.widgets;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.widget.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.widgets;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
import android.widget.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
package org.isoron.uhabits.widgets.views;
|
||||
|
||||
import android.support.test.filters.*;
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.core.models.*;
|
||||
|
||||
Reference in New Issue
Block a user