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

Commit b41c9964 authored by Helen Cheuk's avatar Helen Cheuk Committed by Android (Google) Code Review
Browse files

Merge "[Contextual Edu] Use new GestureType from educationLib in SysUI" into main

parents 096cbaa9 d571ed8a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -576,6 +576,7 @@ android_library {
        "TraceurCommon",
        "Traceur-res",
        "//frameworks/libs/systemui:motion_tool_lib",
        "//frameworks/libs/systemui:contextualeducationlib",
        "notification_flags_lib",
        "PlatformComposeCore",
        "PlatformComposeSceneTransitionLayout",
@@ -736,6 +737,7 @@ android_library {
        "WindowManager-Shell",
        "LowLightDreamLib",
        "//frameworks/libs/systemui:motion_tool_lib",
        "//frameworks/libs/systemui:contextualeducationlib",
        "androidx.core_core-animation-testing",
        "androidx.compose.ui_ui",
        "flag-junit",
+7 −7
Original line number Diff line number Diff line
@@ -22,10 +22,10 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestableContext
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.contextualeducation.GestureType.BACK
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.shared.education.GestureType.BACK_GESTURE
import com.google.common.truth.Truth.assertThat
import java.io.File
import java.time.Clock
@@ -70,8 +70,8 @@ class ContextualEducationRepositoryTest : SysuiTestCase() {
    fun changeRetrievedValueForNewUser() =
        testScope.runTest {
            // Update data for old user.
            underTest.incrementSignalCount(BACK_GESTURE)
            val model by collectLastValue(underTest.readGestureEduModelFlow(BACK_GESTURE))
            underTest.incrementSignalCount(BACK)
            val model by collectLastValue(underTest.readGestureEduModelFlow(BACK))
            assertThat(model?.signalCount).isEqualTo(1)

            // User is changed.
@@ -83,17 +83,17 @@ class ContextualEducationRepositoryTest : SysuiTestCase() {
    @Test
    fun incrementSignalCount() =
        testScope.runTest {
            underTest.incrementSignalCount(BACK_GESTURE)
            val model by collectLastValue(underTest.readGestureEduModelFlow(BACK_GESTURE))
            underTest.incrementSignalCount(BACK)
            val model by collectLastValue(underTest.readGestureEduModelFlow(BACK))
            assertThat(model?.signalCount).isEqualTo(1)
        }

    @Test
    fun dataAddedOnUpdateShortcutTriggerTime() =
        testScope.runTest {
            val model by collectLastValue(underTest.readGestureEduModelFlow(BACK_GESTURE))
            val model by collectLastValue(underTest.readGestureEduModelFlow(BACK))
            assertThat(model?.lastShortcutTriggeredTime).isNull()
            underTest.updateShortcutTriggerTime(BACK_GESTURE)
            underTest.updateShortcutTriggerTime(BACK)
            assertThat(model?.lastShortcutTriggeredTime).isEqualTo(clock.instant())
        }

+7 −7
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.contextualeducation.GestureType
import com.android.systemui.contextualeducation.GestureType.BACK
import com.android.systemui.education.data.repository.contextualEducationRepository
import com.android.systemui.kosmos.testScope
import com.android.systemui.shared.education.GestureType
import com.android.systemui.shared.education.GestureType.BACK_GESTURE
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
@@ -47,15 +47,15 @@ class KeyboardTouchpadEduInteractorTest : SysuiTestCase() {
    @Test
    fun newEducationInfoOnMaxSignalCountReached() =
        testScope.runTest {
            tryTriggeringEducation(BACK_GESTURE)
            tryTriggeringEducation(BACK)
            val model by collectLastValue(underTest.educationTriggered)
            assertThat(model?.gestureType).isEqualTo(BACK_GESTURE)
            assertThat(model?.gestureType).isEqualTo(BACK)
        }

    @Test
    fun noEducationInfoBeforeMaxSignalCountReached() =
        testScope.runTest {
            repository.incrementSignalCount(BACK_GESTURE)
            repository.incrementSignalCount(BACK)
            val model by collectLastValue(underTest.educationTriggered)
            assertThat(model).isNull()
        }
@@ -64,8 +64,8 @@ class KeyboardTouchpadEduInteractorTest : SysuiTestCase() {
    fun noEducationInfoWhenShortcutTriggeredPreviously() =
        testScope.runTest {
            val model by collectLastValue(underTest.educationTriggered)
            repository.updateShortcutTriggerTime(BACK_GESTURE)
            tryTriggeringEducation(BACK_GESTURE)
            repository.updateShortcutTriggerTime(BACK)
            tryTriggeringEducation(BACK)
            assertThat(model).isNull()
        }

+5 −9
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.contextualeducation.GestureType.BACK
import com.android.systemui.education.data.repository.contextualEducationRepository
import com.android.systemui.education.data.repository.fakeEduClock
import com.android.systemui.kosmos.testScope
import com.android.systemui.shared.education.GestureType.BACK_GESTURE
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
@@ -41,11 +41,9 @@ class KeyboardTouchpadStatsInteractorTest : SysuiTestCase() {
    fun dataUpdatedOnIncrementSignalCount() =
        testScope.runTest {
            val model by
                collectLastValue(
                    kosmos.contextualEducationRepository.readGestureEduModelFlow(BACK_GESTURE)
                )
                collectLastValue(kosmos.contextualEducationRepository.readGestureEduModelFlow(BACK))
            val originalValue = model!!.signalCount
            underTest.incrementSignalCount(BACK_GESTURE)
            underTest.incrementSignalCount(BACK)
            assertThat(model?.signalCount).isEqualTo(originalValue + 1)
        }

@@ -53,11 +51,9 @@ class KeyboardTouchpadStatsInteractorTest : SysuiTestCase() {
    fun dataAddedOnUpdateShortcutTriggerTime() =
        testScope.runTest {
            val model by
                collectLastValue(
                    kosmos.contextualEducationRepository.readGestureEduModelFlow(BACK_GESTURE)
                )
                collectLastValue(kosmos.contextualEducationRepository.readGestureEduModelFlow(BACK))
            assertThat(model?.lastShortcutTriggeredTime).isNull()
            underTest.updateShortcutTriggerTime(BACK_GESTURE)
            underTest.updateShortcutTriggerTime(BACK)
            assertThat(model?.lastShortcutTriggeredTime).isEqualTo(kosmos.fakeEduClock.instant())
        }
}
+0 −21
Original line number Diff line number Diff line
/*
 * Copyright 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.shared.education

enum class GestureType {
    BACK_GESTURE,
}
Loading