Repository: cordova-ios Updated Branches: refs/heads/master 3d80c24a5 -> 5c3885b80
CB-9371: Fix how prepare handles orientation on ios Update unit tests. This closes #233 Signed-off-by: Shazron Abdullah <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/5c3885b8 Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/5c3885b8 Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/5c3885b8 Branch: refs/heads/master Commit: 5c3885b807f4c9556bf350c72400827a333f78d3 Parents: 3d80c24 Author: Connor Pearson <[email protected]> Authored: Thu Jun 30 20:27:12 2016 -0400 Committer: Shazron Abdullah <[email protected]> Committed: Fri Jul 1 13:07:50 2016 -0700 ---------------------------------------------------------------------- .../project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist | 2 ++ bin/templates/scripts/cordova/lib/prepare.js | 8 ++++---- tests/spec/unit/prepare.spec.js | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5c3885b8/bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist ---------------------------------------------------------------------- diff --git a/bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist b/bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist index 2b5e1fe..30bada6 100644 --- a/bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist +++ b/bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist @@ -35,6 +35,8 @@ <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> + <string>UIInterfaceOrientationLandscapeLeft</string> + <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UISupportedInterfaceOrientations~ipad</key> <array> http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5c3885b8/bin/templates/scripts/cordova/lib/prepare.js ---------------------------------------------------------------------- diff --git a/bin/templates/scripts/cordova/lib/prepare.js b/bin/templates/scripts/cordova/lib/prepare.js index 8bc4d60..f3d6b79 100644 --- a/bin/templates/scripts/cordova/lib/prepare.js +++ b/bin/templates/scripts/cordova/lib/prepare.js @@ -267,9 +267,9 @@ function handleOrientationSettings(platformConfig, infoPlist) { infoPlist['UISupportedInterfaceOrientations'] = [ 'UIInterfaceOrientationPortrait', 'UIInterfaceOrientationPortraitUpsideDown', 'UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight' ]; infoPlist['UISupportedInterfaceOrientations~ipad'] = [ 'UIInterfaceOrientationPortrait', 'UIInterfaceOrientationPortraitUpsideDown', 'UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight' ]; break; - default: - delete infoPlist['UISupportedInterfaceOrientations']; - delete infoPlist['UISupportedInterfaceOrientations~ipad']; + case 'default': + infoPlist['UISupportedInterfaceOrientations'] = [ 'UIInterfaceOrientationPortrait', 'UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight' ]; + infoPlist['UISupportedInterfaceOrientations~ipad'] = [ 'UIInterfaceOrientationPortrait', 'UIInterfaceOrientationPortraitUpsideDown', 'UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight' ]; delete infoPlist['UIInterfaceOrientation']; } } @@ -471,7 +471,7 @@ function getOrientationValue(platformConfig) { var orientation = platformConfig.getPreference('orientation'); if (!orientation) { - return ORIENTATION_DEFAULT; + return ''; } orientation = orientation.toLowerCase(); http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/5c3885b8/tests/spec/unit/prepare.spec.js ---------------------------------------------------------------------- diff --git a/tests/spec/unit/prepare.spec.js b/tests/spec/unit/prepare.spec.js index 8776b15..ec2a976 100644 --- a/tests/spec/unit/prepare.spec.js +++ b/tests/spec/unit/prepare.spec.js @@ -150,8 +150,8 @@ describe('prepare', function () { it('should handle default orientation', function(done) { cfg.getPreference.andReturn('default'); wrapper(updateProject(cfg, p.locations), done, function() { - expect(plist.build.mostRecentCall.args[0].UISupportedInterfaceOrientations).toBeUndefined(); - expect(plist.build.mostRecentCall.args[0]['UISupportedInterfaceOrientations~ipad']).toBeUndefined(); + expect(plist.build.mostRecentCall.args[0].UISupportedInterfaceOrientations).toEqual([ 'UIInterfaceOrientationPortrait', 'UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight' ]); + expect(plist.build.mostRecentCall.args[0]['UISupportedInterfaceOrientations~ipad']).toEqual([ 'UIInterfaceOrientationPortrait', 'UIInterfaceOrientationPortraitUpsideDown', 'UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight' ]); expect(plist.build.mostRecentCall.args[0].UIInterfaceOrientation).toBeUndefined(); }); }); @@ -179,7 +179,8 @@ describe('prepare', function () { it('should handle custom orientation', function(done) { cfg.getPreference.andReturn('some-custom-orientation'); wrapper(updateProject(cfg, p.locations), done, function() { - expect(plist.build.mostRecentCall.args[0].UISupportedInterfaceOrientations).toBeUndefined(); + expect(plist.build.mostRecentCall.args[0].UISupportedInterfaceOrientations).toEqual([ 'UIInterfaceOrientationPortrait', 'UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight' ]); + expect(plist.build.mostRecentCall.args[0]['UISupportedInterfaceOrientations~ipad']).toEqual([ 'UIInterfaceOrientationPortrait', 'UIInterfaceOrientationPortraitUpsideDown', 'UIInterfaceOrientationLandscapeLeft', 'UIInterfaceOrientationLandscapeRight' ]); expect(plist.build.mostRecentCall.args[0].UIInterfaceOrientation).toBeUndefined(); }); }); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
