Browse Source

Fix orientation android e2e

Guy Carmeli 6 years ago
parent
commit
e4adf9a715

+ 2
- 0
e2e/Orientations.test.js View File

@@ -8,6 +8,7 @@ describe('orientation', () => {
8 8
 
9 9
   beforeEach(async () => {
10 10
     await device.relaunchApp();
11
+    waitForDeviceToSettleAfterOrientationChangeAndroid = ms => new Promise(res => setTimeout(res, device.getPlatform() === 'ios' ? 0 : 10));
11 12
   });
12 13
 
13 14
   it('default allows all', async () => {
@@ -17,6 +18,7 @@ describe('orientation', () => {
17 18
     await device.setOrientation('landscape');
18 19
     await expect(elementById(testIDs.LANDSCAPE_ELEMENT)).toBeVisible();
19 20
     await device.setOrientation('portrait');
21
+    waitForDeviceToSettleAfterOrientationChangeAndroid();
20 22
     await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
21 23
     await elementById(testIDs.DISMISS_BUTTON).tap();
22 24
   });

+ 35
- 0
e2e/OverlayTest.test.js View File

@@ -0,0 +1,35 @@
1
+const Utils = require('./Utils');
2
+const testIDs = require('../playground/src/testIDs');
3
+const { elementByLabel, elementById } = Utils;
4
+
5
+describe('Overlay', () => {
6
+  beforeEach(async () => {
7
+    await device.relaunchApp();
8
+  });
9
+
10
+  it('show and dismiss overlay', async () => {
11
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
12
+    await elementById(testIDs.SHOW_OVERLAY_BUTTON).tap();
13
+    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
14
+    await elementById(testIDs.OK_BUTTON).tap();
15
+    await expect(elementById(testIDs.DIALOG_HEADER)).toBeNotVisible();
16
+  });
17
+
18
+  it('overlay pass touches - true', async () => {
19
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
20
+    await elementById(testIDs.SHOW_TOUCH_THROUGH_OVERLAY_BUTTON).tap();
21
+    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
22
+    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
23
+    await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
24
+    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
25
+  });
26
+
27
+  it('overlay pass touches - false', async () => {
28
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
29
+    await elementById(testIDs.SHOW_OVERLAY_BUTTON).tap();
30
+    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
31
+    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
32
+    await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
33
+    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
34
+  });
35
+});

+ 5
- 17
lib/android/app/src/main/java/com/reactnativenavigation/parse/params/Orientation.java View File

@@ -1,22 +1,19 @@
1 1
 package com.reactnativenavigation.parse.params;
2 2
 
3 3
 import android.content.pm.ActivityInfo;
4
-import android.content.res.Configuration;
5 4
 import android.support.annotation.Nullable;
6 5
 
7 6
 public enum Orientation {
8
-    Portrait("portrait", Configuration.ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT),
9
-    Landscape("landscape", Configuration.ORIENTATION_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE),
10
-    Default("default", Configuration.ORIENTATION_UNDEFINED, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED),
11
-    PortraitLandscape("sensor", Configuration.ORIENTATION_UNDEFINED, ActivityInfo.SCREEN_ORIENTATION_USER);
7
+    Portrait("portrait", ActivityInfo.SCREEN_ORIENTATION_PORTRAIT),
8
+    Landscape("landscape", ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE),
9
+    Default("default", ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED),
10
+    PortraitLandscape("sensor", ActivityInfo.SCREEN_ORIENTATION_USER);
12 11
 
13 12
     public String name;
14
-    public int configurationCode;
15 13
     public int orientationCode;
16 14
 
17
-    Orientation(String name, int configurationCode, int orientationCode) {
15
+    Orientation(String name, int orientationCode) {
18 16
         this.name = name;
19
-        this.configurationCode = configurationCode;
20 17
         this.orientationCode = orientationCode;
21 18
     }
22 19
 
@@ -29,13 +26,4 @@ public enum Orientation {
29 26
         }
30 27
         return null;
31 28
     }
32
-
33
-    public static String fromConfigurationCode(int configurationCode) {
34
-        for (Orientation orientation : values()) {
35
-            if (orientation.configurationCode == configurationCode) {
36
-                return orientation.name;
37
-            }
38
-        }
39
-        throw new RuntimeException();
40
-    }
41 29
 }