• 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 package com.android.settingslib.drawer;
17 
18 import org.junit.Before;
19 import org.junit.Rule;
20 import org.junit.Test;
21 import org.junit.rules.ExpectedException;
22 import org.junit.runner.RunWith;
23 import org.robolectric.RobolectricTestRunner;
24 
25 @RunWith(RobolectricTestRunner.class)
26 public class PrimarySwitchControllerTest {
27 
28     @Rule
29     public final ExpectedException thrown = ExpectedException.none();
30 
31     private PrimarySwitchController mController;
32 
33     @Before
setUp()34     public void setUp() {
35         mController = new TestPrimarySwitchController("123");
36     }
37 
38     @Test
getMetaData_shouldThrowUnsupportedOperationException()39     public void getMetaData_shouldThrowUnsupportedOperationException() {
40         thrown.expect(UnsupportedOperationException.class);
41 
42         mController.getMetaData();
43     }
44 
45     @Test
getBundle_shouldThrowUnsupportedOperationException()46     public void getBundle_shouldThrowUnsupportedOperationException() {
47         thrown.expect(UnsupportedOperationException.class);
48 
49         mController.getBundle();
50     }
51 
52     static class TestPrimarySwitchController extends PrimarySwitchController {
53 
54         private String mKey;
55 
TestPrimarySwitchController(String key)56         TestPrimarySwitchController(String key) {
57             mKey = key;
58         }
59 
60         @Override
getSwitchKey()61         public String getSwitchKey() {
62             return mKey;
63         }
64 
65         @Override
isChecked()66         protected boolean isChecked() {
67             return true;
68         }
69 
70         @Override
onCheckedChanged(boolean checked)71         protected boolean onCheckedChanged(boolean checked) {
72             return true;
73         }
74 
75         @Override
getErrorMessage(boolean attemptedChecked)76         protected String getErrorMessage(boolean attemptedChecked) {
77             return null;
78         }
79     }
80 }
81