• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.Context;
22 import android.content.res.Configuration;
23 
24 import androidx.test.InstrumentationRegistry;
25 import androidx.test.filters.SmallTest;
26 import androidx.test.runner.AndroidJUnit4;
27 
28 import com.android.documentsui.tests.R;
29 import com.android.documentsui.util.VersionUtils;
30 
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 
35 /**
36  * This class test default Dark Theme (Night Mode Disable)
37  * Verify ActionBar background, Window background, and GridItem background to meet Light style
38  */
39 @SmallTest
40 @RunWith(AndroidJUnit4.class)
41 public class DarkThemeUiTest extends ThemeUiTestBase {
42     Context mTestContext;
43 
44     @Before
setUp()45     public void setUp() throws Exception {
46         super.setUp();
47         mTestContext = InstrumentationRegistry.getContext();
48         mTheme = getThemeByUiMode(mTargetContext, Configuration.UI_MODE_NIGHT_YES);
49     }
50 
51     @Test
themeNightModeEnable_actionBarColorShouldBeDark()52     public void themeNightModeEnable_actionBarColorShouldBeDark() throws Exception {
53         assumeFalse(VersionUtils.isAtLeastS()); // Disable for S dynamic color
54         assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorBackground,
55                 mTheme.getResources().getColor(com.android.documentsui.R.color.app_background_color,
56                         mTheme));
57     }
58 
59     @Test
themeNightModeEnable_windowLightNavigationBarShouldBeFalse()60     public void themeNightModeEnable_windowLightNavigationBarShouldBeFalse() {
61         assertTheme(R.styleable.SystemWindow,
62                 R.styleable.SystemWindow_android_windowLightNavigationBar, false);
63     }
64 
65     @Test
themeNightModeEnable_windowLightStatusBarShouldBeFalse()66     public void themeNightModeEnable_windowLightStatusBarShouldBeFalse() {
67         assertTheme(R.styleable.SystemWindow,
68                 R.styleable.SystemWindow_android_windowLightNavigationBar, false);
69     }
70 
71     @Test
themeNightModeEnable_navigationBarColorShouldBeDark()72     public void themeNightModeEnable_navigationBarColorShouldBeDark() {
73         assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_navigationBarColor,
74                 mTheme.getResources().getColor(android.R.color.black, mTheme));
75     }
76 
77     @Test
themeNightModeEnable_windowBackgroundColorShouldBeDark()78     public void themeNightModeEnable_windowBackgroundColorShouldBeDark() throws Exception {
79         assumeFalse(VersionUtils.isAtLeastS()); // Disable for S dynamic color
80         assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_windowBackground,
81                 mTheme.getResources().getColor(com.android.documentsui.R.color.app_background_color,
82                         mTheme));
83     }
84 
85     @Test
themeNightModeEnable_statusBarColorShouldBeDark()86     public void themeNightModeEnable_statusBarColorShouldBeDark() throws Exception {
87         assumeFalse(VersionUtils.isAtLeastS()); // Disable for S dynamic color
88         assertTheme(R.styleable.SystemWindow, R.styleable.SystemWindow_android_statusBarColor,
89                 mTheme.getResources().getColor(com.android.documentsui.R.color.app_background_color,
90                         mTheme));
91     }
92 
93     @Test
appCompatThemeNightModeEnable_colorPrimaryShouldBeThemeable()94     public void appCompatThemeNightModeEnable_colorPrimaryShouldBeThemeable() throws Exception {
95         assumeFalse(VersionUtils.isAtLeastS()); // Disable for S dynamic color
96         assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorPrimary,
97                 mTheme.getResources().getColor(com.android.documentsui.R.color.primary, mTheme));
98     }
99 }