Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9666cdd authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "adb command to reset and print out TutorialSchedulerRepository info" into main

parents ef7b604a f63aff71
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -427,7 +427,7 @@ class KeyboardTouchpadEduInteractorTest(private val gestureType: GestureType) :

    @After
    fun clear() {
        testScope.launch { tutorialSchedulerRepository.clearDataStore() }
        testScope.launch { tutorialSchedulerRepository.clear() }
    }

    private suspend fun triggerMaxEducationSignals(gestureType: GestureType) {
+2 −2
Original line number Diff line number Diff line
@@ -47,13 +47,13 @@ class TutorialSchedulerRepositoryTest : SysuiTestCase() {
            TutorialSchedulerRepository(
                context,
                testScope.backgroundScope,
                "TutorialSchedulerRepositoryTest"
                "TutorialSchedulerRepositoryTest",
            )
    }

    @After
    fun clear() {
        testScope.launch { underTest.clearDataStore() }
        testScope.launch { underTest.clear() }
    }

    @Test
+5 −3
Original line number Diff line number Diff line
@@ -26,10 +26,11 @@ import com.android.systemui.inputdevice.tutorial.data.repository.TutorialSchedul
import com.android.systemui.inputdevice.tutorial.inputDeviceTutorialLogger
import com.android.systemui.inputdevice.tutorial.ui.TutorialNotificationCoordinator
import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.settings.userTracker
import com.android.systemui.statusbar.commandline.commandRegistry
import com.android.systemui.testKosmos
import com.android.systemui.touchpad.data.repository.FakeTouchpadRepository
import com.google.common.truth.Truth.assertThat
import kotlin.time.Duration.Companion.hours
@@ -60,7 +61,7 @@ import org.mockito.kotlin.verify
class TutorialNotificationCoordinatorTest : SysuiTestCase() {

    private lateinit var underTest: TutorialNotificationCoordinator
    private val kosmos = Kosmos()
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val keyboardRepository = FakeKeyboardRepository()
    private val touchpadRepository = FakeTouchpadRepository()
@@ -85,6 +86,7 @@ class TutorialNotificationCoordinatorTest : SysuiTestCase() {
                touchpadRepository,
                repository,
                kosmos.inputDeviceTutorialLogger,
                kosmos.commandRegistry,
            )
        underTest =
            TutorialNotificationCoordinator(
@@ -100,7 +102,7 @@ class TutorialNotificationCoordinatorTest : SysuiTestCase() {

    @After
    fun clear() {
        runBlocking { repository.clearDataStore() }
        runBlocking { repository.clear() }
        dataStoreScope.cancel()
    }

+5 −3
Original line number Diff line number Diff line
@@ -24,8 +24,9 @@ import com.android.systemui.inputdevice.tutorial.data.repository.TutorialSchedul
import com.android.systemui.inputdevice.tutorial.domain.interactor.TutorialSchedulerInteractor.TutorialType
import com.android.systemui.inputdevice.tutorial.inputDeviceTutorialLogger
import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testScope
import com.android.systemui.statusbar.commandline.commandRegistry
import com.android.systemui.testKosmos
import com.android.systemui.touchpad.data.repository.FakeTouchpadRepository
import com.google.common.truth.Truth.assertThat
import kotlin.time.Duration.Companion.hours
@@ -49,7 +50,7 @@ import org.junit.runner.RunWith
class TutorialSchedulerInteractorTest : SysuiTestCase() {

    private lateinit var underTest: TutorialSchedulerInteractor
    private val kosmos = Kosmos()
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private lateinit var dataStoreScope: CoroutineScope
    private val keyboardRepository = FakeKeyboardRepository()
@@ -71,12 +72,13 @@ class TutorialSchedulerInteractorTest : SysuiTestCase() {
                touchpadRepository,
                schedulerRepository,
                kosmos.inputDeviceTutorialLogger,
                kosmos.commandRegistry,
            )
    }

    @After
    fun clear() {
        runBlocking { schedulerRepository.clearDataStore() }
        runBlocking { schedulerRepository.clear() }
        dataStoreScope.cancel()
    }

+5 −7
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.inputdevice.tutorial.data.repository

import android.content.Context
import androidx.annotation.VisibleForTesting
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
@@ -37,12 +36,12 @@ import kotlinx.coroutines.flow.map
class TutorialSchedulerRepository(
    private val applicationContext: Context,
    backgroundScope: CoroutineScope,
    dataStoreName: String
    dataStoreName: String,
) {
    @Inject
    constructor(
        @Application applicationContext: Context,
        @Background backgroundScope: CoroutineScope
        @Background backgroundScope: CoroutineScope,
    ) : this(applicationContext, backgroundScope, dataStoreName = DATASTORE_NAME)

    private val Context.dataStore: DataStore<Preferences> by
@@ -73,7 +72,7 @@ class TutorialSchedulerRepository(
    private fun getSchedulerInfo(pref: Preferences): Map<DeviceType, DeviceSchedulerInfo> {
        return mapOf(
            DeviceType.KEYBOARD to getDeviceSchedulerInfo(pref, DeviceType.KEYBOARD),
            DeviceType.TOUCHPAD to getDeviceSchedulerInfo(pref, DeviceType.TOUCHPAD)
            DeviceType.TOUCHPAD to getDeviceSchedulerInfo(pref, DeviceType.TOUCHPAD),
        )
    }

@@ -89,8 +88,7 @@ class TutorialSchedulerRepository(
    private fun getConnectKey(device: DeviceType) =
        longPreferencesKey(device.name + CONNECT_TIME_SUFFIX)

    @VisibleForTesting
    suspend fun clearDataStore() {
    suspend fun clear() {
        applicationContext.dataStore.edit { it.clear() }
    }

@@ -103,5 +101,5 @@ class TutorialSchedulerRepository(

enum class DeviceType {
    KEYBOARD,
    TOUCHPAD
    TOUCHPAD,
}
Loading