1/*
2 * Copyright (C) 2008 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.app.cts;
18
19import android.app.Activity;
20import android.app.TabActivity;
21import android.content.Intent;
22import android.os.Bundle;
23import android.widget.TabHost;
24
25public class MockTabActivity extends TabActivity {
26
27    private static final String TAB1 = "tab1";
28    private static final String TAB2 = "tab2";
29    private static final String TAB3 = "tab3";
30
31    public boolean isOnChildTitleChangedCalled;
32    public boolean isOnPostCreateCalled;
33    public boolean isOnSaveInstanceStateCalled;
34    public boolean isOnContentChangedCalled;
35    public static boolean isOnRestoreInstanceStateCalled;
36
37    @Override
38    protected void onCreate(Bundle savedInstanceState) {
39        super.onCreate(savedInstanceState);
40        final TabHost tabHost = getTabHost();
41
42        tabHost.addTab(tabHost.newTabSpec(TAB1).setIndicator(TAB1)
43                .setContent(new Intent(this, ChildTabActivity.class)));
44
45        tabHost.addTab(tabHost.newTabSpec(TAB2).setIndicator(TAB2)
46                .setContent(new Intent(this, MockActivity.class)));
47
48        tabHost.addTab(tabHost.newTabSpec(TAB3).setIndicator(TAB3).setContent(
49                new Intent(this, AppStubActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
50
51    }
52
53    @Override
54    protected void onChildTitleChanged(Activity childActivity, CharSequence title) {
55        super.onChildTitleChanged(childActivity, title);
56        isOnChildTitleChangedCalled = true;
57    }
58
59    @Override
60    protected void onPostCreate(Bundle icicle) {
61        super.onPostCreate(icicle);
62        isOnPostCreateCalled = true;
63    }
64
65    @Override
66    protected void onRestoreInstanceState(Bundle state) {
67        super.onRestoreInstanceState(state);
68        isOnRestoreInstanceStateCalled = true;
69    }
70
71    @Override
72    protected void onSaveInstanceState(Bundle outState) {
73        super.onSaveInstanceState(outState);
74        isOnSaveInstanceStateCalled = true;
75    }
76
77    @Override
78    public void onContentChanged() {
79        super.onContentChanged();
80        isOnContentChangedCalled = true;
81    }
82}
83