diff --git a/Examples/UIExplorer/LayoutExample.js b/Examples/UIExplorer/LayoutExample.js index 22ea81c00a..ef9b1c66c8 100644 --- a/Examples/UIExplorer/LayoutExample.js +++ b/Examples/UIExplorer/LayoutExample.js @@ -62,8 +62,11 @@ var CircleBlock = React.createClass({ var LayoutExample = React.createClass({ statics: { title: 'Layout - Flexbox', - description: 'Examples of using the flexbox API to layout views.' + description: 'Examples of using the flexbox API to layout views.', }, + + displayName: 'LayoutExample', + render: function() { return ( diff --git a/Examples/UIExplorer/TabBarIOSExample.js b/Examples/UIExplorer/TabBarIOSExample.js index 12ca22e78a..0cbd1fb9a0 100644 --- a/Examples/UIExplorer/TabBarIOSExample.js +++ b/Examples/UIExplorer/TabBarIOSExample.js @@ -26,9 +26,11 @@ var { var TabBarExample = React.createClass({ statics: { title: '', - description: 'Tab-based navigation.' + description: 'Tab-based navigation.', }, + displayName: 'TabBarExample', + getInitialState: function() { return { selectedTab: 'redTab', diff --git a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj index c266cabcfe..5b1d0d2409 100644 --- a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj +++ b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj @@ -17,8 +17,8 @@ 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; - 141FC1211B222EBB004D5FFB /* IntegrationTestsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 141FC1201B222EBB004D5FFB /* IntegrationTestsTests.m */; }; - 143BC5A11B21E45C00462512 /* UIExplorerIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 143BC5A01B21E45C00462512 /* UIExplorerIntegrationTests.m */; }; + 141FC1211B222EBB004D5FFB /* IntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 141FC1201B222EBB004D5FFB /* IntegrationTests.m */; }; + 143BC5A11B21E45C00462512 /* UIExplorerSnapshotTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 143BC5A01B21E45C00462512 /* UIExplorerSnapshotTests.m */; }; 144D21241B2204C5006DB32B /* RCTClippingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 144D21231B2204C5006DB32B /* RCTClippingTests.m */; }; 147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 147CED4B1AB34F8C00DA3E4C /* libRCTActionSheet.a */; }; 1497CFAC1B21F5E400C1F8F2 /* RCTAllocationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA41B21F5E400C1F8F2 /* RCTAllocationTests.m */; }; @@ -167,7 +167,7 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = UIExplorer/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = UIExplorer/main.m; sourceTree = ""; }; 13CC9D481AEED2B90020D1C2 /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = ../../Libraries/Settings/RCTSettings.xcodeproj; sourceTree = ""; }; - 141FC1201B222EBB004D5FFB /* IntegrationTestsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IntegrationTestsTests.m; sourceTree = ""; }; + 141FC1201B222EBB004D5FFB /* IntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IntegrationTests.m; sourceTree = ""; }; 143BC57E1B21E18100462512 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 143BC5811B21E18100462512 /* testLayoutExampleSnapshot_1@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "testLayoutExampleSnapshot_1@2x.png"; sourceTree = ""; }; 143BC5821B21E18100462512 /* testSliderExampleSnapshot_1@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "testSliderExampleSnapshot_1@2x.png"; sourceTree = ""; }; @@ -177,7 +177,7 @@ 143BC5861B21E18100462512 /* testViewExampleSnapshot_1@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "testViewExampleSnapshot_1@2x.png"; sourceTree = ""; }; 143BC5951B21E3E100462512 /* UIExplorerIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UIExplorerIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 143BC5981B21E3E100462512 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 143BC5A01B21E45C00462512 /* UIExplorerIntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIExplorerIntegrationTests.m; sourceTree = ""; }; + 143BC5A01B21E45C00462512 /* UIExplorerSnapshotTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIExplorerSnapshotTests.m; sourceTree = ""; }; 144D21231B2204C5006DB32B /* RCTClippingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTClippingTests.m; sourceTree = ""; }; 1497CFA41B21F5E400C1F8F2 /* RCTAllocationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAllocationTests.m; sourceTree = ""; }; 1497CFA51B21F5E400C1F8F2 /* RCTBridgeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTBridgeTests.m; sourceTree = ""; }; @@ -381,8 +381,8 @@ 143BC5961B21E3E100462512 /* UIExplorerIntegrationTests */ = { isa = PBXGroup; children = ( - 141FC1201B222EBB004D5FFB /* IntegrationTestsTests.m */, - 143BC5A01B21E45C00462512 /* UIExplorerIntegrationTests.m */, + 141FC1201B222EBB004D5FFB /* IntegrationTests.m */, + 143BC5A01B21E45C00462512 /* UIExplorerSnapshotTests.m */, 143BC5971B21E3E100462512 /* Supporting Files */, ); path = UIExplorerIntegrationTests; @@ -796,8 +796,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 141FC1211B222EBB004D5FFB /* IntegrationTestsTests.m in Sources */, - 143BC5A11B21E45C00462512 /* UIExplorerIntegrationTests.m in Sources */, + 141FC1211B222EBB004D5FFB /* IntegrationTests.m in Sources */, + 143BC5A11B21E45C00462512 /* UIExplorerSnapshotTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/uie_thumb_big.imageset/Contents.json b/Examples/UIExplorer/UIExplorer/Images.xcassets/uie_thumb_big.imageset/Contents.json new file mode 100644 index 0000000000..589a2f4930 --- /dev/null +++ b/Examples/UIExplorer/UIExplorer/Images.xcassets/uie_thumb_big.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "uie_thumb_big.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/UIExplorer/UIExplorer/Images.xcassets/uie_thumb_big.imageset/uie_thumb_big.png b/Examples/UIExplorer/UIExplorer/Images.xcassets/uie_thumb_big.imageset/uie_thumb_big.png new file mode 100644 index 0000000000..dbfdb1b9b2 Binary files /dev/null and b/Examples/UIExplorer/UIExplorer/Images.xcassets/uie_thumb_big.imageset/uie_thumb_big.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTestsTests.m b/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTests.m similarity index 94% rename from Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTestsTests.m rename to Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTests.m index 44d0483233..78e6c8265e 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTestsTests.m +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTests.m @@ -14,11 +14,11 @@ #import "RCTAssert.h" -@interface IntegrationTestsTests : XCTestCase +@interface IntegrationTests : XCTestCase @end -@implementation IntegrationTestsTests +@implementation IntegrationTests { RCTTestRunner *_runner; } @@ -31,7 +31,7 @@ NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion]; RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion); - _runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp"); + _runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp", nil); } #pragma mark Logic Tests diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testLayoutExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testLayoutExample_1@2x.png similarity index 100% rename from Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testLayoutExampleSnapshot_1@2x.png rename to Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testLayoutExample_1@2x.png diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSliderExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSliderExampleSnapshot_1@2x.png deleted file mode 100644 index 66b2645fd8..0000000000 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSliderExampleSnapshot_1@2x.png and /dev/null differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSliderExample_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSliderExample_1@2x.png new file mode 100644 index 0000000000..8cf73dbdeb Binary files /dev/null and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSliderExample_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSwitchExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSwitchExampleSnapshot_1@2x.png deleted file mode 100644 index 6ed97e55cb..0000000000 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSwitchExampleSnapshot_1@2x.png and /dev/null differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSwitchExample_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSwitchExample_1@2x.png new file mode 100644 index 0000000000..b3f91815ee Binary files /dev/null and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSwitchExample_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTabBarExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTabBarExample_1@2x.png similarity index 64% rename from Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTabBarExampleSnapshot_1@2x.png rename to Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTabBarExample_1@2x.png index 0eb7133439..85757513fb 100644 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTabBarExampleSnapshot_1@2x.png and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTabBarExample_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTextExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTextExampleSnapshot_1@2x.png deleted file mode 100644 index 5d5e3b9680..0000000000 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTextExampleSnapshot_1@2x.png and /dev/null differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTextExample_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTextExample_1@2x.png new file mode 100644 index 0000000000..7020433495 Binary files /dev/null and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTextExample_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testViewExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testViewExample_1@2x.png similarity index 100% rename from Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testViewExampleSnapshot_1@2x.png rename to Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testViewExample_1@2x.png diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerIntegrationTests.m b/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerSnapshotTests.m similarity index 68% rename from Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerIntegrationTests.m rename to Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerSnapshotTests.m index 869c329639..1eb3110ec6 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerIntegrationTests.m +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerSnapshotTests.m @@ -21,14 +21,14 @@ #import "RCTRedBox.h" #import "RCTRootView.h" -@interface UIExplorerTests : XCTestCase +@interface UIExplorerSnapshotTests : XCTestCase { RCTTestRunner *_runner; } @end -@implementation UIExplorerTests +@implementation UIExplorerSnapshotTests - (void)setUp { @@ -37,21 +37,26 @@ #endif NSString *version = [[UIDevice currentDevice] systemVersion]; RCTAssert([version isEqualToString:@"8.3"], @"Snapshot tests should be run on iOS 8.3, found %@", version); - _runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerApp.ios"); + _runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerApp.ios", nil); + _runner.recordMode = NO; } -#define RCT_SNAPSHOT_TEST(name, reRecord) \ -- (void)test##name##Snapshot \ -{ \ - _runner.recordMode |= reRecord; \ - [_runner runTest:_cmd module:@#name]; \ +#define RCT_TEST(name) \ +- (void)test##name \ +{ \ + [_runner runTest:_cmd module:@#name]; \ } -RCT_SNAPSHOT_TEST(ViewExample, NO) -RCT_SNAPSHOT_TEST(LayoutExample, NO) -RCT_SNAPSHOT_TEST(TextExample, NO) -RCT_SNAPSHOT_TEST(SwitchExample, NO) -RCT_SNAPSHOT_TEST(SliderExample, NO) -RCT_SNAPSHOT_TEST(TabBarExample, NO) +RCT_TEST(ViewExample) +RCT_TEST(LayoutExample) +RCT_TEST(TextExample) +RCT_TEST(SwitchExample) +RCT_TEST(SliderExample) +RCT_TEST(TabBarExample) + +- (void)testZZZNotInRecordMode +{ + XCTAssertFalse(_runner.recordMode, @"Don't forget to turn record mode back to off"); +} @end diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js b/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js index 21f0f7a2a7..519e333a2e 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp.js @@ -53,7 +53,7 @@ var IntegrationTestsApp = React.createClass({ Click on a test to run it in this shell for easier debugging and - development. Run all tests in the testing envirnment with cmd+U in + development. Run all tests in the testing environment with cmd+U in Xcode. diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/js/LayoutEventsTest.js b/Examples/UIExplorer/UIExplorerIntegrationTests/js/LayoutEventsTest.js index 260a1c8c9e..0e16555f0c 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/js/LayoutEventsTest.js +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/js/LayoutEventsTest.js @@ -121,7 +121,7 @@ var LayoutEventsTest = React.createClass({ ref="img" onLayout={this.onImageLayout} style={styles.image} - source={{uri: 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851561_767334496626293_1958532586_n.png'}} + source={{uri: 'uie_thumb_big.png'}} /> ViewLayout: {JSON.stringify(this.state.viewLayout, null, ' ') + '\n\n'} diff --git a/Libraries/Animation/AnimationExperimental.js b/Libraries/Animation/AnimationExperimental.js index b66b1d056c..e871c6a0d5 100644 --- a/Libraries/Animation/AnimationExperimental.js +++ b/Libraries/Animation/AnimationExperimental.js @@ -7,11 +7,18 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule AnimationExperimental - * @flow */ 'use strict'; var RCTAnimationManager = require('NativeModules').AnimationExperimentalManager; +if (!RCTAnimationManager) { + // AnimationExperimental isn't available internally - this is a temporary + // workaround to enable its availability to be determined at runtime. + // For Flow let's pretend like we always export AnimationExperimental + // so all our users don't need to do null checks + module.exports = null; +} else { + var React = require('React'); var AnimationUtils = require('AnimationUtils'); @@ -88,3 +95,5 @@ if (__DEV__) { } module.exports = AnimationExperimental; + +} diff --git a/Libraries/RCTTest/RCTTestModule.h b/Libraries/RCTTest/RCTTestModule.h index 5ea69dcb6f..06c408bea7 100644 --- a/Libraries/RCTTest/RCTTestModule.h +++ b/Libraries/RCTTest/RCTTestModule.h @@ -25,12 +25,12 @@ typedef NS_ENUM(NSInteger, RCTTestStatus) { /** * The snapshot test controller for this module. */ -@property (nonatomic, weak) FBSnapshotTestController *controller; +@property (nonatomic, strong) FBSnapshotTestController *controller; /** * This is the view to be snapshotted. */ -@property (nonatomic, weak) UIView *view; +@property (nonatomic, strong) UIView *view; /** * This is used to give meaningful names to snapshot image files. diff --git a/Libraries/RCTTest/RCTTestRunner.h b/Libraries/RCTTest/RCTTestRunner.h index 21b558b8c0..72a2b31278 100644 --- a/Libraries/RCTTest/RCTTestRunner.h +++ b/Libraries/RCTTest/RCTTestRunner.h @@ -16,7 +16,10 @@ * * FB_REFERENCE_IMAGE_DIR="\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\"" */ -#define RCTInitRunnerForApp(app__) [[RCTTestRunner alloc] initWithApp:(app__) referenceDir:@FB_REFERENCE_IMAGE_DIR] +#define RCTInitRunnerForApp(app__, moduleProvider__) \ +[[RCTTestRunner alloc] initWithApp:(app__) \ + referenceDirectory:@FB_REFERENCE_IMAGE_DIR \ + moduleProvider:(moduleProvider__)] @interface RCTTestRunner : NSObject @@ -28,10 +31,12 @@ * macro instead of calling this directly. * * @param app The path to the app bundle without suffixes, e.g. IntegrationTests/IntegrationTestsApp - * @param referenceDir The path for snapshot references images. The RCTInitRunnerForApp macro uses - * FB_REFERENCE_IMAGE_DIR for this automatically. + * @param referenceDirectory The path for snapshot references images. The RCTInitRunnerForApp macro uses FB_REFERENCE_IMAGE_DIR for this automatically. + * @param block A block that returns an array of extra modules to be used by the test runner. */ -- (instancetype)initWithApp:(NSString *)app referenceDir:(NSString *)referenceDir NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithApp:(NSString *)app + referenceDirectory:(NSString *)referenceDirectory + moduleProvider:(NSArray *(^)(void))block NS_DESIGNATED_INITIALIZER; /** * Simplest runTest function simply mounts the specified JS module with no diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index 73f88d5edb..f270c3b81c 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -27,20 +27,27 @@ @implementation RCTTestRunner { FBSnapshotTestController *_testController; + RCTBridgeModuleProviderBlock _moduleProvider; } -- (instancetype)initWithApp:(NSString *)app referenceDir:(NSString *)referenceDir +- (instancetype)initWithApp:(NSString *)app + referenceDirectory:(NSString *)referenceDirectory + moduleProvider:(RCTBridgeModuleProviderBlock)block { RCTAssertParam(app); - RCTAssertParam(referenceDir); + RCTAssertParam(referenceDirectory); if ((self = [super init])) { + NSString *sanitizedAppName = [app stringByReplacingOccurrencesOfString:@"/" withString:@"-"]; sanitizedAppName = [sanitizedAppName stringByReplacingOccurrencesOfString:@"\\" withString:@"-"]; _testController = [[FBSnapshotTestController alloc] initWithTestName:sanitizedAppName]; - _testController.referenceImagesDirectory = referenceDir; + _testController.referenceImagesDirectory = referenceDirectory; + _moduleProvider = [block copy]; + #if RUNNING_ON_CI _scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"]; + RCTAssert(_scriptURL != nil, @"Could not locate main.jsBundle"); #else _scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.includeRequire.runModule.bundle?dev=true", app]]; #endif @@ -73,16 +80,20 @@ RCT_NOT_IMPLEMENTED(-init) }]; } -- (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictionary *)initialProps expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock +- (void)runTest:(SEL)test module:(NSString *)moduleName + initialProps:(NSDictionary *)initialProps expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock { - RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:_scriptURL - moduleName:moduleName - launchOptions:nil]; + RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_scriptURL + moduleProvider:_moduleProvider + launchOptions:nil]; + + RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName]; rootView.initialProperties = initialProps; rootView.frame = CGRectMake(0, 0, 320, 2000); // Constant size for testing on multiple devices NSString *testModuleName = RCTBridgeModuleNameForClass([RCTTestModule class]); RCTTestModule *testModule = rootView.bridge.batchedBridge.modules[testModuleName]; + RCTAssert(_testController != nil, @"_testController should not be nil"); testModule.controller = _testController; testModule.testSelector = test; testModule.view = rootView; @@ -100,14 +111,11 @@ RCT_NOT_IMPLEMENTED(-init) } [rootView removeFromSuperview]; - NSArray *nonLayoutSubviews = [vc.view.subviews filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id subview, NSDictionary *bindings) { return ![NSStringFromClass([subview class]) isEqualToString:@"_UILayoutGuide"]; }]]; RCTAssert(nonLayoutSubviews.count == 0, @"There shouldn't be any other views: %@", nonLayoutSubviews); - - vc.view = nil; [[RCTRedBox sharedInstance] dismiss]; if (expectErrorBlock) { RCTAssert(expectErrorBlock(error), @"Expected an error but nothing matched."); @@ -116,7 +124,6 @@ RCT_NOT_IMPLEMENTED(-init) RCTAssert(testModule.status != RCTTestStatusPending, @"Test didn't finish within %d seconds", TIMEOUT_SECONDS); RCTAssert(testModule.status == RCTTestStatusPassed, @"Test failed"); } - RCTAssert(self.recordMode == NO, @"Don't forget to turn record mode back to NO before commit."); } @end diff --git a/React/Base/RCTJavaScriptLoader.m b/React/Base/RCTJavaScriptLoader.m index 44d9e81c16..b110c5af0f 100755 --- a/React/Base/RCTJavaScriptLoader.m +++ b/React/Base/RCTJavaScriptLoader.m @@ -21,7 +21,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge { - RCTAssert(bridge, @"birdge parameter is required"); + RCTAssert(bridge, @"bridge parameter is required"); if ((self = [super init])) { _bridge = bridge; diff --git a/React/Views/RCTMapManager.m b/React/Views/RCTMapManager.m index fba2a60fab..efaf6cc48b 100644 --- a/React/Views/RCTMapManager.m +++ b/React/Views/RCTMapManager.m @@ -79,7 +79,7 @@ RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion, RCTMap) } } -- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(RCTPointAnnotation *)annotation +- (MKAnnotationView *)mapView:(__unused MKMapView *)mapView viewForAnnotation:(RCTPointAnnotation *)annotation { if ([annotation isKindOfClass:[MKUserLocation class]]) { return nil;