Jonathan
12/08/2023, 4:24 PMUiObject2
. I assume the digital crown ==
scroll gesture but I want to make sure.stevebower
12/11/2023, 2:23 PMJonathan
12/11/2023, 2:32 PMUiObject.scroll(…)
would be sufficient to exercise the code for a Baseline & Macrobenchmark profile. Scrolling performance is terrible on a live device.stevebower
12/11/2023, 3:37 PMval list = device.findObject(By.desc(CONTENT_DESCRIPTION))
// Setting a gesture margin is important otherwise gesture nav is triggered.
list.setGestureMargin(device.displayWidth / 5)
repeat(5) {
list.drag(Point(list.visibleCenter.x, list.visibleCenter.y / 3))
device.waitForIdle()
}
Jonathan
12/11/2023, 3:48 PMUiObject.fling(…)
🤔
Either way, I still need to figure out while rotary scrolling is so janky with my app.Jonathan
12/11/2023, 3:48 PMMichail Kulaga
12/11/2023, 4:10 PM@get:Rule
val rule = createComposeRule()
@Test
fun testing_rotary() {
rule.setContent {
// Setting content with scrollable list
}
@OptIn(ExperimentalTestApi::class)
rule.onNodeWithTag(TEST_TAG).performRotaryScrollInput {
// Scroll by 2 items backward
rotateToScrollVertically(-50.0f)
advanceEventTime(250)
rotateToScrollVertically(-50.0f)
}
rule.runOnIdle {
// testing that our scroll happened
}
}
Rotary is different from scroll because it sends a list of different events when it’s scrolled. Usually there’re dozens of events with small values during a single rotation .
But performance-wise there is no difference between rotary or finger scroll, so scrolling with Ui automator for performance tests should be fine