blob: 64c6c865ebda1856059e220296ac8e3ecb7ca7da [file] [log] [blame]
Mike Doddd3b009a2015-08-11 11:16:59 -07001/*
2 * Copyright (C) 2015 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.messaging;
18
19import android.content.Context;
20import android.test.AndroidTestCase;
21
22/*
23 * Base class for service tests that takes care of housekeeping that is common amongst basic test
24 * cases.
25 */
26public abstract class BugleTestCase extends AndroidTestCase {
27
28 static {
29 // Set flag during loading of test cases to prevent application initialization starting
30 setTestsRunning();
31 }
32
33 public static void setTestsRunning() {
34 BugleApplication.setTestsRunning();
35 }
36
37 @Override
38 protected void setUp() throws Exception {
39 super.setUp();
40 TestUtil.testSetup(super.getContext(), this);
41 }
42
43 @Override
44 protected void tearDown() throws Exception {
45 super.tearDown();
46 TestUtil.testTeardown(this);
47 }
48
49 @Override
50 public Context getContext() {
51 // This doesn't really get the "application context" - just the fake context
52 // that the factory has been initialized with for each test case.
53 return Factory.get().getApplicationContext();
54 }
55
56 public Context getTestContext() {
57 return super.getContext();
58 }
59}