StatusBarTest.java revision 4762c2d75a55e0854bbff2f996748116d4ab1a37
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 com.android.statusbartest;
18
19import android.app.ListActivity;
20import android.app.Notification;
21import android.app.NotificationManager;
22import android.widget.ArrayAdapter;
23import android.view.View;
24import android.widget.ListView;
25import android.content.Intent;
26import android.app.Notification;
27import android.app.NotificationManager;
28import android.app.StatusBarManager;
29import android.os.Vibrator;
30import android.os.Bundle;
31import android.os.Handler;
32import android.util.Log;
33import android.net.Uri;
34import android.os.SystemClock;
35import android.widget.RemoteViews;
36import android.widget.Toast;
37import android.os.PowerManager;
38
39public class StatusBarTest extends TestActivity
40{
41    private final static String TAG = "StatusBarTest";
42    StatusBarManager mStatusBarManager;
43    NotificationManager mNotificationManager;
44    Handler mHandler = new Handler();
45
46    @Override
47    protected String tag() {
48        return TAG;
49    }
50
51    @Override
52    protected Test[] tests() {
53        mStatusBarManager = (StatusBarManager)getSystemService(STATUS_BAR_SERVICE);
54        mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
55
56        return mTests;
57    }
58
59    private Test[] mTests = new Test[] {
60        new Test("Disable Alerts") {
61            public void run() {
62                mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_ALERTS);
63            }
64        },
65        new Test("Disable Ticker") {
66            public void run() {
67                mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_TICKER);
68            }
69        },
70        new Test("Disable Expand in 3 sec.") {
71            public void run() {
72                mHandler.postDelayed(new Runnable() {
73                        public void run() {
74                            mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND);
75                        }
76                    }, 3000);
77            }
78        },
79        new Test("Disable Notifications in 3 sec.") {
80            public void run() {
81                mHandler.postDelayed(new Runnable() {
82                        public void run() {
83                            mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_ICONS);
84                        }
85                    }, 3000);
86            }
87        },
88        new Test("Disable Expand + Notifications in 3 sec.") {
89            public void run() {
90                mHandler.postDelayed(new Runnable() {
91                        public void run() {
92                            mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND
93                                    | StatusBarManager.DISABLE_NOTIFICATION_ICONS);
94                        }
95                    }, 3000);
96            }
97        },
98        new Test("Enable everything") {
99            public void run() {
100                mStatusBarManager.disable(0);
101            }
102        },
103        new Test("Enable everything in 3 sec.") {
104            public void run() {
105                mHandler.postDelayed(new Runnable() {
106                        public void run() {
107                            mStatusBarManager.disable(0);
108                        }
109                    }, 3000);
110            }
111        },
112        new Test("Notify in 3 sec.") {
113            public void run() {
114                mHandler.postDelayed(new Runnable() {
115                        public void run() {
116                            mNotificationManager.notify(1,
117                                    new Notification(StatusBarTest.this,
118                                            R.drawable.ic_statusbar_missedcall,
119                                            "tick tick tick",
120                                            System.currentTimeMillis()-(1000*60*60*24),
121                                            "(453) 123-2328",
122                                            "", null
123                                            ));
124                        }
125                    }, 3000);
126            }
127        },
128        new Test("Cancel Notification in 3 sec.") {
129            public void run() {
130                mHandler.postDelayed(new Runnable() {
131                        public void run() {
132                            mNotificationManager.cancel(1);
133                        }
134                    }, 3000);
135            }
136        },
137        new Test("Expand") {
138            public void run() {
139                mStatusBarManager.expand();
140            }
141        },
142        new Test("Expand in 3 sec.") {
143            public void run() {
144                mHandler.postDelayed(new Runnable() {
145                        public void run() {
146                            mStatusBarManager.expand();
147                        }
148                    }, 3000);
149            }
150        },
151        new Test("Collapse in 3 sec.") {
152            public void run() {
153                mHandler.postDelayed(new Runnable() {
154                        public void run() {
155                            mStatusBarManager.collapse();
156                        }
157                    }, 3000);
158            }
159        },
160    };
161}
162