File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed
Ports/iOSPort/nativeSources
scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -1982,8 +1982,24 @@ void com_codename1_impl_ios_IOSNative_lockOrientation___boolean(CN1_THREAD_STATE
19821982 // XMLVM_BEGIN_WRAPPER[com_codename1_impl_ios_IOSNative_lockOrientation___boolean]
19831983 if (n1) {
19841984 orientationLock = 1 ;
1985+ dispatch_async (dispatch_get_main_queue (), ^{
1986+ UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication ] statusBarOrientation ];
1987+ if (currentOrientation != UIInterfaceOrientationPortrait && currentOrientation != UIInterfaceOrientationPortraitUpsideDown) {
1988+ NSNumber *value = [NSNumber numberWithInt: UIInterfaceOrientationPortrait];
1989+ [[UIDevice currentDevice ] setValue: value forKey: @" orientation" ];
1990+ [UIViewController attemptRotationToDeviceOrientation ];
1991+ }
1992+ });
19851993 } else {
19861994 orientationLock = 2 ;
1995+ dispatch_async (dispatch_get_main_queue (), ^{
1996+ UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication ] statusBarOrientation ];
1997+ if (currentOrientation != UIInterfaceOrientationLandscapeLeft && currentOrientation != UIInterfaceOrientationLandscapeRight) {
1998+ NSNumber *value = [NSNumber numberWithInt: UIInterfaceOrientationLandscapeRight];
1999+ [[UIDevice currentDevice ] setValue: value forKey: @" orientation" ];
2000+ [UIViewController attemptRotationToDeviceOrientation ];
2001+ }
2002+ });
19872003 }
19882004 // XMLVM_END_WRAPPER
19892005}
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ public final class Cn1ssDeviceRunner extends DeviceRunner {
6464 new TransformCamera (),
6565 new BrowserComponentScreenshotTest (),
6666 new MediaPlaybackScreenshotTest (),
67+ new OrientationLockScreenshotTest (),
6768 new InPlaceEditViewTest (),
6869 new AccessibilityTest ()
6970 };
@@ -93,10 +94,10 @@ public void runSuite() {
9394 t .printStackTrace ();
9495 }
9596 });
96- int timeout = 9000 ;
97+ int timeout = 30000 ;
9798 while (!testClass .isDone () && timeout > 0 ) {
9899 Util .sleep (3 );
99- timeout -- ;
100+ timeout -= 3 ;
100101 }
101102 testClass .cleanup ();
102103 if (timeout == 0 ) {
Original file line number Diff line number Diff line change 1+ package com .codenameone .examples .hellocodenameone .tests ;
2+
3+ import com .codename1 .testing .TestUtils ;
4+ import com .codename1 .ui .CN ;
5+ import com .codename1 .ui .Form ;
6+ import com .codename1 .ui .Label ;
7+ import com .codename1 .ui .layouts .BoxLayout ;
8+ import com .codename1 .ui .util .UITimer ;
9+
10+ public class OrientationLockScreenshotTest extends BaseTest {
11+ @ Override
12+ public boolean runTest () throws Exception {
13+ Form hi = createForm ("Orientation Lock" , new BoxLayout (BoxLayout .Y_AXIS ), "landscape" );
14+ hi .add (new Label ("Testing orientation lock..." ));
15+
16+ hi .show ();
17+
18+ CN .lockOrientation (false );
19+
20+ TestUtils .waitFor (250 );
21+
22+ return true ;
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments