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.RepetitiveTest;
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 int WAIT_TIME_MS = 500;
35    private static final String LOG_TAG = "LauncherRotationStressTest";
36
37    public LauncherRotationStressTest() {
38        super(Launcher.class);
39    }
40
41    @Override
42    protected void setUp() throws Exception {
43        super.setUp();
44    }
45
46    @Override
47    protected void tearDown() throws Exception {
48        super.tearDown();
49    }
50
51    @RepetitiveTest(numIterations=NUM_ITERATIONS)
52    public void testLauncherRotationStress() throws Exception {
53        Launcher launcher = getActivity();
54        getInstrumentation().waitForIdleSync();
55        SystemClock.sleep(WAIT_TIME_MS);
56        launcher.setRequestedOrientation(
57                ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
58        getInstrumentation().waitForIdleSync();
59        SystemClock.sleep(WAIT_TIME_MS);
60        launcher.setRequestedOrientation(
61                ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
62    }
63}
64