1 /* 2 * Copyright (C) 2017 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.deviceinfo; 18 19 import android.app.Activity; 20 import android.os.SystemProperties; 21 import android.view.View; 22 23 import com.android.settings.R; 24 import com.android.settings.SettingsRobolectricTestRunner; 25 import com.android.settings.TestConfig; 26 27 import org.junit.Before; 28 import org.junit.Test; 29 import org.junit.runner.RunWith; 30 import org.robolectric.Robolectric; 31 import org.robolectric.annotation.Config; 32 33 import static org.mockito.Matchers.any; 34 import static org.mockito.Matchers.anyString; 35 import static org.mockito.Matchers.eq; 36 import static org.mockito.Mockito.spy; 37 import static org.mockito.Mockito.verify; 38 39 @RunWith(SettingsRobolectricTestRunner.class) 40 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) 41 public class HardwareInfoDialogFragmentTest { 42 43 private Activity mActivity; 44 45 @Before 46 public void setUp() { 47 mActivity = Robolectric.setupActivity(Activity.class); 48 } 49 50 @Test 51 public void display_shouldShowHardwareRevision() { 52 final String TEST_HARDWARE_REV = "123"; 53 SystemProperties.set("ro.boot.hardware.revision", TEST_HARDWARE_REV); 54 55 final HardwareInfoDialogFragment fragment = spy(HardwareInfoDialogFragment.newInstance()); 56 fragment.show(mActivity.getFragmentManager(), HardwareInfoDialogFragment.TAG); 57 58 verify(fragment).setText( 59 any(View.class), eq(R.id.model_label), eq(R.id.model_value), 60 anyString()); 61 62 verify(fragment).setText( 63 any(View.class), eq(R.id.hardware_rev_label), eq(R.id.hardware_rev_value), 64 anyString()); 65 } 66 } 67