Yu Shan Emily Lau | c19ee79 | 2009-08-28 10:44:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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.android.music.tests; |
| 18 | |
| 19 | import android.app.Instrumentation; |
| 20 | import com.android.music.TrackBrowserActivity; |
| 21 | import android.view.KeyEvent; |
| 22 | import android.widget.ListView; |
| 23 | |
| 24 | import android.test.ActivityInstrumentationTestCase2; |
| 25 | import android.test.suitebuilder.annotation.LargeTest; |
| 26 | |
| 27 | /** |
| 28 | * Junit / Instrumentation test case for the Music Player |
| 29 | */ |
| 30 | |
| 31 | public class MusicPlayerStability extends ActivityInstrumentationTestCase2 <TrackBrowserActivity>{ |
| 32 | private static String TAG = "musicplayerstability"; |
| 33 | private static int PLAY_TIME = 30000; |
| 34 | private ListView mTrackList; |
| 35 | |
| 36 | public MusicPlayerStability() { |
| 37 | super("com.android.music",TrackBrowserActivity.class); |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | protected void setUp() throws Exception { |
| 42 | getActivity(); |
| 43 | super.setUp(); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | protected void tearDown() throws Exception { |
| 48 | super.tearDown(); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Test case 1: This test case is for the power and general stability |
| 53 | * measurment. We don't need to do the validation. This test case simply |
| 54 | * play the mp3 for 30 seconds then stop. |
| 55 | * The sdcard should have the target mp3 files. |
| 56 | */ |
| 57 | @LargeTest |
Yu Shan Emily Lau | b1808db | 2009-09-25 00:27:32 -0700 | [diff] [blame] | 58 | public void testPlay30sMP3() throws Exception { |
Yu Shan Emily Lau | c19ee79 | 2009-08-28 10:44:14 -0700 | [diff] [blame] | 59 | // Launch the songs list. Pick the fisrt song and play |
| 60 | try { |
| 61 | Instrumentation inst = getInstrumentation(); |
Yu Shan Emily Lau | 71a020a | 2009-10-26 21:55:38 -0700 | [diff] [blame] | 62 | //Make sure the song list shown up |
| 63 | Thread.sleep(2000); |
Yu Shan Emily Lau | c19ee79 | 2009-08-28 10:44:14 -0700 | [diff] [blame] | 64 | inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN); |
| 65 | mTrackList = getActivity().getListView(); |
Yu Shan Emily Lau | 71a020a | 2009-10-26 21:55:38 -0700 | [diff] [blame] | 66 | int scrollCount = mTrackList.getMaxScrollAmount(); |
Yu Shan Emily Lau | c19ee79 | 2009-08-28 10:44:14 -0700 | [diff] [blame] | 67 | //Make sure there is at least one song in the sdcard |
Yu Shan Emily Lau | 71a020a | 2009-10-26 21:55:38 -0700 | [diff] [blame] | 68 | if (scrollCount != -1) { |
Yu Shan Emily Lau | c19ee79 | 2009-08-28 10:44:14 -0700 | [diff] [blame] | 69 | inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER); |
| 70 | } else { |
| 71 | assertTrue("testPlayMP3", false); |
| 72 | } |
| 73 | Thread.sleep(PLAY_TIME); |
| 74 | } catch (Exception e) { |
| 75 | assertTrue("testPlayMP3", false); |
| 76 | } |
| 77 | } |
Yu Shan Emily Lau | 82b4bf7 | 2009-09-20 21:26:37 -0700 | [diff] [blame] | 78 | |
| 79 | @LargeTest |
Yu Shan Emily Lau | b1808db | 2009-09-25 00:27:32 -0700 | [diff] [blame] | 80 | public void testLaunchMusicPlayer() throws Exception { |
Yu Shan Emily Lau | 82b4bf7 | 2009-09-20 21:26:37 -0700 | [diff] [blame] | 81 | // Launch music player and sleep for 30 seconds to capture |
| 82 | // the music player power usage base line. |
| 83 | try { |
| 84 | Thread.sleep(PLAY_TIME); |
| 85 | } catch (Exception e) { |
| 86 | assertTrue("MusicPlayer Do Nothing", false); |
| 87 | } |
| 88 | assertTrue("MusicPlayer Do Nothing", true); |
| 89 | } |
Yu Shan Emily Lau | b1808db | 2009-09-25 00:27:32 -0700 | [diff] [blame] | 90 | } |