OSDN Git Service

Zen Condition text and primary click changes
[android-x86/packages-apps-Settings.git] / tests / robotests / src / com / android / settings / connecteddevice / usb / UsbModeChooserActivityTest.java
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 package com.android.settings.connecteddevice.usb;
17
18 import static com.google.common.truth.Truth.assertThat;
19 import static org.mockito.Matchers.anyInt;
20 import static org.mockito.Mockito.never;
21 import static org.mockito.Mockito.verify;
22
23 import android.widget.TextView;
24 import com.android.settings.R;
25 import com.android.settings.connecteddevice.usb.UsbModeChooserActivity;
26 import com.android.settings.testutils.SettingsRobolectricTestRunner;
27 import com.android.settings.TestConfig;
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 import org.robolectric.annotation.Config;
34
35 @RunWith(SettingsRobolectricTestRunner.class)
36 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
37 public class UsbModeChooserActivityTest {
38
39     @Mock
40     private TextView mTextView;
41
42     @Before
43     public void setUp() {
44         MockitoAnnotations.initMocks(this);
45     }
46
47     @Test
48     public void updateSummary_chargeDevice_shouldNotSetSummary() {
49         UsbModeChooserActivity.updateSummary(mTextView, UsbModeChooserActivity.DEFAULT_MODES[0]);
50         verify(mTextView, never()).setText(anyInt());
51     }
52
53     @Test
54     public void updateSummary_supplyPower_shouldSetSummary() {
55         UsbModeChooserActivity.updateSummary(mTextView, UsbModeChooserActivity.DEFAULT_MODES[1]);
56         verify(mTextView).setText(R.string.usb_use_power_only_desc);
57     }
58
59     @Test
60     public void updateSummary_transferFiles_shouldNotSetSummary() {
61         UsbModeChooserActivity.updateSummary(mTextView, UsbModeChooserActivity.DEFAULT_MODES[2]);
62         verify(mTextView, never()).setText(anyInt());
63     }
64
65     @Test
66     public void updateSummary_transferPhoto_shouldNotSetSummary() {
67         UsbModeChooserActivity.updateSummary(mTextView, UsbModeChooserActivity.DEFAULT_MODES[3]);
68         verify(mTextView, never()).setText(anyInt());
69     }
70
71     @Test
72     public void updateSummary_MIDI_shouldNotSetSummary() {
73         UsbModeChooserActivity.updateSummary(mTextView, UsbModeChooserActivity.DEFAULT_MODES[4]);
74         verify(mTextView, never()).setText(anyInt());
75     }
76
77     @Test
78     public void getTitle_shouldReturnCorrectTitle() {
79         assertThat(UsbModeChooserActivity.getTitle(UsbModeChooserActivity.DEFAULT_MODES[0]))
80                 .isEqualTo(R.string.usb_use_charging_only);
81
82         assertThat(UsbModeChooserActivity.getTitle(UsbModeChooserActivity.DEFAULT_MODES[1]))
83                 .isEqualTo(R.string.usb_use_power_only);
84
85         assertThat(UsbModeChooserActivity.getTitle(UsbModeChooserActivity.DEFAULT_MODES[2]))
86                 .isEqualTo(R.string.usb_use_file_transfers);
87
88         assertThat(UsbModeChooserActivity.getTitle(UsbModeChooserActivity.DEFAULT_MODES[3]))
89                 .isEqualTo(R.string.usb_use_photo_transfers);
90
91         assertThat(UsbModeChooserActivity.getTitle(UsbModeChooserActivity.DEFAULT_MODES[4]))
92                 .isEqualTo(R.string.usb_use_MIDI);
93     }
94
95 }