mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 05:35:39 +03:00
Screenshots with fastlane screengrab
This commit is contained in:
parent
ad6509bdb5
commit
36253ccec2
7 changed files with 196 additions and 0 deletions
|
@ -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 {
|
||||
|
|
2
fastlane/Appfile
Normal file
2
fastlane/Appfile
Normal file
|
@ -0,0 +1,2 @@
|
|||
json_key_file "~/.gradle/Google\ Play\ Android\ Developer-Fastlane.json"
|
||||
package_name "com.nextcloud.client"
|
71
fastlane/Fastfile
Normal file
71
fastlane/Fastfile
Normal file
|
@ -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
|
10
fastlane/Screengrabfile
Normal file
10
fastlane/Screengrabfile
Normal file
|
@ -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
|
|
@ -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<FileDisplayActivity> 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();
|
||||
}
|
||||
}
|
15
src/debug/AndroidManifest.xml
Normal file
15
src/debug/AndroidManifest.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Allows unlocking your device and activating its screen so UI tests can succeed -->
|
||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
|
||||
<!-- Allows for storing and retrieving screenshots -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
|
||||
<!-- Allows changing locales -->
|
||||
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
|
||||
|
||||
<application
|
||||
android:testOnly="false"/>
|
||||
</manifest>
|
Loading…
Reference in a new issue