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 17 package com.example.android.apis.app; 18 19 import android.app.Notification; 20 import android.app.NotificationManager; 21 import android.content.Context; 22 import android.content.Intent; 23 import android.os.Handler; 24 import android.os.IBinder; 25 import android.test.MoreAsserts; 26 import android.test.ServiceTestCase; 27 import android.test.suitebuilder.annotation.MediumTest; 28 import android.test.suitebuilder.annotation.SmallTest; 29 30 /** 31 * This is a simple framework for a test of a Service. See {@link android.test.ServiceTestCase 32 * ServiceTestCase} for more information on how to write and extend service tests. 33 * 34 * To run this test, you can type: 35 * adb shell am instrument -w \ 36 * -e class com.example.android.apis.app.LocalServiceTest \ 37 * com.example.android.apis.tests/android.test.InstrumentationTestRunner 38 */ 39 public class LocalServiceTest extends ServiceTestCase<LocalService> { 40 41 public LocalServiceTest() { 42 super(LocalService.class); 43 } 44 45 @Override 46 protected void setUp() throws Exception { 47 super.setUp(); 48 } 49 50 /** 51 * The name 'test preconditions' is a convention to signal that if this 52 * test doesn't pass, the test case was not set up properly and it might 53 * explain any and all failures in other tests. This is not guaranteed 54 * to run before other tests, as junit uses reflection to find the tests. 55 */ 56 @SmallTest 57 public void testPreconditions() { 58 } 59 60 /** 61 * Test basic startup/shutdown of Service 62 */ 63 @SmallTest 64 public void testStartable() { 65 Intent startIntent = new Intent(); 66 startIntent.setClass(getContext(), LocalService.class); 67 startService(startIntent); 68 } 69 70 /** 71 * Test binding to service 72 */ 73 @MediumTest 74 public void testBindable() { 75 Intent startIntent = new Intent(); 76 startIntent.setClass(getContext(), LocalService.class); 77 IBinder service = bindService(startIntent); 78 } 79 80 } 81