1d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/*
2d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Copyright (C) 2015 The Android Open Source Project
3d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd *
4d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Licensed under the Apache License, Version 2.0 (the "License");
5d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * you may not use this file except in compliance with the License.
6d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * You may obtain a copy of the License at
7d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd *
8d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd *      http://www.apache.org/licenses/LICENSE-2.0
9d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd *
10d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Unless required by applicable law or agreed to in writing, software
11d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * distributed under the License is distributed on an "AS IS" BASIS,
12d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * See the License for the specific language governing permissions and
14d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * limitations under the License.
15d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */
16d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpackage com.android.messaging.ui;
17d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
18d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.app.Activity;
19d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.view.ContextThemeWrapper;
20d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
21d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport com.android.messaging.BugleTestCase;
22d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport com.android.messaging.R;
23d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport com.android.messaging.TestUtil;
24d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
25d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/**
26d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Base class for activity unit test cases, provides boilerplate setup/teardown.
27d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */
28d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpublic abstract class BugleActivityUnitTestCase<T extends Activity> extends
29d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    android.test.ActivityUnitTestCase<T> {
30d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
31d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    static {
32d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        // Set flag during loading of test cases to prevent application initialization starting
33d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        BugleTestCase.setTestsRunning();
34d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    }
35d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
36d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    public BugleActivityUnitTestCase(final Class<T> activityClass) {
37d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        super(activityClass);
38d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    }
39d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
40d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    @SuppressWarnings("unchecked")
41d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    @Override
42d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    protected void setUp() throws Exception {
43d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        super.setUp();
44d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        TestUtil.testSetup(getInstrumentation().getTargetContext(), this);
45d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
46d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        setActivityContext(new ContextThemeWrapper(getInstrumentation().getTargetContext(),
47d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd                R.style.Theme_AppCompat_Light_DarkActionBar));
48d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    }
49d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd
50d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    @Override
51d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    protected void tearDown() throws Exception {
52d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        super.tearDown();
53d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd        TestUtil.testTeardown(this);
54d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd    }
55d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd}
56