ToastTest.java revision f013e1afd1e68af5e3b868c26a653bbfb39538f8
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 com.android.statusbartest; 18 19import android.app.ListActivity; 20import android.app.PendingIntent; 21import android.widget.ArrayAdapter; 22import android.view.View; 23import android.widget.ListView; 24import android.content.Intent; 25import android.os.Bundle; 26import android.os.Handler; 27import android.util.Log; 28import android.net.Uri; 29import android.os.SystemClock; 30import android.view.Gravity; 31import android.widget.RemoteViews; 32import android.widget.Toast; 33import android.widget.TextView; 34import android.os.PowerManager; 35 36public class ToastTest extends TestActivity 37{ 38 private final static String TAG = "ToastTest"; 39 40 Handler mHandler = new Handler(); 41 Toast mToast1; 42 Toast mToast2; 43 44 @Override 45 protected String tag() { 46 return TAG; 47 } 48 49 @Override 50 protected Test[] tests() { 51 return mTests; 52 } 53 54 private Test[] mTests = new Test[] { 55 new Test("Make Toast #1") { 56 public void run() 57 { 58 mToast1 = Toast.makeText(ToastTest.this, "hi 1", Toast.LENGTH_SHORT); 59 } 60 }, 61 62 new Test("Show Toast #1") { 63 public void run() 64 { 65 mToast1.show(); 66 } 67 }, 68 69 new Test("Update Toast #1") { 70 public void run() 71 { 72 TextView view = new TextView(ToastTest.this); 73 view.setText("replaced!"); 74 mToast1.setView(view); 75 mToast1.show(); 76 } 77 }, 78 79 new Test("Make Toast #2") { 80 public void run() 81 { 82 mToast2 = Toast.makeText(ToastTest.this, "hi 2", Toast.LENGTH_SHORT); 83 } 84 }, 85 86 new Test("Show Toast #2") { 87 public void run() 88 { 89 mToast2.show(); 90 } 91 }, 92 93 new Test("Gravity Toast LEFT") { 94 public void run() 95 { 96 Toast toast = Toast.makeText(ToastTest.this, "LEFT", Toast.LENGTH_SHORT); 97 toast.setGravity(Gravity.LEFT, 0, 0); 98 toast.show(); 99 } 100 }, 101 102 new Test("Gravity Toast FILL_HORIZONTAL") { 103 public void run() 104 { 105 Toast toast = Toast.makeText(ToastTest.this, "FILL_HORIZONTAL", 106 Toast.LENGTH_SHORT); 107 toast.setGravity(Gravity.FILL_HORIZONTAL, 0, 0); 108 toast.show(); 109 } 110 }, 111 112 }; 113} 114 115