Skip to content

Commit

Permalink
Undo Deletion in flutter#31092 (flutter#31661)
Browse files Browse the repository at this point in the history
  • Loading branch information
camsim99 authored Feb 28, 2022
1 parent 1a919ed commit 1e5b26b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ public void updateSystemUiOverlays() {
}
}
}

if (currentTheme != null) {
setSystemChromeSystemUIOverlayStyle(currentTheme);
}
}

private void restoreSystemChromeSystemUIOverlays() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
Expand Down Expand Up @@ -505,6 +507,43 @@ public void showSystemOverlays() {
verify(fakeWindowInsetsController).show(WindowInsetsCompat.Type.navigationBars());
}

@Config(sdk = 30)
@Test
public void verifyUpdateSystemUiOverlaysAppliesCurrentTheme() {
View fakeDecorView = mock(View.class);
Window fakeWindow = mock(Window.class);
when(fakeWindow.getDecorView()).thenReturn(fakeDecorView);
Activity fakeActivity = mock(Activity.class);
when(fakeActivity.getWindow()).thenReturn(fakeWindow);
PlatformChannel fakePlatformChannel = mock(PlatformChannel.class);
PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel);
WindowInsetsController fakeWindowInsetsController = mock(WindowInsetsController.class);
when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController);

// Style that requires usage of all system bar APIs used in PlatformPlugin to update overlay
// style
SystemChromeStyle testStyle =
new SystemChromeStyle(
0XFF000000, Brightness.LIGHT, true, 0XFFC70039, Brightness.LIGHT, 0XFF006DB3, true);

platformPlugin.updateSystemUiOverlays();

verify(fakeWindow, never()).setStatusBarColor(anyInt());
verify(fakeWindow, never()).setNavigationBarColor(anyInt());
verify(fakeWindow, never()).setNavigationBarDividerColor(anyInt());
verify(fakeWindow, never()).setStatusBarContrastEnforced(anyBoolean());
verify(fakeWindow, never()).setNavigationBarContrastEnforced(anyBoolean());

platformPlugin.mPlatformMessageHandler.setSystemUiOverlayStyle(testStyle);
platformPlugin.updateSystemUiOverlays();

verify(fakeWindow, times(2)).setStatusBarColor(0xFF000000);
verify(fakeWindow, times(2)).setNavigationBarColor(0XFFC70039);
verify(fakeWindow, times(2)).setNavigationBarDividerColor(0XFF006DB3);
verify(fakeWindow, times(2)).setStatusBarContrastEnforced(true);
verify(fakeWindow, times(2)).setNavigationBarContrastEnforced(true);
}

@Config(sdk = 28)
@Test
public void doNotEnableEdgeToEdgeOnOlderSdk() {
Expand Down

0 comments on commit 1e5b26b

Please sign in to comment.