1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.wearable.sysapp.janktests; 18 19 import android.os.Bundle; 20 import android.support.test.jank.GfxMonitor; 21 import android.support.test.jank.JankTest; 22 import android.support.test.jank.JankTestBase; 23 import android.support.test.uiautomator.UiDevice; 24 25 /** 26 * Jank tests for scrolling & swiping off notification cards on wear 27 */ 28 public class CardsJankTest extends JankTestBase { 29 30 private UiDevice mDevice; 31 private SysAppTestHelper mHelper; 32 33 /* 34 * (non-Javadoc) 35 * @see junit.framework.TestCase#setUp() 36 */ 37 @Override 38 protected void setUp() throws Exception { 39 super.setUp(); 40 mDevice = UiDevice.getInstance(getInstrumentation()); 41 mHelper = SysAppTestHelper.getInstance(mDevice, this.getInstrumentation()); 42 mDevice.wakeUp(); 43 } 44 45 // Prepare device to start scrolling by tapping on the screen 46 // As this is done using demo cards a tap on screen will stop animation and show 47 // home screen 48 public void openScrollCard() throws Exception { 49 mHelper.hasDemoCards(); 50 mHelper.swipeUp(); 51 } 52 53 // Measure card scroll jank 54 55 @JankTest(beforeLoop = "openScrollCard", afterTest = "goBackHome", 56 expectedFrames = SysAppTestHelper.EXPECTED_FRAMES_CARDS_TEST) 57 @GfxMonitor(processName = "com.google.android.wearable.app") 58 public void testScrollCard() { 59 mHelper.swipeUp(); 60 } 61 62 // Preparing the cards to full view before dismissing them 63 64 public void openSwipeCard() throws Exception { 65 mHelper.hasDemoCards(); 66 mHelper.swipeUp(); 67 mHelper.swipeUp(); 68 } 69 70 // Measure jank when dismissing a card 71 72 @JankTest(beforeLoop = "openSwipeCard", afterTest = "goBackHome", 73 expectedFrames = SysAppTestHelper.EXPECTED_FRAMES_CARDS_TEST) 74 @GfxMonitor(processName = "com.google.android.wearable.app") 75 public void testSwipeCard() { 76 mHelper.swipeRight(); 77 } 78 79 // Ensuring that we head back to the first screen before launching the app again 80 public void goBackHome(Bundle metrics) { 81 mHelper.goBackHome(); 82 super.afterTest(metrics); 83 } 84 85 /* 86 * (non-Javadoc) 87 * @see android.test.InstrumentationTestCase#tearDown() 88 */ 89 @Override 90 protected void tearDown() throws Exception { 91 super.tearDown(); 92 } 93 94 } 95