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.settings; 18 19 import android.support.v14.preference.SwitchPreference; 20 import android.support.v7.preference.Preference; 21 import android.support.v7.preference.PreferenceScreen; 22 23 import org.junit.Before; 24 import org.junit.Test; 25 import org.junit.runner.RunWith; 26 import org.mockito.Mock; 27 import org.mockito.MockitoAnnotations; 28 import org.robolectric.annotation.Config; 29 30 import static org.mockito.Mockito.mock; 31 import static org.mockito.Mockito.when; 32 33 @RunWith(SettingsRobolectricTestRunner.class) 34 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) 35 public class PrivacySettingsTest { 36 37 @Mock 38 private PreferenceScreen mScreen; 39 private PrivacySettings mSettings; 40 41 @Before setUp()42 public void setUp() { 43 MockitoAnnotations.initMocks(this); 44 when(mScreen.findPreference(PrivacySettings.BACKUP_DATA)) 45 .thenReturn(mock(Preference.class)); 46 when(mScreen.findPreference(PrivacySettings.CONFIGURE_ACCOUNT)) 47 .thenReturn(mock(Preference.class)); 48 when(mScreen.findPreference(PrivacySettings.DATA_MANAGEMENT)) 49 .thenReturn(mock(Preference.class)); 50 when(mScreen.findPreference(PrivacySettings.AUTO_RESTORE)) 51 .thenReturn(mock(SwitchPreference.class)); 52 mSettings = new PrivacySettings(); 53 } 54 55 @Test testSetPreference_noCrash()56 public void testSetPreference_noCrash() { 57 mSettings.setPreferenceReferences(mScreen); 58 } 59 60 } 61