Skip to content

Commit

Permalink
Merge pull request wix#2421 from wix/DeviceOrientation
Browse files Browse the repository at this point in the history
Fail tests in cases where setting device orientation is not supported
  • Loading branch information
LeoNatan authored Oct 18, 2020
2 parents 1c5f6a2 + 91a2027 commit 72060b7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions detox/ios/Detox/Actions/UIDevice+DetoxActions.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ @implementation UIDevice (DetoxActions)
+ (void)dtx_setOrientation:(UIDeviceOrientation)deviceOrientation
{
NSParameterAssert(NSThread.isMainThread);
DTXAssert(UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone || [[NSBundle.mainBundle objectForInfoDictionaryKey:@"UIRequiresFullScreen"] boolValue] == YES, @"Setting device orientation is only supported for iPhone devices, or for apps declared as requiring full screen on iPad.");
[[UIDevice currentDevice] setOrientation:deviceOrientation animated:YES];
}

Expand Down
2 changes: 2 additions & 0 deletions detox/test/ios/example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "com.wix.detox-example";
PRODUCT_NAME = example;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
Expand Down Expand Up @@ -605,6 +606,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "com.wix.detox-example";
PRODUCT_NAME = example;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
Expand Down
3 changes: 3 additions & 0 deletions detox/test/ios/example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@
<array>
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
Expand Down
7 changes: 5 additions & 2 deletions docs/APIRef.DeviceObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,12 @@ Read more in [Mocking User Activity](APIRef.MockingUserActivity.md) section.
Check out Detox's [own test suite](../detox/test/e2e/18.user-activities.test.js)

### `device.setOrientation(orientation)`

Takes `"portrait"` or `"landscape"` and rotates the device to the given orientation.
Currently only available in the iOS Simulator.
Check out Detox's [own test suite](../detox/test/e2e/06.device-orientation.test.js)

**Note:** Setting device orientation is only supported for iPhone devices, or for apps declared as requiring full screen on iPad. For all other cases, the current test will be failed.

Check out Detox's [own test suite.](../detox/test/e2e/06.device-orientation.test.js)

### `device.setLocation(lat, lon)`
>Note: `setLocation` is dependent on `fbsimctl`. if `fbsimctl` is not installed, the command will fail, asking for it to be installed.
Expand Down

0 comments on commit 72060b7

Please sign in to comment.