@@ -26,33 +26,43 @@ public class OverlayManagerTest extends BaseTest {
26
26
private OverlayManager uut ;
27
27
private SimpleViewController overlay1 ;
28
28
private SimpleViewController overlay2 ;
29
- private FrameLayout root ;
29
+ private FrameLayout contentLayout ;
30
+ private FrameLayout overlayContainer ;
30
31
31
32
@ Override
32
33
public void beforeEach () {
33
34
Activity activity = newActivity ();
34
- root = new FrameLayout (activity );
35
- root .layout (0 , 0 , 1000 , 1000 );
36
- activity .setContentView (root );
35
+ contentLayout = new FrameLayout (activity );
36
+ contentLayout .layout (0 , 0 , 1000 , 1000 );
37
+ activity .setContentView (contentLayout );
38
+ overlayContainer = new FrameLayout (activity );
37
39
38
40
ChildControllersRegistry childRegistry = new ChildControllersRegistry ();
39
41
overlay1 = spy (new SimpleViewController (activity , childRegistry , OVERLAY_ID_1 , new Options ()));
40
42
overlay2 = spy (new SimpleViewController (activity , childRegistry , OVERLAY_ID_2 , new Options ()));
41
43
uut = new OverlayManager ();
44
+ uut .setContentLayout (contentLayout );
45
+ }
46
+
47
+ @ Test
48
+ public void show_attachesOverlayContainerToContentLayout () {
49
+ uut .show (overlayContainer , overlay1 , new CommandListenerAdapter ());
50
+ assertThat (overlayContainer .getParent ()).isEqualTo (contentLayout );
51
+ uut .show (overlayContainer , overlay2 , new CommandListenerAdapter ());
42
52
}
43
53
44
54
@ Test
45
55
public void show () {
46
56
CommandListenerAdapter listener = spy (new CommandListenerAdapter ());
47
- uut .show (root , overlay1 , listener );
57
+ uut .show (overlayContainer , overlay1 , listener );
48
58
verify (listener , times (1 )).onSuccess (OVERLAY_ID_1 );
49
- assertThat (overlay1 .getView ().getParent ()).isEqualTo (root );
59
+ assertThat (overlay1 .getView ().getParent ()).isEqualTo (overlayContainer );
50
60
assertMatchParent (overlay1 .getView ());
51
61
}
52
62
53
63
@ Test
54
64
public void dismiss () {
55
- uut .show (root , overlay1 , new CommandListenerAdapter ());
65
+ uut .show (overlayContainer , overlay1 , new CommandListenerAdapter ());
56
66
assertThat (uut .size ()).isOne ();
57
67
CommandListener listener = spy (new CommandListenerAdapter ());
58
68
uut .dismiss (overlay1 .getId (), listener );
@@ -70,11 +80,22 @@ public void dismiss_rejectIfOverlayNotFound() {
70
80
71
81
@ Test
72
82
public void dismiss_onViewReturnedToFront () {
73
- uut .show (root , overlay1 , new CommandListenerAdapter ());
74
- uut .show (root , overlay2 , new CommandListenerAdapter ());
83
+ uut .show (overlayContainer , overlay1 , new CommandListenerAdapter ());
84
+ uut .show (overlayContainer , overlay2 , new CommandListenerAdapter ());
75
85
verify (overlay1 , times (0 )).onViewBroughtToFront ();
76
86
77
87
uut .dismiss (OVERLAY_ID_2 , new CommandListenerAdapter ());
78
88
verify (overlay1 , times (1 )).onViewBroughtToFront ();
79
89
}
90
+
91
+ @ Test
92
+ public void dismiss_overlayContainerIsRemovedIfAllOverlaysAreDismissed () {
93
+ uut .show (overlayContainer , overlay1 , new CommandListenerAdapter ());
94
+ uut .show (overlayContainer , overlay2 , new CommandListenerAdapter ());
95
+
96
+ uut .dismiss (OVERLAY_ID_2 , new CommandListenerAdapter ());
97
+ assertThat (overlayContainer .getParent ()).isEqualTo (contentLayout );
98
+ uut .dismiss (OVERLAY_ID_1 , new CommandListenerAdapter ());
99
+ assertThat (overlayContainer .getParent ()).isNull ();
100
+ }
80
101
}
0 commit comments