Files
app_Settings/tests/robotests/src/com/android/settings/DeviceInfoSettingsTest.java
Fan Zhang bfb006aa32 Use framework support to customize dividers between prefs.
Bug: 33579296
Test: make RunSettingsRoboTests
Change-Id: I1bb3b82b88dc727cda05b00058e6f40564f0e5db
2017-02-27 12:47:44 -08:00

62 lines
2.0 KiB
Java

/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings;
import android.content.Context;
import android.os.UserManager;
import android.support.v7.preference.PreferenceScreen;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class DeviceInfoSettingsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@Mock
private PreferenceScreen mScreen;
@Mock
private UserManager mUserManager;
private DeviceInfoSettings mSettings;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mSettings = spy(new DeviceInfoSettings());
doReturn(mScreen).when(mSettings).getPreferenceScreen();
}
@Test
public void getPrefXml_shouldReturnDeviceInfoXml() {
assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(R.xml.device_info_settings);
}
}