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

Commit 5f59ac63 authored by Yasin Kilicdere's avatar Yasin Kilicdere Committed by Android Build Coastguard Worker
Browse files

Fix UserRepository to use the correct callback method.

Bug: 369294724
Bug: 331853529
Bug: 360838273

Test: atest UserRepositoryImplTest
Flag: EXEMPT bugfix
(cherry picked from commit 7cb99687)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:175dd00420c6727793b724ecbb9fe90e54f8b688)
Merged-In: I8b412400b89f5c62ccfc314d49dad68400cb3e5b
Change-Id: I8b412400b89f5c62ccfc314d49dad68400cb3e5b
parent c059123b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -195,7 +195,7 @@ constructor(


                val callback =
                val callback =
                    object : UserTracker.Callback {
                    object : UserTracker.Callback {
                        override fun onUserChanging(newUser: Int, userContext: Context) {
                        override fun onBeforeUserSwitching(newUser: Int) {
                            send(SelectionStatus.SELECTION_IN_PROGRESS)
                            send(SelectionStatus.SELECTION_IN_PROGRESS)
                        }
                        }


+9 −1
Original line number Original line Diff line number Diff line
@@ -232,10 +232,17 @@ class UserRepositoryImplTest : SysuiTestCase() {
        underTest.selectedUser.onEach { selectedUser = it }.launchIn(this)
        underTest.selectedUser.onEach { selectedUser = it }.launchIn(this)
        setUpUsers(count = 2, selectedIndex = 1)
        setUpUsers(count = 2, selectedIndex = 1)


        // WHEN the user switch is starting
        tracker.onBeforeUserSwitching(userId = 1)

        // THEN the selection status is IN_PROGRESS
        assertThat(selectedUser!!.selectionStatus)
            .isEqualTo(SelectionStatus.SELECTION_IN_PROGRESS)

        // WHEN the user is changing
        // WHEN the user is changing
        tracker.onUserChanging(userId = 1)
        tracker.onUserChanging(userId = 1)


        // THEN the selection status is IN_PROGRESS
        // THEN the selection status is still IN_PROGRESS
        assertThat(selectedUser!!.selectionStatus).isEqualTo(SelectionStatus.SELECTION_IN_PROGRESS)
        assertThat(selectedUser!!.selectionStatus).isEqualTo(SelectionStatus.SELECTION_IN_PROGRESS)


        // WHEN the user has finished changing
        // WHEN the user has finished changing
@@ -249,6 +256,7 @@ class UserRepositoryImplTest : SysuiTestCase() {


        setUpUsers(count = 2, selectedIndex = 0)
        setUpUsers(count = 2, selectedIndex = 0)


        tracker.onBeforeUserSwitching(userId = 0)
        tracker.onUserChanging(userId = 0)
        tracker.onUserChanging(userId = 0)
        assertThat(selectedUser!!.selectionStatus).isEqualTo(SelectionStatus.SELECTION_IN_PROGRESS)
        assertThat(selectedUser!!.selectionStatus).isEqualTo(SelectionStatus.SELECTION_IN_PROGRESS)