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