Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 4.0.0 branch into master #48

Merged
merged 33 commits into from
Nov 30, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7a2b27e
Use fbsimcmd installed from brew, rather than bring it as a dependenc…
LeoNatan Oct 12, 2016
510045b
Use EarlGrey and SocketRocket as sub-modules. Update EarlGrey to the …
LeoNatan Oct 12, 2016
ac4eb9f
Update to latest React & React Native in test project.
LeoNatan Oct 12, 2016
658a157
Support modern RN reloadRequest method, if available, else fallback t…
LeoNatan Oct 13, 2016
cb419e6
Move each action to its own script, set `test` script to use other sc…
LeoNatan Oct 13, 2016
3277efc
Scripts overhaul
LeoNatan Oct 14, 2016
a798f04
Add new idling resources for dispatch queue, JS display link, JS runl…
LeoNatan Oct 18, 2016
f81daed
Update tests to work with new Detox.
LeoNatan Oct 18, 2016
281c7b8
Add native timeout.
LeoNatan Oct 19, 2016
c543cbf
Remove unneeded imports from public header file.
LeoNatan Oct 25, 2016
6b7be12
Make Detox scheme shared
LeoNatan Oct 25, 2016
d6552de
Fix symbolic links in SocketRocket after npm install, causing compile…
LeoNatan Oct 26, 2016
351d828
Add detox deployment script for Xcode projects
LeoNatan Nov 4, 2016
9804005
Script fixes
LeoNatan Nov 10, 2016
9dcdba2
Upgrade EarlGrey with improved scrolling performance.
LeoNatan Nov 10, 2016
6905745
moved fbsimctl to postinstall
rotemmiz Nov 27, 2016
323bb86
bump major
rotemmiz Nov 27, 2016
59099fe
Update deploy script to use correct path.
LeoNatan Nov 27, 2016
744ab05
Merge branch 'improve_tooling' of github.com:wix/detox into improve_t…
rotemmiz Nov 27, 2016
a44aac2
Update postinstall.js
LeoNatan Nov 27, 2016
c08753a
Merge branch 'improve_tooling' of github.com:wix/detox into improve_t…
rotemmiz Nov 27, 2016
096a9f9
bump
rotemmiz Nov 27, 2016
c41678a
Update postinstall.js
LeoNatan Nov 30, 2016
affdb80
version ++
LeoNatan Nov 30, 2016
1c195c0
Use bash script to remove shelljs dependency.
LeoNatan Nov 30, 2016
3951014
Version ++
LeoNatan Nov 30, 2016
7743a8d
Use iOS 10.1 in test.
LeoNatan Nov 30, 2016
017e7fc
Fix Detox logic
LeoNatan Nov 30, 2016
994af2a
major version 4
DanielZlotin Nov 30, 2016
8a0d82b
Improve npm deployment
LeoNatan Nov 30, 2016
7713189
Ignore dirty submodules
LeoNatan Nov 30, 2016
bd416ce
Version ++
LeoNatan Nov 30, 2016
346c268
Merge master branch
LeoNatan Nov 30, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix Detox logic
  • Loading branch information
LeoNatan committed Nov 30, 2016
commit 017e7fc137afa9b4e75a619b2e5f4a2113987575
31 changes: 22 additions & 9 deletions detox/ios/Detox/DetoxManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

@interface DetoxManager()

@property (nonatomic) BOOL isReady;
@property (nonatomic, retain) WebSocket *websocket;
@property (nonatomic, retain) TestRunner *testRunner;

Expand Down Expand Up @@ -61,6 +62,11 @@ - (instancetype)init
self.testRunner = [[TestRunner alloc] init];
self.testRunner.delegate = self;

if([ReactNativeSupport isReactNativeApp])
{
[self _waitForRNLoad];
}

return self;
}

Expand All @@ -73,6 +79,7 @@ - (void) websocketDidConnect
{
if (![ReactNativeSupport isReactNativeApp])
{
_isReady = YES;
[self.websocket sendAction:@"ready" withParams:@{}];
}
}
Expand All @@ -87,7 +94,10 @@ - (void) websocketDidReceiveAction:(NSString *)type withParams:(NSDictionary *)p

if ([type isEqualToString:@"isReady"])
{
[self.websocket sendAction:@"ready" withParams:@{}];
if(_isReady)
{
[self.websocket sendAction:@"ready" withParams:@{}];
}
return;
}

Expand All @@ -100,21 +110,24 @@ - (void) websocketDidReceiveAction:(NSString *)type withParams:(NSDictionary *)p

if ([type isEqualToString:@"reactNativeReload"])
{
_isReady = NO;
[ReactNativeSupport reloadApp];

__block __weak id observer;
__weak __typeof(self) weakSelf = self;
[self _waitForRNLoad];

observer = [[NSNotificationCenter defaultCenter] addObserverForName:@"RCTContentDidAppearNotification" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {

[weakSelf.websocket sendAction:@"ready" withParams:@{}];

[[NSNotificationCenter defaultCenter] removeObserver:observer];
}];
return;
}
}

- (void)_waitForRNLoad
{
__weak __typeof(self) weakSelf = self;
[ReactNativeSupport waitForReactNativeLoadWithCompletionHandler:^{
weakSelf.isReady = YES;
[weakSelf.websocket sendAction:@"ready" withParams:@{}];
}];
}

- (void)testRunnerOnInvokeResult:(id)res withInvocationId:(NSString *)invocationId
{
if (res == nil) res = @"(null)";
Expand Down
5 changes: 3 additions & 2 deletions detox/ios/Detox/ReactNativeSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

@interface ReactNativeSupport : NSObject

+ (BOOL) isReactNativeApp;
+ (void) reloadApp;
+ (BOOL)isReactNativeApp;
+ (void)reloadApp;
+ (void)waitForReactNativeLoadWithCompletionHandler:(void(^)(void))handler;

@end

15 changes: 15 additions & 0 deletions detox/ios/Detox/ReactNativeSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,19 @@ + (void) reloadApp
}
}

+ (void)waitForReactNativeLoadWithCompletionHandler:(void (^)(void))handler
{
__block __weak id observer;

observer = [[NSNotificationCenter defaultCenter] addObserverForName:@"RCTContentDidAppearNotification" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {

if(handler)
{
handler();
}

[[NSNotificationCenter defaultCenter] removeObserver:observer];
}];
}

@end