Add Calendar jank test, fix dialer jank test
Change-Id: Ieb040747573d9b7cd1052076fc1fa05db09cf759
diff --git a/tests/jank/dialer/src/com/android/dialer/janktests/DialerJankTests.java b/tests/jank/dialer/src/com/android/dialer/janktests/DialerJankTests.java
index 6d1a208..ab2c415 100644
--- a/tests/jank/dialer/src/com/android/dialer/janktests/DialerJankTests.java
+++ b/tests/jank/dialer/src/com/android/dialer/janktests/DialerJankTests.java
@@ -55,7 +55,7 @@
* fling call log
*/
public class DialerJankTests extends JankTestBase {
- private static final int TIMEOUT = 1000;
+ private static final int TIMEOUT = 5000;
private static final int INNER_LOOP = 5;
private static final int EXPECTED_FRAMES = 100;
private static final String PACKAGE_NAME = "com.google.android.dialer";
@@ -100,12 +100,12 @@
UiObject2 contacts = mDevice.wait(Until.findObject(
By.clazz(View.class).desc("Contacts")), TIMEOUT);
assertNotNull("Contacts can't be found", contacts);
- contacts.click();
+ contacts.clickAndWait(Until.newWindow(), TIMEOUT);
// Find a contact by a given contact-name
UiObject2 contactName = mDevice.wait(Until.findObject(
By.res(RES_PACKAGE_NAME, "cliv_name_textview").text(CONTACT_NAME)), TIMEOUT);
assertNotNull("Contactname can't be found", contactName);
- contactName.click();
+ contactName.clickAndWait(Until.newWindow(), TIMEOUT);
// Click on dial-icon beside contact-number to ensure test is ready to be executed
UiObject2 contactNumber = mDevice.wait(Until.findObject(
By.res(RES_PACKAGE_NAME2,"header").text(CONTACT_NUMBER)), TIMEOUT);
diff --git a/tests/jank/sysapp/src/com/android/sysapp/janktests/CalendarJankTests.java b/tests/jank/sysapp/src/com/android/sysapp/janktests/CalendarJankTests.java
index 53db1a4..ff9e771 100644
--- a/tests/jank/sysapp/src/com/android/sysapp/janktests/CalendarJankTests.java
+++ b/tests/jank/sysapp/src/com/android/sysapp/janktests/CalendarJankTests.java
@@ -31,6 +31,7 @@
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.Until;
+import android.view.View;
import junit.framework.Assert;
@@ -45,15 +46,26 @@
private static final int SHORT_TIMEOUT = 100;
private static final int INNER_LOOP = 5;
private static final int EXPECTED_FRAMES = 100;
+ private static final int TAB_MIN_WIDTH = 600;
private static final String PACKAGE_NAME = "com.google.android.calendar";
private static final String RES_PACKAGE_NAME = "com.android.calendar";
private UiDevice mDevice;
+ private BySelector mCalendarSelector = null;
+ private Direction mScrollDirection = null;
+
@Override
public void setUp() throws Exception {
super.setUp();
mDevice = UiDevice.getInstance(getInstrumentation());
mDevice.setOrientationNatural();
+ if (mDevice.getDisplaySizeDp().x < TAB_MIN_WIDTH) {
+ mCalendarSelector = By.res(PACKAGE_NAME, "timely_list");
+ mScrollDirection = Direction.DOWN;
+ } else {
+ mCalendarSelector = By.res(PACKAGE_NAME, "main_pane");
+ mScrollDirection = Direction.RIGHT;
+ }
}
@Override
@@ -74,34 +86,50 @@
launchApp(PACKAGE_NAME);
mDevice.waitForIdle();
dismissCling();
- Assert.assertNotNull("Calendar can't be found",
- mDevice.wait(Until.findObject(By.res(RES_PACKAGE_NAME, "timely_list")), LONG_TIMEOUT));
+ assertNotNull("Calendar can't be found",
+ mDevice.wait(Until.findObject(mCalendarSelector), LONG_TIMEOUT));
}
// Measures jank of flinging calendar items
@JankTest(beforeTest="launchCalendar", expectedFrames=EXPECTED_FRAMES)
@GfxMonitor(processName=PACKAGE_NAME)
- public void disable_testCalendarItemsFling() {
- UiObject2 timelyList = mDevice.wait(
- Until.findObject(By.res(RES_PACKAGE_NAME, "timely_list")), LONG_TIMEOUT);
+ public void testCalendarItemsFling() {
+ UiObject2 calendarItems = null;
+ calendarItems = mDevice.wait(Until.findObject(mCalendarSelector), LONG_TIMEOUT);
for (int i = 0; i < INNER_LOOP; i++) {
- timelyList.fling(Direction.DOWN);
- SystemClock.sleep(SHORT_TIMEOUT);
- timelyList.fling(Direction.UP);
+ calendarItems.scroll(mScrollDirection, 1.0f);
SystemClock.sleep(SHORT_TIMEOUT);
}
}
- private void dismissCling(){
+ private void dismissCling() {
+ UiObject2 splashScreen = null;
+ if (mDevice.getDisplaySizeDp().x < TAB_MIN_WIDTH) {
+ splashScreen = mDevice.wait(Until.findObject(
+ By.pkg(PACKAGE_NAME).depth(0).clazz(View.class).desc("Got it")), LONG_TIMEOUT);
+ } else {
+ splashScreen = mDevice.wait(Until.findObject(
+ By.pkg(PACKAGE_NAME).depth(0).clazz(View.class)), LONG_TIMEOUT);
+ if (splashScreen != null) {
+ assertEquals("Childcount shoudl be 0", 0, splashScreen.getChildCount());
+ assertNull("Parent shoud be null", splashScreen.getParent());
+ assertEquals("Only one object exists by view class", 1, mDevice.wait(Until.findObjects(
+ By.pkg(PACKAGE_NAME).clazz(View.class)), LONG_TIMEOUT).size());
+ }
+ }
+ if (splashScreen != null) {
+ splashScreen.clickAndWait(Until.newWindow(), SHORT_TIMEOUT);
+ }
+
UiObject2 rightArrow = null;
short counter = 8;
while ((rightArrow = mDevice.wait(Until.findObject(By.res(
- RES_PACKAGE_NAME, "right_arrow_touch")), LONG_TIMEOUT)) != null && counter > 0) {
+ PACKAGE_NAME, "right_arrow_touch")), LONG_TIMEOUT)) != null && counter > 0) {
rightArrow.click();
--counter;
}
UiObject2 gotIt = mDevice.wait(Until.findObject(
- By.res(RES_PACKAGE_NAME, "done_button").text("Got it")), LONG_TIMEOUT);
+ By.res(PACKAGE_NAME, "done_button").text("Got it")), LONG_TIMEOUT);
if (gotIt != null) {
gotIt.click();
}