blob: d84d2f8c03b7c304708836482676c24e2cdaa5e6 [file] [log] [blame]
Yu Shan Emily Lauc19ee792009-08-28 10:44:14 -07001/*
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
17package com.android.music.tests;
18
19import android.app.Instrumentation;
20import com.android.music.TrackBrowserActivity;
21import android.view.KeyEvent;
22import android.widget.ListView;
23
24import android.test.ActivityInstrumentationTestCase2;
25import android.test.suitebuilder.annotation.LargeTest;
26
27/**
28 * Junit / Instrumentation test case for the Music Player
29 */
30
31public 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 Laub1808db2009-09-25 00:27:32 -070058 public void testPlay30sMP3() throws Exception {
Yu Shan Emily Lauc19ee792009-08-28 10:44:14 -070059 // Launch the songs list. Pick the fisrt song and play
60 try {
61 Instrumentation inst = getInstrumentation();
Yu Shan Emily Lau71a020a2009-10-26 21:55:38 -070062 //Make sure the song list shown up
63 Thread.sleep(2000);
Yu Shan Emily Lauc19ee792009-08-28 10:44:14 -070064 inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
65 mTrackList = getActivity().getListView();
Yu Shan Emily Lau71a020a2009-10-26 21:55:38 -070066 int scrollCount = mTrackList.getMaxScrollAmount();
Yu Shan Emily Lauc19ee792009-08-28 10:44:14 -070067 //Make sure there is at least one song in the sdcard
Yu Shan Emily Lau71a020a2009-10-26 21:55:38 -070068 if (scrollCount != -1) {
Yu Shan Emily Lauc19ee792009-08-28 10:44:14 -070069 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 Lau82b4bf72009-09-20 21:26:37 -070078
79 @LargeTest
Yu Shan Emily Laub1808db2009-09-25 00:27:32 -070080 public void testLaunchMusicPlayer() throws Exception {
Yu Shan Emily Lau82b4bf72009-09-20 21:26:37 -070081 // 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 Laub1808db2009-09-25 00:27:32 -070090}