diff options
author | cyberta <cyberta@riseup.net> | 2023-01-02 21:08:29 +0100 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2023-01-02 21:08:29 +0100 |
commit | e201e92acf17e3a71e2bffb73419fdd3726b0569 (patch) | |
tree | e2d794451129a9764075fb1750c8a3eee807a733 /app | |
parent | 256bf71832d266da62fdf8b3143308da00e7459b (diff) |
simple example setup for fastlane, doing some screenshots in different languages, including screenshots with phone frames for use in an app store
Diffstat (limited to 'app')
-rw-r--r-- | app/build.gradle | 19 | ||||
-rw-r--r-- | app/src/androidTest/java/base/ProviderSetupTest.java | 68 | ||||
-rw-r--r-- | app/src/debug/AndroidManifest.xml | 43 |
3 files changed, 123 insertions, 7 deletions
diff --git a/app/build.gradle b/app/build.gradle index 92120f88..359597a4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -276,12 +276,13 @@ android { applicationIdSuffix ".beta" appSuffix = " Beta" buildConfigField "Boolean", "DEBUG_MODE", "true" + testCoverageEnabled = false // tor-android doesn't know this build-type, fallback to release in that case matchingFallbacks = ['release'] } debug { - testCoverageEnabled = true + testCoverageEnabled = false buildConfigField "Boolean", "DEBUG_MODE", "true" } } @@ -410,13 +411,17 @@ dependencies { testImplementation 'org.powermock:powermock-module-junit4-rule:2.0.9' testImplementation group: 'com.tngtech.java', name: 'junit-dataprovider', version: '1.10.0' - androidTestImplementation 'org.mockito:mockito-core:3.6.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0' - androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0' - //TODO: remove that library - androidTestImplementation 'com.jayway.android.robotium:robotium-solo:5.6.3' + androidTestImplementation 'org.mockito:mockito-core:3.9.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' + androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.5.0' + androidTestImplementation 'androidx.test.espresso:espresso-intents:3.5.0' + + androidTestImplementation 'tools.fastlane:screengrab:2.1.1' + testImplementation 'tools.fastlane:screengrab:2.1.1' + + testImplementation 'org.json:json:20180813' + androidTestImplementation 'androidx.test.ext:junit:1.1.4' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1' annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' annotationProcessor 'com.squareup.dagger:dagger-compiler:1.2.2' diff --git a/app/src/androidTest/java/base/ProviderSetupTest.java b/app/src/androidTest/java/base/ProviderSetupTest.java new file mode 100644 index 00000000..fd46a093 --- /dev/null +++ b/app/src/androidTest/java/base/ProviderSetupTest.java @@ -0,0 +1,68 @@ +package base; + + +import static android.content.Context.MODE_PRIVATE; +import static androidx.test.core.app.ApplicationProvider.getApplicationContext; +import static androidx.test.espresso.Espresso.onData; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static org.hamcrest.Matchers.anything; + +import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES; + +import android.content.SharedPreferences; + +import androidx.test.ext.junit.rules.ActivityScenarioRule; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.LargeTest; + +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.Locale; + +import se.leap.bitmaskclient.R; +import se.leap.bitmaskclient.base.StartActivity; +import se.leap.bitmaskclient.base.utils.PreferenceHelper; +import se.leap.bitmaskclient.providersetup.ProviderListActivity; +import se.leap.bitmaskclient.providersetup.activities.ProviderSetupBaseActivity; +import se.leap.bitmaskclient.testutils.ForceLocaleRule; +import tools.fastlane.screengrab.Screengrab; +import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy; +import tools.fastlane.screengrab.locale.LocaleTestRule; + +@LargeTest +@RunWith(AndroidJUnit4.class) +public class ProviderSetupTest { + + @ClassRule + public static final LocaleTestRule localeTestRule = new LocaleTestRule(); + + @Rule + public ActivityScenarioRule<ProviderListActivity> mActivityScenarioRule = + new ActivityScenarioRule<>(ProviderListActivity.class); + + @Before + public void setup() { + Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy()); + SharedPreferences preferences = getApplicationContext().getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); + preferences.edit().clear().commit(); + } + + @Test + public void testConfigureRiseupVPNScreenshot() { + Screengrab.screenshot("configureRiseupVPN_before_button_click"); + onData(anything()).inAdapterView(withId(R.id.provider_list)).atPosition(2).perform(click()); + Screengrab.screenshot("configureRiseupVPN_after_button_click"); + } + + @Test + public void testaddManuallyNewProviderScreenshot() { + Screengrab.screenshot("addManuallyNewProvider_before_button_click"); + onData(anything()).inAdapterView(withId(R.id.provider_list)).atPosition(3).perform(click()); + Screengrab.screenshot("addManuallyNewProvider_after_button_click"); + } +} diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..51e17015 --- /dev/null +++ b/app/src/debug/AndroidManifest.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + package="se.leap.bitmaskclient" + android:requestLegacyExternalStorage="true" + > + <!-- package is overwritten in build.gradle --> + + <!-- The following permissions are required by fastlane / espresso --> + <!-- _____________________________________________________________ --> + <!-- 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" + tools:ignore="ScopedStorage" /> + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> + + <!-- Allows changing locales --> + <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" + tools:ignore="ProtectedPermissions" /> + + <uses-permission android:name="android.permission.DUMP" + tools:ignore="ProtectedPermissions" /> + <!-- _____________________________________________________________ --> + +</manifest> |