StatusBarTest.java revision 9066cfe9886ac131c34d59ed0e2d287b0e3c0087
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 Expand in 3 sec.") {
66            public void run() {
67                mHandler.postDelayed(new Runnable() {
68                        public void run() {
69                            mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND);
70                        }
71                    }, 3000);
72            }
73        },
74        new Test("Disable Notifications in 3 sec.") {
75            public void run() {
76                mHandler.postDelayed(new Runnable() {
77                        public void run() {
78                            mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_ICONS);
79                        }
80                    }, 3000);
81            }
82        },
83        new Test("Disable Both in 3 sec.") {
84            public void run() {
85                mHandler.postDelayed(new Runnable() {
86                        public void run() {
87                            mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND
88                                    | StatusBarManager.DISABLE_NOTIFICATION_ICONS);
89                        }
90                    }, 3000);
91            }
92        },
93        new Test("Disable None in 3 sec.") {
94            public void run() {
95                mHandler.postDelayed(new Runnable() {
96                        public void run() {
97                            mStatusBarManager.disable(0);
98                        }
99                    }, 3000);
100            }
101        },
102        new Test("Notify in 3 sec.") {
103            public void run() {
104                mHandler.postDelayed(new Runnable() {
105                        public void run() {
106                            mNotificationManager.notify(1,
107                                    new Notification(StatusBarTest.this,
108                                            R.drawable.ic_statusbar_missedcall,
109                                            "tick tick tick",
110                                            System.currentTimeMillis()-(1000*60*60*24),
111                                            "(453) 123-2328",
112                                            "", null
113                                            ));
114                        }
115                    }, 3000);
116            }
117        },
118        new Test("Cancel Notification in 3 sec.") {
119            public void run() {
120                mHandler.postDelayed(new Runnable() {
121                        public void run() {
122                            mNotificationManager.cancel(1);
123                        }
124                    }, 3000);
125            }
126        },
127        new Test("Expand in 3 sec.") {
128            public void run() {
129                mHandler.postDelayed(new Runnable() {
130                        public void run() {
131                            mStatusBarManager.expand();
132                        }
133                    }, 3000);
134            }
135        },
136        new Test("Expand in 3 sec.") {
137            public void run() {
138                mHandler.postDelayed(new Runnable() {
139                        public void run() {
140                            mStatusBarManager.expand();
141                        }
142                    }, 3000);
143            }
144        },
145        new Test("Collapse in 3 sec.") {
146            public void run() {
147                mHandler.postDelayed(new Runnable() {
148                        public void run() {
149                            mStatusBarManager.collapse();
150                        }
151                    }, 3000);
152            }
153        },
154        new Test("Toggle in 3 sec.") {
155            public void run() {
156                mHandler.postDelayed(new Runnable() {
157                        public void run() {
158                            mStatusBarManager.toggle();
159                        }
160                    }, 3000);
161            }
162        },
163    };
164}
165