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_defaultRootUri_isNotEmpty()47 public void testConfig_defaultRootUri_isNotEmpty() { 48 assertThat( 49 mTargetContext.getResources().getString(R.string.default_root_uri)).isNotEmpty(); 50 } 51 52 @Test testConfig_preferredRootPackage_isNotNull()53 public void testConfig_preferredRootPackage_isNotNull() { 54 assertThat( 55 mTargetContext.getResources().getString( 56 R.string.preferred_root_package)).isNotNull(); 57 } 58 59 @Test testConfig_trustedQuickViewerPackage_isNotNull()60 public void testConfig_trustedQuickViewerPackage_isNotNull() { 61 assertThat( 62 mTargetContext.getResources().getString( 63 R.string.trusted_quick_viewer_package)).isNotNull(); 64 } 65 66 @Test testDrawable_icEject_isVectorDrawable()67 public void testDrawable_icEject_isVectorDrawable() { 68 assertThat( 69 mTargetContext.getResources().getDrawable( 70 R.drawable.ic_eject)).isInstanceOf(Drawable.class); 71 } 72 73 @Test testDrawable_icRootDownload_isVectorDrawable()74 public void testDrawable_icRootDownload_isVectorDrawable() { 75 assertThat( 76 mTargetContext.getResources().getDrawable( 77 R.drawable.ic_root_download)).isInstanceOf(Drawable.class); 78 } 79 80 @Test testDrawable_icSdStorage_isVectorDrawable()81 public void testDrawable_icSdStorage_isVectorDrawable() { 82 assertThat( 83 mTargetContext.getResources().getDrawable( 84 R.drawable.ic_sd_storage)).isInstanceOf(Drawable.class); 85 } 86 87 @Test testDrawable_icRootListSelector_isDrawable()88 public void testDrawable_icRootListSelector_isDrawable() { 89 assertThat( 90 mTargetContext.getResources().getDrawable( 91 R.drawable.root_list_selector)).isInstanceOf(Drawable.class); 92 } 93 94 @Test testDimen_gridItemRadius_isReasonable()95 public void testDimen_gridItemRadius_isReasonable() { 96 int maxRadius = 160; 97 assertThat( 98 mTargetContext.getResources().getDimensionPixelSize( 99 R.dimen.grid_item_radius)).isLessThan(maxRadius); 100 assertThat( 101 mTargetContext.getResources().getDimensionPixelSize( 102 R.dimen.grid_item_radius)).isAtLeast(0); 103 } 104 } 105