diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index cb8fbbb9c..5d90a0f2a 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -287,6 +287,7 @@ dependencies { testCompile "org.easytesting:fest-assert-core:${FEST_ASSERT_CORE_VERSION}" testCompile "org.robolectric:robolectric:${ROBOLECTRIC_VERSION}" + androidTestCompile fileTree(dir: 'src/main/third-party/java/buck-android-support/', include: ['*.jar']) androidTestCompile 'com.android.support.test:runner:0.3' androidTestCompile "org.mockito:mockito-core:${MOCKITO_CORE_VERSION}" } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK index 6f4d57fa6..22336f925 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK @@ -6,6 +6,7 @@ android_library( deps = [ react_native_dep('libraries/soloader/java/com/facebook/soloader:soloader'), react_native_dep('third-party/android/support/v4:lib-support-v4'), + react_native_dep('third-party/java/buck-android-support:buck-android-support'), react_native_dep('third-party/java/infer-annotations:infer-annotations'), react_native_dep('third-party/java/jsr-305:jsr-305'), react_native_dep('third-party/java/junit:junit'), diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestAppShell.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestAppShell.java new file mode 100644 index 000000000..7f5d2cd6c --- /dev/null +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestAppShell.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +package com.facebook.react.testing; + +import com.facebook.buck.android.support.exopackage.ApplicationLike; +import com.facebook.buck.android.support.exopackage.ExopackageApplication; +import com.facebook.react.common.build.ReactBuildConfig; +import com.facebook.soloader.SoLoader; + +/** + * Application class for the Catalyst Launcher to allow it to work as an exopackage. + * + * Any app-specific code that should run before secondary dex files are loaded + * (like setting up crash reporting) should go in onBaseContextAttached. + * Anything that should run after secondary dex should go in CatalystApplicationImpl.onCreate. + */ +public class ReactTestAppShell extends ExopackageApplication { + + public ReactTestAppShell() { + super("com.facebook.react.testing.ReactTestApplicationImpl", ReactBuildConfig.EXOPACKAGE_FLAGS); + } + + @Override + protected void onBaseContextAttached() { + // This is a terrible hack. Don't copy it. + // It's unfortunate that Instagram does the same thing. + // We need to do this here because internal apps use SoLoader, + // and Open Source Buck uses ExopackageSoLoader. + // If you feel the need to copy this, we should refactor it + // into an FB-specific subclass of ExopackageApplication. + SoLoader.init(this, (ReactBuildConfig.EXOPACKAGE_FLAGS & 2) != 0); + } +} diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestApplicationImpl.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestApplicationImpl.java new file mode 100644 index 000000000..6f58924f6 --- /dev/null +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestApplicationImpl.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +package com.facebook.react.testing; + +import android.app.Application; + +import com.facebook.buck.android.support.exopackage.DefaultApplicationLike; + +public class ReactTestApplicationImpl extends DefaultApplicationLike { + + public ReactTestApplicationImpl() { + super(); + } + + public ReactTestApplicationImpl(Application application) { + super(application); + } +} diff --git a/ReactAndroid/src/main/third-party/java/buck-android-support/BUCK b/ReactAndroid/src/main/third-party/java/buck-android-support/BUCK new file mode 100644 index 000000000..67307130b --- /dev/null +++ b/ReactAndroid/src/main/third-party/java/buck-android-support/BUCK @@ -0,0 +1,14 @@ +include_defs('//ReactAndroid/DEFS') + +# this lib was compiled by buck version : 6cbf2709778ea352a169d1c84e3ef2894dfa39ec +prebuilt_jar( + name = 'buck-android-support', + binary_jar = 'buck-android-support.jar', + visibility = [ + react_native_integration_tests_target('...'), + ], +) + +project_config( + src_target = ':buck-android-support', +) diff --git a/ReactAndroid/src/main/third-party/java/buck-android-support/buck-android-support.jar b/ReactAndroid/src/main/third-party/java/buck-android-support/buck-android-support.jar new file mode 100644 index 000000000..52c8d8f43 Binary files /dev/null and b/ReactAndroid/src/main/third-party/java/buck-android-support/buck-android-support.jar differ