5package io.flutter.plugin.platform;
7import static io.flutter.Build.API_LEVELS;
8import static org.mockito.Mockito.mock;
9import static org.mockito.Mockito.verify;
10import static org.mockito.Mockito.verifyNoInteractions;
12import android.annotation.TargetApi;
15import android.view.WindowManager;
16import androidx.test.ext.junit.runners.AndroidJUnit4;
17import java.util.concurrent.Executor;
18import java.util.function.Consumer;
20import org.junit.runner.RunWith;
21import org.robolectric.annotation.Config;
24@RunWith(AndroidJUnit4.class)
25@TargetApi(API_LEVELS.API_28)
29 public
void windowManagerHandler_passesCorrectlyToFakeWindowViewGroup() {
31 WindowManager mockWindowManager = mock(WindowManager.class);
35 View mockView = mock(View.class);
36 ViewGroup.LayoutParams mockLayoutParams = mock(ViewGroup.LayoutParams.class);
43 verify(mockView).clearAnimation();
44 verify(mockSingleViewFakeWindowViewGroup).removeView(mockView);
45 verifyNoInteractions(mockWindowManager);
48 windowManagerHandler.
addView(mockView, mockLayoutParams);
49 verify(mockSingleViewFakeWindowViewGroup).addView(mockView, mockLayoutParams);
50 verifyNoInteractions(mockWindowManager);
54 verify(mockSingleViewFakeWindowViewGroup).updateViewLayout(mockView, mockLayoutParams);
55 verifyNoInteractions(mockWindowManager);
59 verify(mockSingleViewFakeWindowViewGroup).removeView(mockView);
60 verifyNoInteractions(mockWindowManager);
65 public
void windowManagerHandler_logAndReturnEarly_whenFakeWindowViewGroupIsNull() {
67 WindowManager mockWindowManager = mock(WindowManager.class);
69 View mockView = mock(View.class);
70 ViewGroup.LayoutParams mockLayoutParams = mock(ViewGroup.LayoutParams.class);
76 verifyNoInteractions(mockView);
77 verifyNoInteractions(mockWindowManager);
80 windowManagerHandler.
addView(mockView, mockLayoutParams);
81 verifyNoInteractions(mockWindowManager);
85 verifyNoInteractions(mockWindowManager);
89 verifyNoInteractions(mockWindowManager);
97 @SuppressWarnings(
"deprecation")
98 public
void windowManagerHandler_forwardsAllOtherCallsToDelegate() {
100 WindowManager mockWindowManager = mock(WindowManager.class);
108 Executor mockExecutor = mock(Executor.class);
109 @SuppressWarnings(
"Unchecked cast")
110 Consumer<Boolean> mockListener = (Consumer<Boolean>) mock(Consumer.class);
113 verify(mockWindowManager).getDefaultDisplay();
116 verify(mockWindowManager).getCurrentWindowMetrics();
119 verify(mockWindowManager).getMaximumWindowMetrics();
122 verify(mockWindowManager).isCrossWindowBlurEnabled();
125 verify(mockWindowManager).addCrossWindowBlurEnabledListener(mockListener);
128 verify(mockWindowManager).addCrossWindowBlurEnabledListener(mockExecutor, mockListener);
131 verify(mockWindowManager).removeCrossWindowBlurEnabledListener(mockListener);