@@ -62,17 +62,27 @@ class SystemBridgeAutoStarterTest {
6262 private lateinit var mockResourceProvider: ResourceProvider
6363 private lateinit var testBuildConfig: TestBuildConfigProvider
6464
65- private val isRootGrantedFlow = MutableStateFlow (false )
66- private val shizukuIsStartedFlow = MutableStateFlow (false )
67- private val connectionStateFlow = MutableStateFlow <SystemBridgeConnectionState >(
68- SystemBridgeConnectionState .Disconnected (time = 0 , isStoppedByUser = false ),
69- )
70- private val isWifiConnectedFlow = MutableStateFlow (false )
71- private val writeSecureSettingsGrantedFlow = MutableStateFlow (false )
72- private val shizukuPermissionGrantedFlow = MutableStateFlow (false )
65+ private lateinit var isRootGrantedFlow: MutableStateFlow <Boolean >
66+ private lateinit var shizukuIsStartedFlow: MutableStateFlow <Boolean >
67+ private lateinit var connectionStateFlow: MutableStateFlow <SystemBridgeConnectionState >
68+ private lateinit var isWifiConnectedFlow: MutableStateFlow <Boolean >
69+ private lateinit var writeSecureSettingsGrantedFlow: MutableStateFlow <Boolean >
70+ private lateinit var shizukuPermissionGrantedFlow: MutableStateFlow <Boolean >
7371
7472 @Before
7573 fun init () {
74+ isRootGrantedFlow = MutableStateFlow (false )
75+ shizukuIsStartedFlow = MutableStateFlow (false )
76+ connectionStateFlow = MutableStateFlow (
77+ SystemBridgeConnectionState .Disconnected (
78+ time = testCoroutineScope.testScheduler.currentTime,
79+ isStoppedByUser = false ,
80+ ),
81+ )
82+ isWifiConnectedFlow = MutableStateFlow (false )
83+ writeSecureSettingsGrantedFlow = MutableStateFlow (false )
84+ shizukuPermissionGrantedFlow = MutableStateFlow (false )
85+
7686 mockSuAdapter = mock {
7787 on { isRootGranted } doReturn isRootGrantedFlow
7888 }
@@ -521,15 +531,14 @@ class SystemBridgeAutoStarterTest {
521531 }
522532
523533 @Test
524- fun `show killed and not restarting notification if system bridge dies less than 30 seconds after auto starting ` () =
534+ fun `show killed and not restarting notification if want to autostart again within the cooldown ` () =
525535 runTest(testDispatcher) {
526536 fakePreferences.set(Keys .isSystemBridgeKeepAliveEnabled, true )
527537 fakePreferences.set(Keys .isSystemBridgeUsed, true )
528538
529539 whenever(
530540 mockResourceProvider.getString(R .string.system_bridge_died_notification_title),
531541 ).thenReturn(" died" )
532-
533542 whenever(mockSetupController.isAdbPaired()).thenReturn(true )
534543 isWifiConnectedFlow.value = true
535544 writeSecureSettingsGrantedFlow.value = true
@@ -542,10 +551,11 @@ class SystemBridgeAutoStarterTest {
542551 verify(mockNotificationAdapter).showNotification(any())
543552 connectionStateFlow.value = SystemBridgeConnectionState .Connected (time = 10000 )
544553
545- // Set the state as connected within the timeout
554+ // Set the state as disconnected within the timeout
546555 connectionStateFlow.value =
547556 SystemBridgeConnectionState .Disconnected (time = 11000 , isStoppedByUser = false )
548557 advanceUntilIdle()
558+
549559 // Show notification
550560 val argument = argumentCaptor<NotificationModel >()
551561 verify(mockNotificationAdapter).showNotification(argument.capture())
0 commit comments