mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-03-25 03:59:11 +00:00
[workloads/jetnews] Harden JetNews testing to cope with tablets/small phones
On tablets we have a landscape view by default, so we need to account for that in our tests. On smaller phones, the landscape mode doesn't show the article preview. On both tablets and small screen phones, we need to be mindful of scrolling too fast and missing an element we're looking for, either because a bigger screen means we scroll faster or because a smaller screen means only a few items are shown at one time.
This commit is contained in:
parent
e85cca9ffc
commit
5180fed72f
Binary file not shown.
@ -110,7 +110,7 @@ public class UiAutomationJankTests extends JankTestBase {
|
||||
}
|
||||
|
||||
private void runPortraitVerticalTests() throws Exception {
|
||||
// Scroll to the first postcard in the list.
|
||||
mDevice.setOrientationPortrait();
|
||||
mDevice.wait(Until.findObject(By.res(MAIN_VIEW)), DEFAULT_TIMEOUT);
|
||||
UiObject2 articles = mDevice.findObject(By.res(MAIN_VIEW));
|
||||
ViewMatchers.assertThat(articles, CoreMatchers.notNullValue());
|
||||
@ -134,14 +134,20 @@ public class UiAutomationJankTests extends JankTestBase {
|
||||
}
|
||||
|
||||
private void runPortraitHorizontalTests() throws Exception {
|
||||
mDevice.setOrientationPortrait();
|
||||
mDevice.wait(Until.findObject(By.res(MAIN_VIEW)), DEFAULT_TIMEOUT);
|
||||
UiObject2 articles = mDevice.findObject(By.res(MAIN_VIEW));
|
||||
ViewMatchers.assertThat(articles, CoreMatchers.notNullValue());
|
||||
|
||||
scrollTo(articles, TOP_ARTICLE, false, TOP_ARTICLE,
|
||||
BOTTOM_ARTICLE, false, true, fling_speed);
|
||||
|
||||
// Scroll downwards until the first postcard in the list is on screen.
|
||||
// We reduce the fling speed so we don't skip past it on devices with
|
||||
// screens that are too small or too big (fast scrolling).
|
||||
scrollTo(articles, POPULAR_LIST, true, TOP_ARTICLE,
|
||||
BOTTOM_ARTICLE, false, true, 5000);
|
||||
BOTTOM_ARTICLE, false, true,
|
||||
(fling_speed / 5) < 1000? 1000 : fling_speed);
|
||||
|
||||
UiObject2 article = mDevice.findObject(By.res(POPULAR_LIST));
|
||||
article.fling(Direction.RIGHT,
|
||||
@ -149,6 +155,8 @@ public class UiAutomationJankTests extends JankTestBase {
|
||||
article.fling(Direction.LEFT, fling_speed);
|
||||
scrollTo(articles, BOTTOM_ARTICLE, true, TOP_ARTICLE,
|
||||
BOTTOM_ARTICLE, false, true, fling_speed);
|
||||
scrollTo(articles, TOP_ARTICLE, false, TOP_ARTICLE,
|
||||
BOTTOM_ARTICLE, false, true, fling_speed);
|
||||
}
|
||||
|
||||
private void runLandscapeVerticalTests() throws Exception {
|
||||
@ -157,22 +165,39 @@ public class UiAutomationJankTests extends JankTestBase {
|
||||
mDevice.setOrientationLandscape();
|
||||
mDevice.wait(Until.findObject(By.res(MAIN_VIEW)), DEFAULT_TIMEOUT);
|
||||
|
||||
// On some devices with smaller screens, the landscape test may not
|
||||
// be supported, as the screen space is too small to display both
|
||||
// the list of articles and the article preview view.
|
||||
// In that case, skip the portion of the test that interacts with
|
||||
// the preview view.
|
||||
UiObject2 articles = mDevice.findObject(By.res(MAIN_VIEW));
|
||||
ViewMatchers.assertThat(articles, CoreMatchers.notNullValue());
|
||||
|
||||
articles.setGestureMarginPercentage(0.2f);
|
||||
scrollTo(articles, BOTTOM_ARTICLE, true, TOP_ARTICLE,
|
||||
BOTTOM_ARTICLE, false, true,
|
||||
fling_speed);
|
||||
BOTTOM_ARTICLE, false, true,
|
||||
fling_speed);
|
||||
scrollTo(articles, TOP_ARTICLE, false, TOP_ARTICLE,
|
||||
BOTTOM_ARTICLE, false, true,
|
||||
fling_speed);
|
||||
BOTTOM_ARTICLE, false, true,
|
||||
fling_speed);
|
||||
|
||||
// Scroll downwards until the first postcard in the list is on screen.
|
||||
// We reduce the fling speed so we don't skip past it on devices with
|
||||
// screens that are too small or too big (fast scrolling).
|
||||
scrollTo(articles, "PostCardSimple0", true, TOP_ARTICLE,
|
||||
BOTTOM_ARTICLE, false, true,
|
||||
(fling_speed / 5) < 1000? 1000 : fling_speed);
|
||||
|
||||
UiObject2 article_to_click = mDevice.findObject(By.res("PostCardSimple0"));
|
||||
article_to_click.click();
|
||||
|
||||
// Wait for the clicked article to appear.
|
||||
UiObject2 article = mDevice.wait(
|
||||
Until.findObject(By.res(ARTICLE_VIEW)),
|
||||
DEFAULT_TIMEOUT
|
||||
);
|
||||
|
||||
article.setGestureMarginPercentage(0.2f);
|
||||
article.fling(Direction.DOWN, fling_speed);
|
||||
article.fling(Direction.UP, fling_speed);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user