1 /*
2  * Copyright (C) 2021 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.systemui.statusbar.policy
18 
19 import android.service.quickaccesswallet.QuickAccessWalletClient
20 
21 import androidx.test.ext.junit.runners.AndroidJUnit4
22 import androidx.test.filters.SmallTest
23 
24 import com.android.systemui.SysuiTestCase
25 import com.android.systemui.statusbar.policy.DeviceControlsControllerImpl.Companion.QS_PRIORITY_POSITION
26 
27 import com.google.common.truth.Truth.assertThat
28 
29 import org.junit.Before
30 import org.junit.Test
31 import org.junit.runner.RunWith
32 
33 import org.mockito.Mock
34 import org.mockito.MockitoAnnotations
35 import org.mockito.Mockito.`when`
36 
37 @SmallTest
38 @RunWith(AndroidJUnit4::class)
39 class WalletControllerImplTest : SysuiTestCase() {
40 
41     @Mock
42     private lateinit var quickAccessWalletClient: QuickAccessWalletClient
43 
44     private lateinit var controller: WalletController
45 
46     @Before
setUpnull47     fun setUp() {
48         MockitoAnnotations.initMocks(this)
49 
50         controller = WalletControllerImpl(quickAccessWalletClient)
51     }
52 
53     @Test
testResultIsNullWhenNoServiceAvailablenull54     fun testResultIsNullWhenNoServiceAvailable() {
55         `when`(quickAccessWalletClient.isWalletServiceAvailable()).thenReturn(false)
56         assertThat(controller.getWalletPosition()).isNull()
57     }
58 
59     @Test
testResultIsIntWhenServiceAvailablenull60     fun testResultIsIntWhenServiceAvailable() {
61         `when`(quickAccessWalletClient.isWalletServiceAvailable()).thenReturn(true)
62         assertThat(controller.getWalletPosition()).isEqualTo(QS_PRIORITY_POSITION)
63     }
64 }
65