• 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.security;
18 
19 
20 import android.content.DialogInterface;
21 
22 import com.android.settings.testutils.SettingsRobolectricTestRunner;
23 import com.android.settings.TestConfig;
24 import com.android.settings.testutils.shadow.ShadowEventLogWriter;
25 
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.robolectric.Robolectric;
29 import org.robolectric.annotation.Config;
30 import org.robolectric.util.FragmentController;
31 
32 import static org.mockito.Mockito.doNothing;
33 import static org.mockito.Mockito.spy;
34 import static org.mockito.Mockito.verify;
35 
36 @RunWith(SettingsRobolectricTestRunner.class)
37 @Config(
38     manifest = TestConfig.MANIFEST_PATH,
39     sdk = TestConfig.SDK_VERSION,
40     shadows = ShadowEventLogWriter.class
41 )
42 public class ConfigureKeyGuardDialogTest {
43 
44     @Test
displayDialog_clickPositiveButton_launchSetNewPassword()45     public void displayDialog_clickPositiveButton_launchSetNewPassword() {
46         final FragmentController<ConfigureKeyGuardDialog> fragmentController =
47                 Robolectric.buildFragment(ConfigureKeyGuardDialog.class);
48         final ConfigureKeyGuardDialog fragment = spy(fragmentController.get());
49         doNothing().when(fragment).startPasswordSetup();
50         fragmentController.attach().create().start().resume();
51         fragment.onClick(null /* dialog */, DialogInterface.BUTTON_POSITIVE);
52         fragment.onDismiss(null /* dialog */);
53 
54         verify(fragment).startPasswordSetup();
55     }
56 }
57