14f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel/*
24f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * Copyright (C) 2015 The Android Open Source Project
34f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel *
44f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * Licensed under the Apache License, Version 2.0 (the "License");
54f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * you may not use this file except in compliance with the License.
64f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * You may obtain a copy of the License at
74f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel *
84f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel *      http://www.apache.org/licenses/LICENSE-2.0
94f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel *
104f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * Unless required by applicable law or agreed to in writing, software
114f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * distributed under the License is distributed on an "AS IS" BASIS,
124f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * See the License for the specific language governing permissions and
144f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * limitations under the License.
154f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel */
164f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel
174f26c041ad0429710d135d8e179eec8f44077ebeYury Khmelpackage android.windowanimationjank;
184f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel
194f26c041ad0429710d135d8e179eec8f44077ebeYury Khmelimport java.io.IOException;
204f26c041ad0429710d135d8e179eec8f44077ebeYury Khmelimport java.util.StringTokenizer;
214f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel
224f26c041ad0429710d135d8e179eec8f44077ebeYury Khmelimport android.support.test.jank.JankTestBase;
234f26c041ad0429710d135d8e179eec8f44077ebeYury Khmelimport android.support.test.uiautomator.UiDevice;
244f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel
254f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel/**
264f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * This adds additional system level jank monitor and its result is merged with primary monitor
274f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel * used in test.
284f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel */
294f26c041ad0429710d135d8e179eec8f44077ebeYury Khmelpublic abstract class WindowAnimationJankTestBase extends JankTestBase {
304f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    private static final String TAG = "WindowAnimationJankTestBase";
314f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel
324f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    protected WindowAnimationJankTestBase() {
334f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    }
344f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel
354f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    @Override
364f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    protected void setUp() throws Exception {
374f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel        super.setUp();
384f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel
394f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel        // fix device orientation
404f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel        getUiDevice().setOrientationNatural();
414f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel
424f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel        // Start from the home screen
434f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel        getUiDevice().pressHome();
444f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel        getUiDevice().waitForIdle();
454f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    }
464f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel
474f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    @Override
484f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    protected void tearDown() throws Exception {
494f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel        getUiDevice().unfreezeRotation();
504f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel        super.tearDown();
514f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    }
524f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel
534f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    protected UiDevice getUiDevice() {
544f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel        return UiDevice.getInstance(getInstrumentation());
554f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel    }
564f26c041ad0429710d135d8e179eec8f44077ebeYury Khmel}
57