• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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.overlay;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import android.graphics.drawable.Drawable;
22 
23 import androidx.test.filters.SmallTest;
24 import androidx.test.runner.AndroidJUnit4;
25 
26 import com.android.documentsui.R;
27 import com.android.documentsui.ui.ThemeUiTestBase;
28 
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 
33 /**
34  * This class verify overlayable resource defined in RRO package
35  * Verify Drawable, Dimen, Config to guarantee run time get resource without NotFound exception
36  */
37 @SmallTest
38 @RunWith(AndroidJUnit4.class)
39 public class OverlayableTest extends ThemeUiTestBase {
40 
41     @Before
setUp()42     public void setUp() throws Exception {
43         super.setUp();
44     }
45 
46     @Test
testConfig_isLauncherEnable_isNotNull()47     public void testConfig_isLauncherEnable_isNotNull() {
48         assertThat(
49                 mTargetContext.getResources().getBoolean(R.bool.is_launcher_enabled)).isNotNull();
50     }
51 
52     @Test
testConfig_defaultRootUri_isNotEmpty()53     public void testConfig_defaultRootUri_isNotEmpty() {
54         assertThat(
55                 mTargetContext.getResources().getString(R.string.default_root_uri)).isNotEmpty();
56     }
57 
58     @Test
testConfig_preferredRootPackage_isNotNull()59     public void testConfig_preferredRootPackage_isNotNull() {
60         assertThat(
61                 mTargetContext.getResources().getString(
62                         R.string.preferred_root_package)).isNotNull();
63     }
64 
65     @Test
testConfig_trustedQuickViewerPackage_isNotNull()66     public void testConfig_trustedQuickViewerPackage_isNotNull() {
67         assertThat(
68                 mTargetContext.getResources().getString(
69                         R.string.trusted_quick_viewer_package)).isNotNull();
70     }
71 
72     @Test
testDrawable_icEject_isVectorDrawable()73     public void testDrawable_icEject_isVectorDrawable() {
74         assertThat(
75                 mTargetContext.getResources().getDrawable(
76                         R.drawable.ic_eject)).isInstanceOf(Drawable.class);
77     }
78 
79     @Test
testDrawable_icRootDownload_isVectorDrawable()80     public void testDrawable_icRootDownload_isVectorDrawable() {
81         assertThat(
82                 mTargetContext.getResources().getDrawable(
83                         R.drawable.ic_root_download)).isInstanceOf(Drawable.class);
84     }
85 
86     @Test
testDrawable_icSdStorage_isVectorDrawable()87     public void testDrawable_icSdStorage_isVectorDrawable() {
88         assertThat(
89                 mTargetContext.getResources().getDrawable(
90                         R.drawable.ic_sd_storage)).isInstanceOf(Drawable.class);
91     }
92 
93     @Test
testDrawable_icRootListSelector_isDrawable()94     public void testDrawable_icRootListSelector_isDrawable() {
95         assertThat(
96                 mTargetContext.getResources().getDrawable(
97                         R.drawable.root_list_selector)).isInstanceOf(Drawable.class);
98     }
99 
100     @Test
testDimen_gridItemRadius_isReasonable()101     public void testDimen_gridItemRadius_isReasonable() {
102         int maxRadius = 160;
103         assertThat(
104                 mTargetContext.getResources().getDimensionPixelSize(
105                         R.dimen.grid_item_radius)).isLessThan(maxRadius);
106         assertThat(
107                 mTargetContext.getResources().getDimensionPixelSize(
108                         R.dimen.grid_item_radius)).isAtLeast(0);
109     }
110 }
111