From 566198a54e68e253132d8e33675a67865e303d55 Mon Sep 17 00:00:00 2001 From: devfd Date: Fri, 15 Jul 2016 06:51:27 +0200 Subject: [PATCH] update e2e app setup --- e2e/android/app/build.gradle | 139 ------------------ .../java/com/geocodere2eapp/MainActivity.java | 43 ------ e2e/android/build.gradle | 36 ----- e2e/android/settings.gradle | 5 - e2e/js/index.android.js | 4 +- e2e/prepare.sh | 4 +- e2e/run.sh | 7 +- 7 files changed, 11 insertions(+), 227 deletions(-) delete mode 100644 e2e/android/app/build.gradle delete mode 100644 e2e/android/app/src/main/java/com/geocodere2eapp/MainActivity.java delete mode 100644 e2e/android/build.gradle delete mode 100644 e2e/android/settings.gradle diff --git a/e2e/android/app/build.gradle b/e2e/android/app/build.gradle deleted file mode 100644 index 536223e..0000000 --- a/e2e/android/app/build.gradle +++ /dev/null @@ -1,139 +0,0 @@ -apply plugin: "com.android.application" - -import com.android.build.OutputFile - -/** - * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets - * and bundleReleaseJsAndAssets). - * These basically call `react-native bundle` with the correct arguments during the Android build - * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the - * bundle directly from the development server. Below you can see all the possible configurations - * and their defaults. If you decide to add a configuration block, make sure to add it before the - * `apply from: "../../node_modules/react-native/react.gradle"` line. - * - * project.ext.react = [ - * // the name of the generated asset file containing your JS bundle - * bundleAssetName: "index.android.bundle", - * - * // the entry file for bundle generation - * entryFile: "index.android.js", - * - * // whether to bundle JS and assets in debug mode - * bundleInDebug: false, - * - * // whether to bundle JS and assets in release mode - * bundleInRelease: true, - * - * // whether to bundle JS and assets in another build variant (if configured). - * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants - * // The configuration property can be in the following formats - * // 'bundleIn${productFlavor}${buildType}' - * // 'bundleIn${buildType}' - * // bundleInFreeDebug: true, - * // bundleInPaidRelease: true, - * // bundleInBeta: true, - * - * // the root of your project, i.e. where "package.json" lives - * root: "../../", - * - * // where to put the JS bundle asset in debug mode - * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", - * - * // where to put the JS bundle asset in release mode - * jsBundleDirRelease: "$buildDir/intermediates/assets/release", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in debug mode - * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in release mode - * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", - * - * // by default the gradle tasks are skipped if none of the JS files or assets change; this means - * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to - * // date; if you have any other folders that you want to ignore for performance reasons (gradle - * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ - * // for example, you might want to remove it from here. - * inputExcludes: ["android/**", "ios/**"] - * ] - */ - -project.ext.react = [ - bundleInDebug: true -] - - -apply from: "../../node_modules/react-native/react.gradle" - -/** - * Set this to true to create two separate APKs instead of one: - * - An APK that only works on ARM devices - * - An APK that only works on x86 devices - * The advantage is the size of the APK is reduced by about 4MB. - * Upload all the APKs to the Play Store and people will download - * the correct one based on the CPU architecture of their device. - */ -def enableSeparateBuildPerCPUArchitecture = false - -/** - * Run Proguard to shrink the Java bytecode in release builds. - */ -def enableProguardInReleaseBuilds = false - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" - - defaultConfig { - applicationId "com.geocodere2etests" - minSdkVersion 16 - targetSdkVersion 22 - versionCode 1 - versionName "1.0" - ndk { - abiFilters "armeabi-v7a", "x86" - } - } - splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86" - } - } - buildTypes { - release { - minifyEnabled enableProguardInReleaseBuilds - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - } - } - // applicationVariants are e.g. debug, release - applicationVariants.all { variant -> - variant.outputs.each { output -> - // For each separate APK per architecture, set a unique version code as described here: - // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits - def versionCodes = ["armeabi-v7a":1, "x86":2] - def abi = output.getFilter(OutputFile.ABI) - if (abi != null) { // null for the universal-debug, universal-release variants - output.versionCodeOverride = - versionCodes.get(abi) * 1048576 + defaultConfig.versionCode - } - } - } -} - -dependencies { - compile fileTree(dir: "libs", include: ["*.jar"]) - compile "com.android.support:appcompat-v7:23.0.1" - compile "com.facebook.react:react-native:+" // From node_modules - compile project(':react-native-geocoder') -} - -// Run this once to be able to run the application with BUCK -// puts all compile dependencies into folder libs for BUCK to use -task copyDownloadableDepsToLibs(type: Copy) { - from configurations.compile - into 'libs' -} diff --git a/e2e/android/app/src/main/java/com/geocodere2eapp/MainActivity.java b/e2e/android/app/src/main/java/com/geocodere2eapp/MainActivity.java deleted file mode 100644 index e43168d..0000000 --- a/e2e/android/app/src/main/java/com/geocodere2eapp/MainActivity.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.geocodere2eapp; - -import com.facebook.react.ReactActivity; -import com.facebook.react.ReactPackage; -import com.facebook.react.shell.MainReactPackage; - -import java.util.Arrays; -import java.util.List; - -import com.devfd.RNGeocoder.RNGeocoderPackage; - -public class MainActivity extends ReactActivity { - - /** - * Returns the name of the main component registered from JavaScript. - * This is used to schedule rendering of the component. - */ - @Override - protected String getMainComponentName() { - return "GeocoderE2EApp"; - } - - /** - * Returns whether dev mode should be enabled. - * This enables e.g. the dev menu. - */ - @Override - protected boolean getUseDeveloperSupport() { - return false; - } - - /** - * A list of packages used by the app. If the app uses additional views - * or modules besides the default ones, add more packages here. - */ - @Override - protected List getPackages() { - return Arrays.asList( - new MainReactPackage(), - new RNGeocoderPackage() - ); - } -} diff --git a/e2e/android/build.gradle b/e2e/android/build.gradle deleted file mode 100644 index 06f671c..0000000 --- a/e2e/android/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:1.3.1' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - mavenLocal() - jcenter() - maven { - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - url "$projectDir/../../node_modules/react-native/android" - } - } -} - -project.ext.preDexLibs = !project.hasProperty('disablePreDex') - -subprojects { - project.plugins.whenPluginAdded { plugin -> - if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) { - project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs - } else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) { - project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs - } - } -} diff --git a/e2e/android/settings.gradle b/e2e/android/settings.gradle deleted file mode 100644 index cda5b47..0000000 --- a/e2e/android/settings.gradle +++ /dev/null @@ -1,5 +0,0 @@ -rootProject.name = 'GeocoderE2ETests' - -include ':app' -include ':react-native-geocoder' -project(':react-native-geocoder').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-geocoder/android') diff --git a/e2e/js/index.android.js b/e2e/js/index.android.js index 9dc477e..6732909 100644 --- a/e2e/js/index.android.js +++ b/e2e/js/index.android.js @@ -51,9 +51,11 @@ class GeocoderE2EApp extends Component { { this.refs.geoInput.blur(); + this.setState({result: null}); + const [lat, lng] = this.state.reverseInput.split(' '); - Geocoder.reverseGeocodeLocation({latitude: 1 * lat, longitude: 1 * lng}).then((res) => { + Geocoder.geocodePosition({lat: 1 * lat, lng: 1 * lng}).then((res) => { this.setState({ result: res[0] }); }); }}> diff --git a/e2e/prepare.sh b/e2e/prepare.sh index 26bacf6..2f7786d 100755 --- a/e2e/prepare.sh +++ b/e2e/prepare.sh @@ -21,11 +21,11 @@ npm install ../../$NPM_PACKAGE > /dev/null rm -rf ../../$NPM_PACKAGE echo "Prepare android" -cp -r ../android . +rnpm link react-native-geocoder echo "Prepare JS app" cp ../js/index.android.js . echo "Compile android" cd android -./gradlew clean assembleDebug -PdisablePreDex +./gradlew clean assembleDebug diff --git a/e2e/run.sh b/e2e/run.sh index b7170a7..c7116d4 100755 --- a/e2e/run.sh +++ b/e2e/run.sh @@ -9,15 +9,20 @@ echo "Start Appium" node_modules/.bin/appium & APPIUM_PID=$! +echo "Start static http server" +http-server & +HTTPSERVER_PID=$! + echo "Start packager" node e2e/GeocoderE2EApp/node_modules/react-native/local-cli/cli.js start --reset-cache & PACKAGER_PID=$! sleep 5 -node_modules/.bin/mocha && SUCCESS=$? || SUCCESS=$? +node_modules/.bin/mocha --require test/setup.js test/e2e && SUCCESS=$? || SUCCESS=$? kill $APPIUM_PID +kill $HTTPSERVER_PID kill $PACKAGER_PID exit $SUCCESS