Home | History | Annotate | Download | only in drawer
      1 /*
      2  * Copyright (C) 2016 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.settingslib.drawer;
     18 
     19 import android.util.ArraySet;
     20 
     21 import com.android.settingslib.TestConfig;
     22 
     23 import org.junit.Test;
     24 import org.junit.runner.RunWith;
     25 import org.robolectric.RobolectricTestRunner;
     26 import org.robolectric.annotation.Config;
     27 
     28 import java.util.Set;
     29 
     30 import static com.google.common.truth.Truth.assertThat;
     31 
     32 @RunWith(RobolectricTestRunner.class)
     33 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
     34 public class CategoryKeyTest {
     35 
     36     @Test
     37     public void testKeyCompatMap_allOldCategoryKeyAreMapped() {
     38         assertThat(CategoryKey.KEY_COMPAT_MAP.size()).isEqualTo(4);
     39     }
     40 
     41     @Test
     42     public void removingAnyKeyBreaksCompiler() {
     43         // The keys in this test can be added but cannot be removed. Removing any key will remove
     44         // categories from Settings app. Bad things will happen.
     45         final Set<String> allKeys = new ArraySet<>();
     46 
     47         // DO NOT REMOVE ANYTHING BELOW
     48         allKeys.add(CategoryKey.CATEGORY_HOMEPAGE);
     49         allKeys.add(CategoryKey.CATEGORY_DEVICE);
     50         allKeys.add(CategoryKey.CATEGORY_APPS);
     51         allKeys.add(CategoryKey.CATEGORY_APPS_DEFAULT);
     52         allKeys.add(CategoryKey.CATEGORY_BATTERY);
     53         allKeys.add(CategoryKey.CATEGORY_DISPLAY);
     54         allKeys.add(CategoryKey.CATEGORY_SOUND);
     55         allKeys.add(CategoryKey.CATEGORY_STORAGE);
     56         allKeys.add(CategoryKey.CATEGORY_SECURITY);
     57         allKeys.add(CategoryKey.CATEGORY_SECURITY_LOCKSCREEN);
     58         allKeys.add(CategoryKey.CATEGORY_ACCOUNT);
     59         allKeys.add(CategoryKey.CATEGORY_ACCOUNT_DETAIL);
     60         allKeys.add(CategoryKey.CATEGORY_SYSTEM);
     61         allKeys.add(CategoryKey.CATEGORY_SYSTEM_LANGUAGE);
     62         allKeys.add(CategoryKey.CATEGORY_SYSTEM_DEVELOPMENT);
     63         // DO NOT REMOVE ANYTHING ABOVE
     64 
     65         assertThat(allKeys.size()).isEqualTo(15);
     66     }
     67 
     68 }
     69