1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.documentsui.ui; 18 19 import android.content.Context; 20 import android.content.res.Configuration; 21 22 import androidx.test.InstrumentationRegistry; 23 import androidx.test.filters.SmallTest; 24 import androidx.test.runner.AndroidJUnit4; 25 26 import com.android.documentsui.tests.R; 27 28 import org.junit.Before; 29 import org.junit.Test; 30 import org.junit.runner.RunWith; 31 32 /** 33 * This class test default Dark Theme (Night Mode Disable) 34 * Verify ActionBar background, Window background, and GridItem background to meet Light style 35 */ 36 @SmallTest 37 @RunWith(AndroidJUnit4.class) 38 public class DarkThemeUiTest extends ThemeUiTestBase { 39 Context mTestContext; 40 41 @Before setUp()42 public void setUp() throws Exception { 43 super.setUp(); 44 mTestContext = InstrumentationRegistry.getContext(); 45 mTheme = getThemeByUiMode(mTargetContext, Configuration.UI_MODE_NIGHT_YES); 46 } 47 48 @Test themeNightModeEnable_actionBarColorShouldBeDark()49 public void themeNightModeEnable_actionBarColorShouldBeDark() { 50 assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorBackground, 51 mTheme.getResources().getColor(com.android.documentsui.R.color.app_background_color, 52 mTheme)); 53 } 54 55 @Test themeNightModeEnable_windowLightNavigationBarShouldBeFalse()56 public void themeNightModeEnable_windowLightNavigationBarShouldBeFalse() { 57 assertTheme(R.styleable.SystemWindow, 58 R.styleable.SystemWindow_android_windowLightNavigationBar, false); 59 } 60 61 @Test themeNightModeEnable_windowLightStatusBarShouldBeFalse()62 public void themeNightModeEnable_windowLightStatusBarShouldBeFalse() { 63 assertTheme(R.styleable.SystemWindow, 64 R.styleable.SystemWindow_android_windowLightNavigationBar, false); 65 } 66 67 @Test themeNightModeEnable_navigationBarColorShouldBeDark()68 public void themeNightModeEnable_navigationBarColorShouldBeDark() { 69 assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_navigationBarColor, 70 mTheme.getResources().getColor(android.R.color.black, mTheme)); 71 } 72 73 @Test themeNightModeEnable_windowBackgroundColorShouldBeDark()74 public void themeNightModeEnable_windowBackgroundColorShouldBeDark() { 75 assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_windowBackground, 76 mTheme.getResources().getColor(com.android.documentsui.R.color.app_background_color, 77 mTheme)); 78 } 79 80 @Test themeNightModeEnable_statusBarColorShouldBeDark()81 public void themeNightModeEnable_statusBarColorShouldBeDark() { 82 assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_statusBarColor, 83 mTheme.getResources().getColor(com.android.documentsui.R.color.app_background_color, 84 mTheme)); 85 } 86 87 @Test appCompatThemeNightModeEnable_colorPrimaryShouldBeThemeable()88 public void appCompatThemeNightModeEnable_colorPrimaryShouldBeThemeable() { 89 assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorPrimary, 90 mTheme.getResources().getColor(com.android.documentsui.R.color.primary, mTheme)); 91 } 92 }