Loading packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt +9 −21 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ import androidx.compose.foundation.gestures.Orientation import androidx.compose.material3.Text import androidx.compose.ui.geometry.Offset import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.NestedScrollSource.Companion.UserInput import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.LayoutDirection Loading Loading @@ -294,15 +294,10 @@ class DraggableHandlerTest { available: Offset, consumedByScroll: Offset = Offset.Zero, ) { val consumedByPreScroll = onPreScroll(available = available, source = NestedScrollSource.Drag) val consumedByPreScroll = onPreScroll(available = available, source = UserInput) val consumed = consumedByPreScroll + consumedByScroll onPostScroll( consumed = consumed, available = available - consumed, source = NestedScrollSource.Drag, ) onPostScroll(consumed = consumed, available = available - consumed, source = UserInput) } fun NestedScrollConnection.preFling( Loading Loading @@ -738,7 +733,7 @@ class DraggableHandlerTest { val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview) nestedScroll.onPreScroll( available = downOffset(fractionOfScreen = 0.1f), source = NestedScrollSource.Drag, source = UserInput, ) assertIdle(currentScene = SceneA) } Loading @@ -750,7 +745,7 @@ class DraggableHandlerTest { nestedScroll.onPostScroll( consumed = Offset.Zero, available = Offset.Zero, source = NestedScrollSource.Drag, source = UserInput, ) assertIdle(currentScene = SceneA) Loading @@ -764,7 +759,7 @@ class DraggableHandlerTest { nestedScroll.onPostScroll( consumed = Offset.Zero, available = downOffset(fractionOfScreen = 0.1f), source = NestedScrollSource.Drag, source = UserInput, ) assertTransition(currentScene = SceneA) Loading @@ -784,16 +779,12 @@ class DraggableHandlerTest { val consumed = nestedScroll.onPreScroll( available = downOffset(fractionOfScreen = 0.1f), source = NestedScrollSource.Drag, source = UserInput, ) assertThat(progress).isEqualTo(0.2f) // do nothing on postScroll nestedScroll.onPostScroll( consumed = consumed, available = Offset.Zero, source = NestedScrollSource.Drag, ) nestedScroll.onPostScroll(consumed = consumed, available = Offset.Zero, source = UserInput) assertThat(progress).isEqualTo(0.2f) nestedScroll.scroll(available = downOffset(fractionOfScreen = 0.1f)) Loading @@ -813,10 +804,7 @@ class DraggableHandlerTest { nestedScroll.preFling(available = Velocity.Zero) // a pre scroll event, that could be intercepted by DraggableHandlerImpl nestedScroll.onPreScroll( available = Offset(0f, secondScroll), source = NestedScrollSource.Drag, ) nestedScroll.onPreScroll(available = Offset(0f, secondScroll), source = UserInput) } @Test Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt +15 −42 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package com.android.systemui.statusbar.notification import androidx.compose.ui.geometry.Offset import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.NestedScrollSource.Companion.UserInput import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading Loading @@ -58,10 +58,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { contentHeight = COLLAPSED_CONTENT_HEIGHT val offsetConsumed = scrollConnection.onPreScroll( available = Offset(x = 0f, y = -1f), source = NestedScrollSource.Drag, ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput) assertThat(offsetConsumed).isEqualTo(Offset.Zero) assertThat(isStarted).isEqualTo(false) Loading @@ -73,10 +70,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrimOffset = MIN_SCRIM_OFFSET val offsetConsumed = scrollConnection.onPreScroll( available = Offset(x = 0f, y = -1f), source = NestedScrollSource.Drag, ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput) assertThat(offsetConsumed).isEqualTo(Offset.Zero) assertThat(isStarted).isEqualTo(false) Loading @@ -88,10 +82,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { val availableOffset = Offset(x = 0f, y = -1f) val offsetConsumed = scrollConnection.onPreScroll( available = availableOffset, source = NestedScrollSource.Drag, ) scrollConnection.onPreScroll(available = availableOffset, source = UserInput) assertThat(offsetConsumed).isEqualTo(availableOffset) assertThat(isStarted).isEqualTo(true) Loading @@ -105,10 +96,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { val availableOffset = Offset(x = 0f, y = -2f) val consumableOffset = Offset(x = 0f, y = -1f) val offsetConsumed = scrollConnection.onPreScroll( available = availableOffset, source = NestedScrollSource.Drag, ) scrollConnection.onPreScroll(available = availableOffset, source = UserInput) assertThat(offsetConsumed).isEqualTo(consumableOffset) assertThat(isStarted).isEqualTo(true) Loading @@ -120,7 +108,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrollConnection.onPostScroll( consumed = Offset.Zero, available = Offset(x = 0f, y = -1f), source = NestedScrollSource.Drag, source = UserInput, ) assertThat(offsetConsumed).isEqualTo(Offset.Zero) Loading @@ -130,10 +118,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { @Test fun onScrollDown_canStartPreScroll_ignoreScroll() = runTest { val offsetConsumed = scrollConnection.onPreScroll( available = Offset(x = 0f, y = 1f), source = NestedScrollSource.Drag, ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = 1f), source = UserInput) assertThat(offsetConsumed).isEqualTo(Offset.Zero) assertThat(isStarted).isEqualTo(false) Loading @@ -148,7 +133,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrollConnection.onPostScroll( consumed = Offset.Zero, available = availableOffset, source = NestedScrollSource.Drag source = UserInput, ) assertThat(offsetConsumed).isEqualTo(availableOffset) Loading @@ -165,7 +150,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrollConnection.onPostScroll( consumed = Offset.Zero, available = availableOffset, source = NestedScrollSource.Drag source = UserInput, ) assertThat(offsetConsumed).isEqualTo(consumableOffset) Loading @@ -180,7 +165,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrollConnection.onPostScroll( consumed = Offset.Zero, available = Offset(x = 0f, y = 1f), source = NestedScrollSource.Drag source = UserInput, ) assertThat(offsetConsumed).isEqualTo(Offset.Zero) Loading @@ -197,7 +182,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrollConnection.onPostScroll( consumed = Offset.Zero, available = Offset(x = 0f, y = 1f), source = NestedScrollSource.Drag source = UserInput, ) assertThat(offsetConsumed).isEqualTo(Offset.Zero) Loading @@ -210,17 +195,11 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { fun canContinueScroll_inBetweenMinMaxOffset_true() = runTest { scrimOffset = (MIN_SCRIM_OFFSET + MAX_SCRIM_OFFSET) / 2f contentHeight = EXPANDED_CONTENT_HEIGHT scrollConnection.onPreScroll( available = Offset(x = 0f, y = -1f), source = NestedScrollSource.Drag ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput) assertThat(isStarted).isEqualTo(true) scrollConnection.onPreScroll( available = Offset(x = 0f, y = 1f), source = NestedScrollSource.Drag ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = 1f), source = UserInput) assertThat(isStarted).isEqualTo(true) } Loading @@ -229,17 +208,11 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { fun canContinueScroll_atMaxOffset_false() = runTest { scrimOffset = MAX_SCRIM_OFFSET contentHeight = EXPANDED_CONTENT_HEIGHT scrollConnection.onPreScroll( available = Offset(x = 0f, y = -1f), source = NestedScrollSource.Drag ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput) assertThat(isStarted).isEqualTo(true) scrollConnection.onPreScroll( available = Offset(x = 0f, y = 1f), source = NestedScrollSource.Drag ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = 1f), source = UserInput) assertThat(isStarted).isEqualTo(false) } Loading Loading
packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt +9 −21 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ import androidx.compose.foundation.gestures.Orientation import androidx.compose.material3.Text import androidx.compose.ui.geometry.Offset import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.NestedScrollSource.Companion.UserInput import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.LayoutDirection Loading Loading @@ -294,15 +294,10 @@ class DraggableHandlerTest { available: Offset, consumedByScroll: Offset = Offset.Zero, ) { val consumedByPreScroll = onPreScroll(available = available, source = NestedScrollSource.Drag) val consumedByPreScroll = onPreScroll(available = available, source = UserInput) val consumed = consumedByPreScroll + consumedByScroll onPostScroll( consumed = consumed, available = available - consumed, source = NestedScrollSource.Drag, ) onPostScroll(consumed = consumed, available = available - consumed, source = UserInput) } fun NestedScrollConnection.preFling( Loading Loading @@ -738,7 +733,7 @@ class DraggableHandlerTest { val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview) nestedScroll.onPreScroll( available = downOffset(fractionOfScreen = 0.1f), source = NestedScrollSource.Drag, source = UserInput, ) assertIdle(currentScene = SceneA) } Loading @@ -750,7 +745,7 @@ class DraggableHandlerTest { nestedScroll.onPostScroll( consumed = Offset.Zero, available = Offset.Zero, source = NestedScrollSource.Drag, source = UserInput, ) assertIdle(currentScene = SceneA) Loading @@ -764,7 +759,7 @@ class DraggableHandlerTest { nestedScroll.onPostScroll( consumed = Offset.Zero, available = downOffset(fractionOfScreen = 0.1f), source = NestedScrollSource.Drag, source = UserInput, ) assertTransition(currentScene = SceneA) Loading @@ -784,16 +779,12 @@ class DraggableHandlerTest { val consumed = nestedScroll.onPreScroll( available = downOffset(fractionOfScreen = 0.1f), source = NestedScrollSource.Drag, source = UserInput, ) assertThat(progress).isEqualTo(0.2f) // do nothing on postScroll nestedScroll.onPostScroll( consumed = consumed, available = Offset.Zero, source = NestedScrollSource.Drag, ) nestedScroll.onPostScroll(consumed = consumed, available = Offset.Zero, source = UserInput) assertThat(progress).isEqualTo(0.2f) nestedScroll.scroll(available = downOffset(fractionOfScreen = 0.1f)) Loading @@ -813,10 +804,7 @@ class DraggableHandlerTest { nestedScroll.preFling(available = Velocity.Zero) // a pre scroll event, that could be intercepted by DraggableHandlerImpl nestedScroll.onPreScroll( available = Offset(0f, secondScroll), source = NestedScrollSource.Drag, ) nestedScroll.onPreScroll(available = Offset(0f, secondScroll), source = UserInput) } @Test Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt +15 −42 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package com.android.systemui.statusbar.notification import androidx.compose.ui.geometry.Offset import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.NestedScrollSource.Companion.UserInput import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase Loading Loading @@ -58,10 +58,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { contentHeight = COLLAPSED_CONTENT_HEIGHT val offsetConsumed = scrollConnection.onPreScroll( available = Offset(x = 0f, y = -1f), source = NestedScrollSource.Drag, ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput) assertThat(offsetConsumed).isEqualTo(Offset.Zero) assertThat(isStarted).isEqualTo(false) Loading @@ -73,10 +70,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrimOffset = MIN_SCRIM_OFFSET val offsetConsumed = scrollConnection.onPreScroll( available = Offset(x = 0f, y = -1f), source = NestedScrollSource.Drag, ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput) assertThat(offsetConsumed).isEqualTo(Offset.Zero) assertThat(isStarted).isEqualTo(false) Loading @@ -88,10 +82,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { val availableOffset = Offset(x = 0f, y = -1f) val offsetConsumed = scrollConnection.onPreScroll( available = availableOffset, source = NestedScrollSource.Drag, ) scrollConnection.onPreScroll(available = availableOffset, source = UserInput) assertThat(offsetConsumed).isEqualTo(availableOffset) assertThat(isStarted).isEqualTo(true) Loading @@ -105,10 +96,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { val availableOffset = Offset(x = 0f, y = -2f) val consumableOffset = Offset(x = 0f, y = -1f) val offsetConsumed = scrollConnection.onPreScroll( available = availableOffset, source = NestedScrollSource.Drag, ) scrollConnection.onPreScroll(available = availableOffset, source = UserInput) assertThat(offsetConsumed).isEqualTo(consumableOffset) assertThat(isStarted).isEqualTo(true) Loading @@ -120,7 +108,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrollConnection.onPostScroll( consumed = Offset.Zero, available = Offset(x = 0f, y = -1f), source = NestedScrollSource.Drag, source = UserInput, ) assertThat(offsetConsumed).isEqualTo(Offset.Zero) Loading @@ -130,10 +118,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { @Test fun onScrollDown_canStartPreScroll_ignoreScroll() = runTest { val offsetConsumed = scrollConnection.onPreScroll( available = Offset(x = 0f, y = 1f), source = NestedScrollSource.Drag, ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = 1f), source = UserInput) assertThat(offsetConsumed).isEqualTo(Offset.Zero) assertThat(isStarted).isEqualTo(false) Loading @@ -148,7 +133,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrollConnection.onPostScroll( consumed = Offset.Zero, available = availableOffset, source = NestedScrollSource.Drag source = UserInput, ) assertThat(offsetConsumed).isEqualTo(availableOffset) Loading @@ -165,7 +150,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrollConnection.onPostScroll( consumed = Offset.Zero, available = availableOffset, source = NestedScrollSource.Drag source = UserInput, ) assertThat(offsetConsumed).isEqualTo(consumableOffset) Loading @@ -180,7 +165,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrollConnection.onPostScroll( consumed = Offset.Zero, available = Offset(x = 0f, y = 1f), source = NestedScrollSource.Drag source = UserInput, ) assertThat(offsetConsumed).isEqualTo(Offset.Zero) Loading @@ -197,7 +182,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { scrollConnection.onPostScroll( consumed = Offset.Zero, available = Offset(x = 0f, y = 1f), source = NestedScrollSource.Drag source = UserInput, ) assertThat(offsetConsumed).isEqualTo(Offset.Zero) Loading @@ -210,17 +195,11 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { fun canContinueScroll_inBetweenMinMaxOffset_true() = runTest { scrimOffset = (MIN_SCRIM_OFFSET + MAX_SCRIM_OFFSET) / 2f contentHeight = EXPANDED_CONTENT_HEIGHT scrollConnection.onPreScroll( available = Offset(x = 0f, y = -1f), source = NestedScrollSource.Drag ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput) assertThat(isStarted).isEqualTo(true) scrollConnection.onPreScroll( available = Offset(x = 0f, y = 1f), source = NestedScrollSource.Drag ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = 1f), source = UserInput) assertThat(isStarted).isEqualTo(true) } Loading @@ -229,17 +208,11 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() { fun canContinueScroll_atMaxOffset_false() = runTest { scrimOffset = MAX_SCRIM_OFFSET contentHeight = EXPANDED_CONTENT_HEIGHT scrollConnection.onPreScroll( available = Offset(x = 0f, y = -1f), source = NestedScrollSource.Drag ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput) assertThat(isStarted).isEqualTo(true) scrollConnection.onPreScroll( available = Offset(x = 0f, y = 1f), source = NestedScrollSource.Drag ) scrollConnection.onPreScroll(available = Offset(x = 0f, y = 1f), source = UserInput) assertThat(isStarted).isEqualTo(false) } Loading