Browse Source

e2e adjustments for detox android

yogevbd 6 years ago
parent
commit
aa01d95e50

+ 1
- 1
e2e/Orientations.test.js View File

4
 
4
 
5
 const { elementById } = Utils;
5
 const { elementById } = Utils;
6
 
6
 
7
-describe('orientation', () => {
7
+describe(':ios: orientation', () => {
8
   beforeEach(async () => {
8
   beforeEach(async () => {
9
     await device.relaunchApp();
9
     await device.relaunchApp();
10
   });
10
   });

+ 8
- 8
e2e/ScreenStyle.test.js View File

35
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
35
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
36
   });
36
   });
37
 
37
 
38
-  it('hides topBar onScroll down and shows it on scroll up', async () => {
38
+  it(':ios: hides topBar onScroll down and shows it on scroll up', async () => {
39
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
39
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
40
     await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
40
     await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
41
     await elementById(testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
41
     await elementById(testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
42
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
42
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
43
-    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'fast');
43
+    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'slow');
44
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
44
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
45
-    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
45
+    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'slow');
46
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
46
     await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
47
   });
47
   });
48
 
48
 
52
     await expect(element(by.text('TeSt'))).toBeVisible();
52
     await expect(element(by.text('TeSt'))).toBeVisible();
53
   });
53
   });
54
 
54
 
55
-  it('hide Tab Bar', async () => {
55
+  it(':ios: hide Tab Bar', async () => {
56
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
56
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
57
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
57
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
58
     await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
58
     await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
59
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
59
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
60
   });
60
   });
61
 
61
 
62
-  it('show Tab Bar', async () => {
62
+  it(':ios: show Tab Bar', async () => {
63
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
63
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
64
     await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
64
     await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
65
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
65
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
67
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
67
     await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
68
   });
68
   });
69
 
69
 
70
-  it('side menu visibility - left', async () => {
70
+  it(':ios: side menu visibility - left', async () => {
71
     await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
71
     await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
72
     await elementById(testIDs.SHOW_LEFT_SIDE_MENU_BUTTON).tap();
72
     await elementById(testIDs.SHOW_LEFT_SIDE_MENU_BUTTON).tap();
73
     await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
73
     await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
75
     await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
75
     await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
76
   });
76
   });
77
 
77
 
78
-  it('side menu visibility - right', async () => {
78
+  it(':ios: side menu visibility - right', async () => {
79
     await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
79
     await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
80
     await elementById(testIDs.SHOW_RIGHT_SIDE_MENU_BUTTON).tap();
80
     await elementById(testIDs.SHOW_RIGHT_SIDE_MENU_BUTTON).tap();
81
     await expect(elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON)).toBeVisible();
81
     await expect(elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON)).toBeVisible();
83
     await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
83
     await expect(elementById(testIDs.CENTERED_TEXT_HEADER)).toBeVisible();
84
   });
84
   });
85
 
85
 
86
-  it('set right buttons', async () => {
86
+  it(':ios: set right buttons', async () => {
87
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
87
     await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
88
     await expect(elementById('buttonOne')).toBeVisible();
88
     await expect(elementById('buttonOne')).toBeVisible();
89
     await elementById('buttonOne').tap();
89
     await elementById('buttonOne').tap();

+ 1
- 2
e2e/TopLevelApi.test.js View File

18
     await expect(elementByLabel('Hello from a function!')).toBeVisible();
18
     await expect(elementByLabel('Hello from a function!')).toBeVisible();
19
   });
19
   });
20
 
20
 
21
-  it('switch to tabs with side menus', async () => {
21
+  it(':ios: switch to tabs with side menus', async () => {
22
     await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
22
     await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
23
     await elementById(testIDs.CENTERED_TEXT_HEADER).swipe('right');
23
     await elementById(testIDs.CENTERED_TEXT_HEADER).swipe('right');
24
     await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
24
     await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
28
     await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
28
     await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
29
     await expect(elementByLabel('didAppear')).toBeVisible();
29
     await expect(elementByLabel('didAppear')).toBeVisible();
30
     await elementById(testIDs.PUSH_TO_TEST_DID_DISAPPEAR_BUTTON).tap();
30
     await elementById(testIDs.PUSH_TO_TEST_DID_DISAPPEAR_BUTTON).tap();
31
-    await expect(elementByLabel('Alert')).toBeVisible();
32
     await expect(elementByLabel('didDisappear')).toBeVisible();
31
     await expect(elementByLabel('didDisappear')).toBeVisible();
33
   });
32
   });
34
 
33
 

+ 3
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabOptions.java View File

32
         if (other.badge.hasValue()) {
32
         if (other.badge.hasValue()) {
33
             badge = other.badge;
33
             badge = other.badge;
34
         }
34
         }
35
+        if (other.testId.hasValue()) {
36
+            testId = other.testId;
37
+        }
35
     }
38
     }
36
 
39
 
37
     void mergeWithDefault(final BottomTabOptions defaultOptions) {
40
     void mergeWithDefault(final BottomTabOptions defaultOptions) {

+ 1
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/Options.java View File

48
         result.topTabOptions.mergeWith(topTabOptions);
48
         result.topTabOptions.mergeWith(topTabOptions);
49
         result.bottomTabOptions.mergeWith(bottomTabOptions);
49
         result.bottomTabOptions.mergeWith(bottomTabOptions);
50
         result.bottomTabsOptions.mergeWith(bottomTabsOptions);
50
         result.bottomTabsOptions.mergeWith(bottomTabsOptions);
51
+        result.overlayOptions = overlayOptions;
51
         return result;
52
         return result;
52
     }
53
     }
53
 
54
 

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/StackLayout.java View File

18
 
18
 
19
     public StackLayout(Context context) {
19
     public StackLayout(Context context) {
20
         super(context);
20
         super(context);
21
-        topBar = new TopBar(context, this);
21
+        topBar = new TopBar(context, this, this);
22
         topBar.setId(CompatUtils.generateViewId());
22
         topBar.setId(CompatUtils.generateViewId());
23
         createLayout();
23
         createLayout();
24
         setContentDescription("StackLayout");
24
         setContentDescription("StackLayout");

+ 16
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/TopBar.java View File

24
 
24
 
25
 import java.util.ArrayList;
25
 import java.util.ArrayList;
26
 
26
 
27
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
28
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
29
+
27
 @SuppressLint("ViewConstructor")
30
 @SuppressLint("ViewConstructor")
28
 public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAwareView {
31
 public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAwareView {
29
     private final Toolbar titleBar;
32
     private final Toolbar titleBar;
31
     private final TopBarCollapseBehavior collapsingBehavior;
34
     private final TopBarCollapseBehavior collapsingBehavior;
32
     private final TopBarAnimator animator;
35
     private final TopBarAnimator animator;
33
     private TopTabs topTabs;
36
     private TopTabs topTabs;
37
+    private StackLayout parentView;
34
 
38
 
35
-    public TopBar(final Context context, TitleBarButton.OnClickListener onClickListener) {
39
+    public TopBar(final Context context, TitleBarButton.OnClickListener onClickListener, StackLayout parentView) {
36
         super(context);
40
         super(context);
37
         this.onClickListener = onClickListener;
41
         this.onClickListener = onClickListener;
38
         collapsingBehavior = new TopBarCollapseBehavior(this);
42
         collapsingBehavior = new TopBarCollapseBehavior(this);
40
         titleBar.getMenu();
44
         titleBar.getMenu();
41
         topTabs = new TopTabs(getContext());
45
         topTabs = new TopTabs(getContext());
42
         this.animator = new TopBarAnimator(this);
46
         this.animator = new TopBarAnimator(this);
47
+        this.parentView = parentView;
43
         addView(titleBar);
48
         addView(titleBar);
44
     }
49
     }
45
 
50
 
191
         }
196
         }
192
     }
197
     }
193
 
198
 
199
+    @Override
200
+    public void setVisibility(int visibility) {
201
+        super.setVisibility(visibility);
202
+        if (visibility == View.GONE) {
203
+            this.parentView.removeView(this);
204
+        } else if (visibility == View.VISIBLE && this.getParent() == null) {
205
+            this.parentView.addView(this, MATCH_PARENT, WRAP_CONTENT);
206
+        }
207
+    }
208
+
194
     public void clear() {
209
     public void clear() {
195
         titleBar.setTitle(null);
210
         titleBar.setTitle(null);
196
         titleBar.setNavigationIcon(null);
211
         titleBar.setNavigationIcon(null);

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java View File

9
 public class TopBarTest extends BaseTest {
9
 public class TopBarTest extends BaseTest {
10
     @Test
10
     @Test
11
     public void title() throws Exception {
11
     public void title() throws Exception {
12
-        TopBar topBar = new TopBar(newActivity(), buttonId -> {});
12
+        TopBar topBar = new TopBar(newActivity(), buttonId -> {}, null);
13
         assertThat(topBar.getTitle()).isEmpty();
13
         assertThat(topBar.getTitle()).isEmpty();
14
 
14
 
15
         topBar.setTitle("new title");
15
         topBar.setTitle("new title");

+ 2
- 1
playground/src/screens/ScrollViewScreen.js View File

13
         title: 'Collapse',
13
         title: 'Collapse',
14
         drawBehind: true,
14
         drawBehind: true,
15
         textColor: 'black',
15
         textColor: 'black',
16
-        textFontSize: 16
16
+        textFontSize: 16,
17
+        testID: testIDs.TOP_BAR_ELEMENT
17
       }
18
       }
18
     };
19
     };
19
   }
20
   }

+ 1
- 1
scripts/test.e2e.android.detox.js View File

8
 function run() {
8
 function run() {
9
   const conf = release ? `release` : `debug`;
9
   const conf = release ? `release` : `debug`;
10
   exec.execSync(`detox build --configuration android.emu.${conf}`);
10
   exec.execSync(`detox build --configuration android.emu.${conf}`);
11
-  exec.execSync(`detox test --configuration android.emu.${conf} ${process.env.CI ? '--cleanup' : ''}`);
11
+  exec.execSync(`detox test --configuration android.emu.${conf} ${process.env.CI ? '--cleanup' : ''}  --platform android`);
12
 }
12
 }