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 static org.junit.Assume.assumeFalse;
20 
21 import android.content.res.Configuration;
22 import android.graphics.Color;
23 
24 import androidx.test.filters.SmallTest;
25 import androidx.test.runner.AndroidJUnit4;
26 
27 import com.android.documentsui.tests.R;
28 import com.android.documentsui.util.VersionUtils;
29 
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 
34 /**
35  * This class test default Light Theme (Night Mode Disable)
36  * Verify ActionBar background, Window background, and GridItem background to meet Light style
37  */
38 @SmallTest
39 @RunWith(AndroidJUnit4.class)
40 public class ThemeUiTest extends ThemeUiTestBase {
41 
42     @Before
setUp()43     public void setUp() throws Exception {
44         super.setUp();
45         mTheme = getThemeByUiMode(mTargetContext, Configuration.UI_MODE_NIGHT_NO);
46     }
47 
48     @Test
themeNightModeDisable_actionBarColorShouldBeLight()49     public void themeNightModeDisable_actionBarColorShouldBeLight() throws Exception {
50         assumeFalse(VersionUtils.isAtLeastS()); // Disable for S dynamic color
51         assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorBackground,
52                 Color.WHITE);
53     }
54 
55     @Test
themeNightModeDisable_windowLightNavigationBarShouldBeTrue()56     public void themeNightModeDisable_windowLightNavigationBarShouldBeTrue() {
57         assertTheme(R.styleable.SystemWindow,
58                 R.styleable.SystemWindow_android_windowLightNavigationBar, true);
59     }
60 
61     @Test
themeNightModeDisable_windowLightStatusBarShouldBeTrue()62     public void themeNightModeDisable_windowLightStatusBarShouldBeTrue() {
63         assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_windowLightStatusBar,
64                 true);
65     }
66 
67     @Test
themeNightModeDisable_navigationBarColorShouldBeLight()68     public void themeNightModeDisable_navigationBarColorShouldBeLight() throws Exception {
69         assumeFalse(VersionUtils.isAtLeastS()); // Disable for S dynamic color
70         assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_navigationBarColor,
71                 Color.WHITE);
72     }
73 
74     @Test
themeNightModeDisable_windowBackgroundColorShouldBeLight()75     public void themeNightModeDisable_windowBackgroundColorShouldBeLight() throws Exception {
76         assumeFalse(VersionUtils.isAtLeastS()); // Disable for S dynamic color
77         assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_windowBackground,
78                 Color.WHITE);
79     }
80 
81     @Test
themeNightModeDisable_statusBarColorShouldBeLight()82     public void themeNightModeDisable_statusBarColorShouldBeLight() throws Exception {
83         assumeFalse(VersionUtils.isAtLeastS()); // Disable for S dynamic color
84         assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_statusBarColor,
85                 Color.WHITE);
86     }
87 
88     @Test
appCompatThemeNightModeDisable_colorPrimaryShouldBeThemeable()89     public void appCompatThemeNightModeDisable_colorPrimaryShouldBeThemeable() throws Exception {
90         assumeFalse(VersionUtils.isAtLeastS()); // Disable for S dynamic color
91         assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorPrimary,
92                 mTheme.getResources().getColor(com.android.documentsui.R.color.primary, mTheme));
93     }
94 }