From 0152f16053905ac914e4bdcfdf77b34cd132738e Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Wed, 20 May 2020 10:56:49 -0300 Subject: [PATCH] Initial Android setup --- android/app/build.gradle | 3 +++ .../chat/rocket/reactnative/DetoxTest.java | 26 +++++++++++++++++++ .../main/res/xml/network_security_config.xml | 3 +++ android/build.gradle | 2 ++ package.json | 16 ++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 android/app/src/androidTest/java/chat/rocket/reactnative/DetoxTest.java diff --git a/android/app/build.gradle b/android/app/build.gradle index cacb3f5db..6d1637d85 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -143,6 +143,8 @@ android { vectorDrawables.useSupportLibrary = true manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String] missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60" // See note below! + testBuildType System.getProperty('testBuildType', 'debug') + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } signingConfigs { @@ -242,6 +244,7 @@ dependencies { implementation "com.google.code.gson:gson:2.8.5" implementation "com.github.bumptech.glide:glide:4.9.0" annotationProcessor "com.github.bumptech.glide:compiler:4.9.0" + androidTestImplementation('com.wix:detox:+') } // Run this once to be able to run the application with BUCK diff --git a/android/app/src/androidTest/java/chat/rocket/reactnative/DetoxTest.java b/android/app/src/androidTest/java/chat/rocket/reactnative/DetoxTest.java new file mode 100644 index 000000000..64fe213f7 --- /dev/null +++ b/android/app/src/androidTest/java/chat/rocket/reactnative/DetoxTest.java @@ -0,0 +1,26 @@ +package chat.rocket.reactnative; + +import com.wix.detox.Detox; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; + +@RunWith(AndroidJUnit4.class) +@LargeTest +public class DetoxTest { + + @Rule + // Replace 'MainActivity' with the value of android:name entry in + // in AndroidManifest.xml + public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); + + @Test + public void runDetoxTests() { + Detox.runTests(mActivityRule); + } +} \ No newline at end of file diff --git a/android/app/src/main/res/xml/network_security_config.xml b/android/app/src/main/res/xml/network_security_config.xml index bb6ab93df..5e32cfdae 100644 --- a/android/app/src/main/res/xml/network_security_config.xml +++ b/android/app/src/main/res/xml/network_security_config.xml @@ -6,4 +6,7 @@ + + 10.0.2.2 + \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index f1e95820c..058f85d63 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -45,6 +45,8 @@ allprojects { url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases" } + maven { url "$rootDir/../node_modules/detox/Detox-android" } + google() jcenter() diff --git a/package.json b/package.json index 8008e3867..0d517a629 100644 --- a/package.json +++ b/package.json @@ -189,6 +189,22 @@ "device": { "type": "iPhone 11 Pro" } + }, + "android.emu.debug": { + "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk", + "build": "cd android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug && cd ..", + "type": "android.emulator", + "device": { + "avdName": "Pixel_3_API_29" + } + }, + "android.emu.release": { + "binaryPath": "android/app/build/outputs/apk/release/app-release.apk", + "build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..", + "type": "android.emulator", + "device": { + "avdName": "Pixel_3_API_29" + } } } }