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 static org.mockito.Mockito.mock; 20 import static org.mockito.Mockito.when; 21 22 import android.support.v14.preference.SwitchPreference; 23 import android.support.v7.preference.Preference; 24 import android.support.v7.preference.PreferenceScreen; 25 26 import com.android.settings.testutils.SettingsRobolectricTestRunner; 27 28 import org.junit.Before; 29 import org.junit.Test; 30 import org.junit.runner.RunWith; 31 import org.mockito.Mock; 32 import org.mockito.MockitoAnnotations; 33 34 @RunWith(SettingsRobolectricTestRunner.class) 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