LauncherRotationStressTest.java revision 8c7a2b7d023d9f24ff7db3ba2e02672aa006c45b
1/* 2 * Copyright (C) 2011 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 17package com.android.launcher2.stress; 18 19 20import com.android.launcher2.Launcher; 21 22import android.content.pm.ActivityInfo; 23import android.os.SystemClock; 24import android.test.ActivityInstrumentationTestCase2; 25import android.test.TimedTest; 26import android.util.Log; 27 28/** 29 * Run rotation stress test using Launcher2 for 50 iterations. 30 */ 31public class LauncherRotationStressTest extends ActivityInstrumentationTestCase2<Launcher> { 32 33 private static final int NUM_ITERATIONS = 50; 34 private static final String LOG_TAG = "LauncherRotationStressTest"; 35 36 public LauncherRotationStressTest() { 37 super(Launcher.class); 38 } 39 40 @Override 41 protected void setUp() throws Exception { 42 super.setUp(); 43 } 44 45 @Override 46 protected void tearDown() throws Exception { 47 super.tearDown(); 48 } 49 50 @TimedTest(includeDetailedStats=true) 51 public void testLauncherRotationStress() throws Exception { 52 Launcher launcher = getActivity(); 53 for (int i = 0; i < NUM_ITERATIONS; i++) { 54 Log.i(LOG_TAG, "Starting LauncherRotationStressTest " + (i + 1) + " of " + 55 NUM_ITERATIONS); 56 getInstrumentation().waitForIdleSync(); 57 SystemClock.sleep(500); 58 launcher.setRequestedOrientation( 59 ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 60 getInstrumentation().waitForIdleSync(); 61 SystemClock.sleep(500); 62 launcher.setRequestedOrientation( 63 ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 64 Log.i(LOG_TAG, "Finished LauncherRotationStressTest " + (i + 1) + " of " + 65 NUM_ITERATIONS); 66 } 67 } 68} 69