diff --git a/build.gradle b/build.gradle index 9f2c0cacdd..e6836d4ac6 100644 --- a/build.gradle +++ b/build.gradle @@ -231,11 +231,14 @@ dependencies { // Espresso core androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.1' // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests //androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details //androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}" implementation 'org.jetbrains:annotations:15.0' + + androidTestCompile 'tools.fastlane:screengrab:1.0.0' } configurations.all { diff --git a/fastlane/Appfile b/fastlane/Appfile new file mode 100644 index 0000000000..64725e1fde --- /dev/null +++ b/fastlane/Appfile @@ -0,0 +1,2 @@ +json_key_file "~/.gradle/Google\ Play\ Android\ Developer-Fastlane.json" +package_name "com.nextcloud.client" diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 0000000000..2bf3eb14ec --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,71 @@ +# Customise this file, documentation can be found here: +# https://github.com/fastlane/fastlane/tree/master/fastlane/docs +# All available actions: https://docs.fastlane.tools/actions +# can also be listed using the `fastlane actions` command + +# Change the syntax highlighting to Ruby +# All lines starting with a # are ignored when running `fastlane` + +# If you want to automatically update fastlane if a new version is available: +# update_fastlane + +# This is the minimum version number required. +# Update this, if you use features of a newer version +fastlane_version "2.58.0" + +default_platform :android + +platform :android do + before_all do + # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..." + end + + desc "Runs all the tests" + lane :test do + gradle(task: "test") + end + + desc "Submit a new Beta Build to Crashlytics Beta" + lane :beta do + gradle(task: "assembleRelease") + crashlytics + + # sh "your_script.sh" + # You can also use other beta testing services here + end + + desc "Deploy a new version to the Google Play" + lane :deploy do + gradle(task: "assembleRelease") + supply + end + + # You can define as many lanes as you want + + after_all do |lane| + # This block is called, only if the executed lane was successful + + # slack( + # message: "Successfully deployed new App Update." + # ) + end + + error do |lane, exception| + # slack( + # message: exception.message, + # success: false + # ) + end +end + +lane :screenshots do + screengrab + # supply +end + + +# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md +# All available actions: https://docs.fastlane.tools/actions + +# fastlane reports which actions are used. No personal data is recorded. +# Learn more at https://github.com/fastlane/fastlane#metrics diff --git a/fastlane/Screengrabfile b/fastlane/Screengrabfile new file mode 100644 index 0000000000..ddb6186835 --- /dev/null +++ b/fastlane/Screengrabfile @@ -0,0 +1,10 @@ +app_package_name 'com.nextcloud.client' +use_tests_in_packages ['com.owncloud.android.screenshots'] + +app_apk_path 'build/outputs/apk/generic/debug/android-generic-debug.apk' +tests_apk_path 'build/outputs/apk/generic/debug/android-generic-debug.apk' + +locales ['en-US', 'de-DE', 'en-GB', 'fr-FR', 'it-IT', 'pt-BR', 'pt-PT', 'sv-SE', 'sq-AL', 'sq-MK', 'iw-IL', 'ar-AR', 'bg-BG', 'da-DK', 'fi-FI', 'gl-ES', 'hu-HU', 'tr-TR', 'uk-UK', 'vi-VI', 'ro-RO', 'ru-RU', 'sr-SR', 'pl-PL', 'el-GR', 'ko-KR', 'nl-NL', 'ja-JP', 'no-NO', 'eu-ES', 'lt-LT', 'es-ES', 'es-419', 'zh-HK', 'zk-CN', 'is-IS', 'sr-SR', 'id-ID', 'cs-CZ', 'sl-SL', 'fa-FA' ] + +# clear all previously generated screenshots in your local output directory before creating new ones +clear_previous_screenshots true \ No newline at end of file diff --git a/androidTest/AndroidManifest.xml b/src/androidTest/AndroidManifest.xml similarity index 100% rename from androidTest/AndroidManifest.xml rename to src/androidTest/AndroidManifest.xml diff --git a/src/androidTest/java/com/owncloud/android/screenshots/ScreenshotsIT.java b/src/androidTest/java/com/owncloud/android/screenshots/ScreenshotsIT.java new file mode 100644 index 0000000000..5e3aac4b82 --- /dev/null +++ b/src/androidTest/java/com/owncloud/android/screenshots/ScreenshotsIT.java @@ -0,0 +1,95 @@ +package com.owncloud.android.screenshots; + +import android.support.test.espresso.Espresso; +import android.support.test.espresso.contrib.DrawerActions; +import android.support.test.rule.ActivityTestRule; + +import com.owncloud.android.R; +import com.owncloud.android.ui.activity.FileDisplayActivity; + +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); + + @BeforeClass + public static void beforeAll() { + Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy()); + } + + @Test + public void gridViewScreenshot() throws InterruptedException { + Espresso.openContextualActionModeOverflowMenu(); + onView(anyOf(withText(R.string.action_switch_grid_view), withId(R.id.action_switch_view))).perform(click()); + + Screengrab.screenshot("01_grid_view"); + + Espresso.openContextualActionModeOverflowMenu(); + onView(anyOf(withText(R.string.action_switch_list_view), withId(R.id.action_switch_view))).perform(click()); + } + + @Test + public void listViewScreenshot() throws InterruptedException { + // go into work folder + onData(anything()).inAdapterView(withId(R.id.list_root)).atPosition(0).perform(click()); + + Screengrab.screenshot("02_list_view"); + + Espresso.pressBack(); + } + + @Test + public void drawerScreenshot() throws InterruptedException { + + onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); + + Screengrab.screenshot("03_drawer"); + + onView(withId(R.id.drawer_layout)).perform(DrawerActions.close()); + + } + + @Test + public void multipleAccountsScreenshot() throws InterruptedException { + + 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()); + } + + @Test + public void autoUploadScreenshot() throws InterruptedException { + + 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_auto_upload"); + + Espresso.pressBack(); + } +} \ No newline at end of file diff --git a/src/debug/AndroidManifest.xml b/src/debug/AndroidManifest.xml new file mode 100644 index 0000000000..5976b7fa26 --- /dev/null +++ b/src/debug/AndroidManifest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file