• 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.fingerprint;
18 
19 
20 import android.app.Dialog;
21 import android.hardware.fingerprint.Fingerprint;
22 
23 import com.android.settings.TestConfig;
24 import com.android.settings.fingerprint.FingerprintSettings.FingerprintSettingsFragment;
25 import com.android.settings.fingerprint.FingerprintSettings.FingerprintSettingsFragment
26         .DeleteFingerprintDialog;
27 import com.android.settings.testutils.SettingsRobolectricTestRunner;
28 import com.android.settings.testutils.shadow.ShadowEventLogWriter;
29 
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.Mock;
34 import org.mockito.MockitoAnnotations;
35 import org.robolectric.annotation.Config;
36 import org.robolectric.util.FragmentTestUtil;
37 
38 import static org.mockito.Mockito.never;
39 import static org.mockito.Mockito.verify;
40 
41 @RunWith(SettingsRobolectricTestRunner.class)
42 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
43         shadows = {
44                 ShadowEventLogWriter.class
45         })
46 public class DeleteFingerprintDialogTest {
47 
48     @Mock
49     private FingerprintSettingsFragment mTarget;
50     @Mock
51     private Fingerprint mFingerprint;
52     private DeleteFingerprintDialog mFragment;
53 
54 
55     @Before
setUp()56     public void setUp() {
57         MockitoAnnotations.initMocks(this);
58         mFragment = DeleteFingerprintDialog.newInstance(mFingerprint, mTarget);
59     }
60 
61     @Test
launchDialog_clickPositive_shouldDeleteFingerprint()62     public void launchDialog_clickPositive_shouldDeleteFingerprint() {
63         FragmentTestUtil.startFragment(mFragment);
64 
65         mFragment.onClick(mFragment.getDialog(), Dialog.BUTTON_POSITIVE);
66 
67         verify(mTarget).deleteFingerPrint(mFingerprint);
68     }
69 
70     @Test
launchDialog_clickNegative_shouldDoNothing()71     public void launchDialog_clickNegative_shouldDoNothing() {
72         FragmentTestUtil.startFragment(mFragment);
73 
74         mFragment.onClick(mFragment.getDialog(), Dialog.BUTTON_NEGATIVE);
75 
76         verify(mTarget, never()).deleteFingerPrint(mFingerprint);
77     }
78 }
79