|
@@ -1,6 +1,7 @@
|
1
|
1
|
package com.reactnativenavigation.viewcontrollers.overlay;
|
2
|
2
|
|
3
|
3
|
import android.app.Activity;
|
|
4
|
+import android.view.View;
|
4
|
5
|
import android.widget.FrameLayout;
|
5
|
6
|
|
6
|
7
|
import com.reactnativenavigation.BaseTest;
|
|
@@ -36,6 +37,7 @@ public class OverlayManagerTest extends BaseTest {
|
36
|
37
|
contentLayout.layout(0, 0, 1000, 1000);
|
37
|
38
|
activity.setContentView(contentLayout);
|
38
|
39
|
overlayContainer = new FrameLayout(activity);
|
|
40
|
+ contentLayout.addView(overlayContainer);
|
39
|
41
|
|
40
|
42
|
ChildControllersRegistry childRegistry = new ChildControllersRegistry();
|
41
|
43
|
overlay1 = spy(new SimpleViewController(activity, childRegistry, OVERLAY_ID_1, new Options()));
|
|
@@ -45,15 +47,15 @@ public class OverlayManagerTest extends BaseTest {
|
45
|
47
|
|
46
|
48
|
@Test
|
47
|
49
|
public void show_attachesOverlayContainerToContentLayout() {
|
48
|
|
- uut.show(contentLayout, overlayContainer, overlay1, new CommandListenerAdapter());
|
|
50
|
+ uut.show(overlayContainer, overlay1, new CommandListenerAdapter());
|
49
|
51
|
assertThat(overlayContainer.getParent()).isEqualTo(contentLayout);
|
50
|
|
- uut.show(contentLayout, overlayContainer, overlay2, new CommandListenerAdapter());
|
|
52
|
+ uut.show(overlayContainer, overlay2, new CommandListenerAdapter());
|
51
|
53
|
}
|
52
|
54
|
|
53
|
55
|
@Test
|
54
|
56
|
public void show() {
|
55
|
57
|
CommandListenerAdapter listener = spy(new CommandListenerAdapter());
|
56
|
|
- uut.show(contentLayout, overlayContainer, overlay1, listener);
|
|
58
|
+ uut.show(overlayContainer, overlay1, listener);
|
57
|
59
|
verify(listener, times(1)).onSuccess(OVERLAY_ID_1);
|
58
|
60
|
assertThat(overlay1.getView().getParent()).isEqualTo(overlayContainer);
|
59
|
61
|
assertMatchParent(overlay1.getView());
|
|
@@ -61,10 +63,10 @@ public class OverlayManagerTest extends BaseTest {
|
61
|
63
|
|
62
|
64
|
@Test
|
63
|
65
|
public void dismiss() {
|
64
|
|
- uut.show(contentLayout, overlayContainer, overlay1, new CommandListenerAdapter());
|
|
66
|
+ uut.show(overlayContainer, overlay1, new CommandListenerAdapter());
|
65
|
67
|
assertThat(uut.size()).isOne();
|
66
|
68
|
CommandListener listener = spy(new CommandListenerAdapter());
|
67
|
|
- uut.dismiss(overlay1.getId(), listener);
|
|
69
|
+ uut.dismiss(overlayContainer, overlay1.getId(), listener);
|
68
|
70
|
assertThat(uut.size()).isZero();
|
69
|
71
|
verify(listener, times(1)).onSuccess(OVERLAY_ID_1);
|
70
|
72
|
verify(overlay1, times(1)).destroy();
|
|
@@ -73,28 +75,29 @@ public class OverlayManagerTest extends BaseTest {
|
73
|
75
|
@Test
|
74
|
76
|
public void dismiss_rejectIfOverlayNotFound() {
|
75
|
77
|
CommandListener listener = spy(new CommandListenerAdapter());
|
76
|
|
- uut.dismiss(overlay1.getId(), listener);
|
|
78
|
+ uut.dismiss(overlayContainer, overlay1.getId(), listener);
|
77
|
79
|
verify(listener, times(1)).onError(any());
|
78
|
80
|
}
|
79
|
81
|
|
80
|
82
|
@Test
|
81
|
83
|
public void dismiss_onViewReturnedToFront() {
|
82
|
|
- uut.show(contentLayout, overlayContainer, overlay1, new CommandListenerAdapter());
|
83
|
|
- uut.show(contentLayout, overlayContainer, overlay2, new CommandListenerAdapter());
|
|
84
|
+ uut.show(overlayContainer, overlay1, new CommandListenerAdapter());
|
|
85
|
+ uut.show(overlayContainer, overlay2, new CommandListenerAdapter());
|
84
|
86
|
verify(overlay1, times(0)).onViewBroughtToFront();
|
85
|
87
|
|
86
|
|
- uut.dismiss(OVERLAY_ID_2, new CommandListenerAdapter());
|
|
88
|
+ uut.dismiss(overlayContainer, OVERLAY_ID_2, new CommandListenerAdapter());
|
87
|
89
|
verify(overlay1, times(1)).onViewBroughtToFront();
|
88
|
90
|
}
|
89
|
91
|
|
90
|
92
|
@Test
|
91
|
|
- public void dismiss_overlayContainerIsRemovedIfAllOverlaysAreDismissed() {
|
92
|
|
- uut.show(contentLayout, overlayContainer, overlay1, new CommandListenerAdapter());
|
93
|
|
- uut.show(contentLayout, overlayContainer, overlay2, new CommandListenerAdapter());
|
|
93
|
+ public void dismiss_overlayContainerIsHiddenIfAllOverlaysAreDismissed() {
|
|
94
|
+ uut.show(overlayContainer, overlay1, new CommandListenerAdapter());
|
|
95
|
+ uut.show(overlayContainer, overlay2, new CommandListenerAdapter());
|
94
|
96
|
|
95
|
|
- uut.dismiss(OVERLAY_ID_2, new CommandListenerAdapter());
|
|
97
|
+ uut.dismiss(overlayContainer, OVERLAY_ID_2, new CommandListenerAdapter());
|
|
98
|
+ assertThat(overlayContainer.getVisibility()).isEqualTo(View.VISIBLE);
|
96
|
99
|
assertThat(overlayContainer.getParent()).isEqualTo(contentLayout);
|
97
|
|
- uut.dismiss(OVERLAY_ID_1, new CommandListenerAdapter());
|
98
|
|
- assertThat(overlayContainer.getParent()).isNull();
|
|
100
|
+ uut.dismiss(overlayContainer, OVERLAY_ID_1, new CommandListenerAdapter());
|
|
101
|
+ assertThat(overlayContainer.getVisibility()).isEqualTo(View.GONE);
|
99
|
102
|
}
|
100
|
103
|
}
|