1/*
2 * Copyright (C) 2007 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 android.view;
18
19import android.test.ActivityInstrumentationTestCase;
20import android.test.suitebuilder.annotation.MediumTest;
21
22public class RunQueueTest extends ActivityInstrumentationTestCase<RunQueue> {
23    public RunQueueTest() {
24        super("com.android.frameworks.coretests", RunQueue.class);
25    }
26
27    @Override
28    public void setUp() throws Exception {
29        super.setUp();
30    }
31
32    @MediumTest
33    public void testRunnableRan() throws Exception {
34        final RunQueue activity = getActivity();
35        getInstrumentation().waitForIdleSync();
36        assertTrue("The runnable did not run", activity.runnableRan);
37    }
38
39    @MediumTest
40    public void testRunnableCancelled() throws Exception {
41        final RunQueue activity = getActivity();
42        getInstrumentation().waitForIdleSync();
43        assertTrue("The runnable was not cancelled", activity.runnableCancelled);
44    }
45
46    @MediumTest
47    public void testListenerFired() throws Exception {
48        final RunQueue activity = getActivity();
49        getInstrumentation().waitForIdleSync();
50        assertTrue("The global layout listener did not fire", activity.globalLayout);
51    }
52
53    @MediumTest
54    public void testTreeObserverKilled() throws Exception {
55        final RunQueue activity = getActivity();
56        getInstrumentation().waitForIdleSync();
57        assertFalse("The view tree observer is still alive", activity.viewTreeObserver.isAlive());
58    }
59}
60