<lambda>null1 package com.android.systemui.user
2 
3 import android.app.Dialog
4 import android.testing.AndroidTestingRunner
5 import android.testing.TestableLooper
6 import androidx.test.ext.junit.rules.ActivityScenarioRule
7 import androidx.test.filters.SmallTest
8 import com.android.systemui.SysuiTestCase
9 import com.android.systemui.util.mockito.any
10 import com.android.systemui.util.mockito.mock
11 import com.android.systemui.util.mockito.nullable
12 import com.android.systemui.util.mockito.whenever
13 import com.google.common.truth.Truth.assertThat
14 import org.junit.Rule
15 import org.junit.Test
16 import org.junit.runner.RunWith
17 
18 @RunWith(AndroidTestingRunner::class)
19 @SmallTest
20 @TestableLooper.RunWithLooper
21 class CreateUserActivityTest : SysuiTestCase() {
22     open class CreateUserActivityTestable :
23         CreateUserActivity(
24             /* userCreator = */ mock(),
25             /* editUserInfoController = */ mock {
26                 val dialog: Dialog = mock()
27                 whenever(
28                         createDialog(
29                             /* activity = */ nullable(),
30                             /* activityStarter = */ nullable(),
31                             /* isMultipleAdminsEnabled = */ any(),
32                             /* successCallback = */ nullable(),
33                             /* cancelCallback = */ nullable()
34                         )
35                     )
36                     .thenReturn(dialog)
37             },
38             /* activityManager = */ mock(),
39             /* activityStarter = */ mock(),
40             mock(),
41         )
42 
43     @get:Rule val activityRule = ActivityScenarioRule(CreateUserActivityTestable::class.java)
44 
45     @Test
46     fun onBackPressed_finishActivity() {
47         activityRule.scenario.onActivity { activity ->
48             assertThat(activity.isFinishing).isFalse()
49 
50             activity.onBackPressed()
51 
52             assertThat(activity.isFinishing).isTrue()
53         }
54     }
55 }
56