1 /*
<lambda>null2  * Copyright (C) 2023 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.wifi
18 
19 import androidx.activity.ComponentActivity
20 import androidx.test.ext.junit.rules.ActivityScenarioRule
21 import androidx.test.ext.junit.runners.AndroidJUnit4
22 import com.android.settings.R
23 import com.android.settings.wifi.WifiDialog2.WifiDialog2Listener
24 import com.android.wifitrackerlib.WifiEntry
25 import com.google.common.truth.Truth.assertThat
26 import org.junit.Ignore
27 import org.junit.Rule
28 import org.junit.Test
29 import org.junit.runner.RunWith
30 import org.mockito.Mock
31 import org.mockito.junit.MockitoJUnit
32 import org.mockito.junit.MockitoRule
33 
34 @Ignore
35 @RunWith(AndroidJUnit4::class)
36 class WifiDialog2Test {
37     @get:Rule
38     val activityScenarioRule = ActivityScenarioRule(ComponentActivity::class.java)
39 
40     @get:Rule
41     val mockito: MockitoRule = MockitoJUnit.rule()
42 
43     @Mock
44     private lateinit var mockWifiEntry: WifiEntry
45 
46     private val listener = object : WifiDialog2Listener {}
47 
48     @Test
49     fun constructor_usesDefaultTheme() {
50         activityScenarioRule.scenario.onActivity { activity ->
51             val wifiDialog2 = WifiDialog2(
52                 context = activity,
53                 listener = listener,
54                 wifiEntry = mockWifiEntry,
55                 mode = WifiConfigUiBase2.MODE_CONNECT,
56                 style = 0,
57                 hideSubmitButton = false
58             )
59 
60             val modal = WifiDialog2(
61                 context = activity,
62                 listener = listener,
63                 wifiEntry = mockWifiEntry,
64                 mode = WifiConfigUiBase2.MODE_CONNECT,
65             )
66 
67             assertThat(modal.context.themeResId).isEqualTo(wifiDialog2.context.themeResId)
68         }
69     }
70 
71     @Test
72     fun constructor_whenSetTheme_shouldBeCustomizedTheme() {
73         activityScenarioRule.scenario.onActivity { activity ->
74             val wifiDialog2 = WifiDialog2(
75                 context = activity,
76                 listener = listener,
77                 wifiEntry = mockWifiEntry,
78                 mode = WifiConfigUiBase2.MODE_CONNECT,
79                 style = R.style.SuwAlertDialogThemeCompat_Light,
80                 hideSubmitButton = false,
81             )
82 
83             val modal = WifiDialog2(
84                 context = activity,
85                 listener = listener,
86                 wifiEntry = mockWifiEntry,
87                 mode = WifiConfigUiBase2.MODE_CONNECT,
88                 style = R.style.SuwAlertDialogThemeCompat_Light,
89             )
90 
91             assertThat(modal.context.themeResId).isEqualTo(wifiDialog2.context.themeResId)
92         }
93     }
94 }
95