From ebdd4207ed1f8437ca9ac06c57cd894bbc025401 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Wed, 23 May 2018 08:57:14 +0200 Subject: [PATCH] move disabled tests to its own package Signed-off-by: tobiasKaminsky --- .../screenshots/ScreenshotsIT.java | 131 ++++++++++++++++++ .../uiautomator/InitialTest.java | 78 +++++------ .../android/screenshots/ScreenshotsIT.java | 131 ------------------ 3 files changed, 170 insertions(+), 170 deletions(-) create mode 100644 src/androidTest/disabledTests/screenshots/ScreenshotsIT.java rename src/androidTest/{java/com/owncloud/android => disabledTests}/uiautomator/InitialTest.java (67%) delete mode 100644 src/androidTest/java/com/owncloud/android/screenshots/ScreenshotsIT.java diff --git a/src/androidTest/disabledTests/screenshots/ScreenshotsIT.java b/src/androidTest/disabledTests/screenshots/ScreenshotsIT.java new file mode 100644 index 0000000000..d819c9dea3 --- /dev/null +++ b/src/androidTest/disabledTests/screenshots/ScreenshotsIT.java @@ -0,0 +1,131 @@ +package com.owncloud.android.screenshots; + +import android.content.Intent; +import android.support.test.espresso.Espresso; +import android.support.test.espresso.action.ViewActions; +import android.support.test.espresso.contrib.DrawerActions; +import android.support.test.espresso.matcher.PreferenceMatchers; +import android.support.test.rule.ActivityTestRule; + +import com.owncloud.android.R; +import com.owncloud.android.ui.activity.FileDisplayActivity; +import com.owncloud.android.ui.activity.Preferences; + +import junit.framework.Assert; + +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import tools.fastlane.screengrab.Screengrab; +import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy; +import tools.fastlane.screengrab.locale.LocaleTestRule; + +import static android.support.test.espresso.Espresso.onData; +import static android.support.test.espresso.Espresso.onView; +import static android.support.test.espresso.action.ViewActions.click; +import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static org.hamcrest.Matchers.anything; +import static org.hamcrest.core.AnyOf.anyOf; + +@RunWith(JUnit4.class) +public class ScreenshotsIT { + @ClassRule + public static final LocaleTestRule localeTestRule = new LocaleTestRule(); + + @Rule + public ActivityTestRule fileDisplayRule = new ActivityTestRule<>(FileDisplayActivity.class); + + @Rule + public ActivityTestRule preferencesRule = new ActivityTestRule<>(Preferences.class, true, false); + + @BeforeClass + public static void beforeAll() { + Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy()); + } + + @Test + public void gridViewScreenshot() throws InterruptedException { + fileDisplayRule.launchActivity(new Intent()); + + Espresso.openContextualActionModeOverflowMenu(); + onView(anyOf(withText(R.string.action_switch_grid_view), withId(R.id.action_switch_view))).perform(click()); + + Thread.sleep(1000); + + Screengrab.screenshot("01_gridView"); + + Espresso.openContextualActionModeOverflowMenu(); + onView(anyOf(withText(R.string.action_switch_list_view), withId(R.id.action_switch_view))).perform(click()); + + Assert.assertTrue(true); // if we reach this, everything is ok + } + + @Test + public void listViewScreenshot() throws InterruptedException { + fileDisplayRule.launchActivity(new Intent()); + + // go into work folder + onData(anything()).inAdapterView(withId(R.id.list_root)).atPosition(0).perform(click()); + + Screengrab.screenshot("02_listView"); + + Assert.assertTrue(true); // if we reach this, everything is ok + } + + @Test + public void drawerScreenshot() throws InterruptedException { + fileDisplayRule.launchActivity(new Intent()); + + onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); + + Screengrab.screenshot("03_drawer"); + + onView(withId(R.id.drawer_layout)).perform(DrawerActions.close()); + + Assert.assertTrue(true); // if we reach this, everything is ok + } + + @Test + public void multipleAccountsScreenshot() throws InterruptedException { + fileDisplayRule.launchActivity(new Intent()); + + onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); + onView(withId(R.id.drawer_active_user)).perform(click()); + + Screengrab.screenshot("04_accounts"); + + onView(withId(R.id.drawer_layout)).perform(DrawerActions.close()); + + Assert.assertTrue(true); // if we reach this, everything is ok + } + + @Test + public void autoUploadScreenshot() throws InterruptedException { + fileDisplayRule.launchActivity(new Intent()); + + onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); + onView(anyOf(withText(R.string.drawer_synced_folders), withId(R.id.nav_synced_folders))).perform(click()); + + Screengrab.screenshot("05_autoUpload"); + + Assert.assertTrue(true); // if we reach this, everything is ok + } + + @Test + public void davdroidScreenshot() throws InterruptedException { + preferencesRule.launchActivity(new Intent()); + + onData(PreferenceMatchers.withTitle(R.string.prefs_category_more)).perform(ViewActions.scrollTo()); + + Thread.sleep(1000); + + Screengrab.screenshot("06_davdroid"); + + Assert.assertTrue(true); // if we reach this, everything is ok + } +} diff --git a/src/androidTest/java/com/owncloud/android/uiautomator/InitialTest.java b/src/androidTest/disabledTests/uiautomator/InitialTest.java similarity index 67% rename from src/androidTest/java/com/owncloud/android/uiautomator/InitialTest.java rename to src/androidTest/disabledTests/uiautomator/InitialTest.java index 3ff0e73d5b..adb83e4e5c 100644 --- a/src/androidTest/java/com/owncloud/android/uiautomator/InitialTest.java +++ b/src/androidTest/disabledTests/uiautomator/InitialTest.java @@ -65,51 +65,51 @@ public class InitialTest { /** * Start Nextcloud app */ -// @Test -// public void startAppFromHomeScreen() { -// // Perform a short press on the HOME button -// mDevice.pressHome(); -// -// // Wait for launcher -// final String launcherPackage = getLauncherPackageName(); -// assertThat(launcherPackage, notNullValue()); -// mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT); -// -// // Launch the app -// Context context = InstrumentationRegistry.getContext(); -// final Intent intent = context.getPackageManager() -// .getLaunchIntentForPackage(OWNCLOUD_APP_PACKAGE); -// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); -// context.startActivity(intent); -// -// // Wait for the app to appear -// mDevice.wait(Until.hasObject(By.pkg(OWNCLOUD_APP_PACKAGE).depth(0)), LAUNCH_TIMEOUT); -// } + @Test + public void startAppFromHomeScreen() { + // Perform a short press on the HOME button + mDevice.pressHome(); + + // Wait for launcher + final String launcherPackage = getLauncherPackageName(); + assertThat(launcherPackage, notNullValue()); + mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT); + + // Launch the app + Context context = InstrumentationRegistry.getContext(); + final Intent intent = context.getPackageManager() + .getLaunchIntentForPackage(OWNCLOUD_APP_PACKAGE); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); + context.startActivity(intent); + + // Wait for the app to appear + mDevice.wait(Until.hasObject(By.pkg(OWNCLOUD_APP_PACKAGE).depth(0)), LAUNCH_TIMEOUT); + } /** * Start Settings app * * @throws UiObjectNotFoundException */ -// @Test -// public void startSettingsFromHomeScreen() throws UiObjectNotFoundException { -// -// mDevice.pressHome(); -// -// // Wait for launcher -// final String launcherPackage = getLauncherPackageName(); -// assertThat(launcherPackage, notNullValue()); -// mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT); -// -// // Launch the app -// Context context = InstrumentationRegistry.getContext(); -// final Intent intent = context.getPackageManager() -// .getLaunchIntentForPackage(ANDROID_SETTINGS_PACKAGE); -// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); -// context.startActivity(intent); -// -// clickByText(SETTINGS_DATA_USAGE_OPTION); -// } + @Test + public void startSettingsFromHomeScreen() throws UiObjectNotFoundException { + + mDevice.pressHome(); + + // Wait for launcher + final String launcherPackage = getLauncherPackageName(); + assertThat(launcherPackage, notNullValue()); + mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT); + + // Launch the app + Context context = InstrumentationRegistry.getContext(); + final Intent intent = context.getPackageManager() + .getLaunchIntentForPackage(ANDROID_SETTINGS_PACKAGE); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); + context.startActivity(intent); + + clickByText(SETTINGS_DATA_USAGE_OPTION); + } /** * Uses package manager to find the package name of the device launcher. Usually this package diff --git a/src/androidTest/java/com/owncloud/android/screenshots/ScreenshotsIT.java b/src/androidTest/java/com/owncloud/android/screenshots/ScreenshotsIT.java deleted file mode 100644 index 3a8d322c7d..0000000000 --- a/src/androidTest/java/com/owncloud/android/screenshots/ScreenshotsIT.java +++ /dev/null @@ -1,131 +0,0 @@ -//package com.owncloud.android.screenshots; -// -//import android.content.Intent; -//import android.support.test.espresso.Espresso; -//import android.support.test.espresso.action.ViewActions; -//import android.support.test.espresso.contrib.DrawerActions; -//import android.support.test.espresso.matcher.PreferenceMatchers; -//import android.support.test.rule.ActivityTestRule; -// -//import com.owncloud.android.R; -//import com.owncloud.android.ui.activity.FileDisplayActivity; -//import com.owncloud.android.ui.activity.Preferences; -// -//import junit.framework.Assert; -// -//import org.junit.BeforeClass; -//import org.junit.ClassRule; -//import org.junit.Rule; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.junit.runners.JUnit4; -// -//import tools.fastlane.screengrab.Screengrab; -//import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy; -//import tools.fastlane.screengrab.locale.LocaleTestRule; -// -//import static android.support.test.espresso.Espresso.onData; -//import static android.support.test.espresso.Espresso.onView; -//import static android.support.test.espresso.action.ViewActions.click; -//import static android.support.test.espresso.matcher.ViewMatchers.withId; -//import static android.support.test.espresso.matcher.ViewMatchers.withText; -//import static org.hamcrest.Matchers.anything; -//import static org.hamcrest.core.AnyOf.anyOf; -// -//@RunWith(JUnit4.class) -//public class ScreenshotsIT { -// @ClassRule -// public static final LocaleTestRule localeTestRule = new LocaleTestRule(); -// -// @Rule -// public ActivityTestRule fileDisplayRule = new ActivityTestRule<>(FileDisplayActivity.class); -// -// @Rule -// public ActivityTestRule preferencesRule = new ActivityTestRule<>(Preferences.class, true, false); -// -// @BeforeClass -// public static void beforeAll() { -// Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy()); -// } -// -// @Test -// public void gridViewScreenshot() throws InterruptedException { -// fileDisplayRule.launchActivity(new Intent()); -// -// Espresso.openContextualActionModeOverflowMenu(); -// onView(anyOf(withText(R.string.action_switch_grid_view), withId(R.id.action_switch_view))).perform(click()); -// -// Thread.sleep(1000); -// -// Screengrab.screenshot("01_gridView"); -// -// Espresso.openContextualActionModeOverflowMenu(); -// onView(anyOf(withText(R.string.action_switch_list_view), withId(R.id.action_switch_view))).perform(click()); -// -// Assert.assertTrue(true); // if we reach this, everything is ok -// } -// -// @Test -// public void listViewScreenshot() throws InterruptedException { -// fileDisplayRule.launchActivity(new Intent()); -// -// // go into work folder -// onData(anything()).inAdapterView(withId(R.id.list_root)).atPosition(0).perform(click()); -// -// Screengrab.screenshot("02_listView"); -// -// Assert.assertTrue(true); // if we reach this, everything is ok -// } -// -// @Test -// public void drawerScreenshot() throws InterruptedException { -// fileDisplayRule.launchActivity(new Intent()); -// -// onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); -// -// Screengrab.screenshot("03_drawer"); -// -// onView(withId(R.id.drawer_layout)).perform(DrawerActions.close()); -// -// Assert.assertTrue(true); // if we reach this, everything is ok -// } -// -// @Test -// public void multipleAccountsScreenshot() throws InterruptedException { -// fileDisplayRule.launchActivity(new Intent()); -// -// onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); -// onView(withId(R.id.drawer_active_user)).perform(click()); -// -// Screengrab.screenshot("04_accounts"); -// -// onView(withId(R.id.drawer_layout)).perform(DrawerActions.close()); -// -// Assert.assertTrue(true); // if we reach this, everything is ok -// } -// -// @Test -// public void autoUploadScreenshot() throws InterruptedException { -// fileDisplayRule.launchActivity(new Intent()); -// -// onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); -// onView(anyOf(withText(R.string.drawer_synced_folders), withId(R.id.nav_synced_folders))).perform(click()); -// -// Screengrab.screenshot("05_autoUpload"); -// -// Assert.assertTrue(true); // if we reach this, everything is ok -// } -// -// @Test -// public void davdroidScreenshot() throws InterruptedException { -// preferencesRule.launchActivity(new Intent()); -// -// onData(PreferenceMatchers.withTitle(R.string.prefs_category_more)).perform(ViewActions.scrollTo()); -// -// Thread.sleep(1000); -// -// Screengrab.screenshot("06_davdroid"); -// -// Assert.assertTrue(true); // if we reach this, everything is ok -// } -//}