1792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project/*
2792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
3792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project *
4792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
5792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project * you may not use this file except in compliance with the License.
6792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project * You may obtain a copy of the License at
7792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project *
8792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
9792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project *
10792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software
11792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
12792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project * See the License for the specific language governing permissions and
14792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project * limitations under the License.
15792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project */
16792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
17792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectpackage com.android.music.tests.functional;
18792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
19792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.app.Activity;
20792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.content.*;
21792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.app.Instrumentation;
22792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.content.Intent;
23792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.test.ActivityInstrumentationTestCase;
24792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.test.suitebuilder.annotation.LargeTest;
25792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.util.Log;
26792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.view.KeyEvent;
27792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.net.Uri;
28792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.os.Environment;
29792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.provider.MediaStore;
30792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.content.ContentResolver;
31792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.content.pm.ActivityInfo;
32792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.database.Cursor;
33792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.content.Intent;
34792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.content.BroadcastReceiver;
35792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport android.content.IntentFilter;
36792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
37792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport com.android.music.CreatePlaylist;
38792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport com.android.music.TrackBrowserActivity;
39792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport com.android.music.MusicUtils;
40792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
41792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport com.android.music.tests.MusicPlayerNames;
42792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
43792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectimport java.io.*;
44792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
45792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project/**
46792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project * Junit / Instrumentation test case for the TrackBrowserActivity
47792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
48792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project */
49792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Projectpublic class TestSongs extends ActivityInstrumentationTestCase <TrackBrowserActivity>{
50792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    private static String TAG = "musicplayertests";
51792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
52792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    public TestSongs() {
53792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        super("com.android.music",TrackBrowserActivity.class);
54792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    }
55792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
56792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    @Override
57792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    protected void setUp() throws Exception {
58792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        super.setUp();
59792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    }
60792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
61792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    @Override
62792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    protected void tearDown() throws Exception {
63792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        super.tearDown();
64792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    }
65792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
66792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    /**
67792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     * Add 10 new playlists with unsorted title order
68792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     */
69792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    public void addNewPlaylist() throws Exception{
70792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      Instrumentation inst = getInstrumentation();
71792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      for (int i=0; i< MusicPlayerNames.NO_OF_PLAYLIST; i++){
72792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        inst.invokeContextMenuAction(getActivity(), MusicUtils.Defs.NEW_PLAYLIST, 0);
73792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        Thread.sleep(MusicPlayerNames.WAIT_SHORT_TIME);
74792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        //Remove the default playlist name
75792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        for (int j=0; j< MusicPlayerNames.DEFAULT_PLAYLIST_LENGTH; j++)
76792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project          inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DEL);
77792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        inst.sendStringSync(MusicPlayerNames.unsortedPlaylistTitle[i]);
78792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
79792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
80792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        Thread.sleep(MusicPlayerNames.WAIT_LONG_TIME);
81792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
82792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        Thread.sleep(MusicPlayerNames.WAIT_LONG_TIME);
83792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      }
84792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    }
85792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
86792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    private void copy(File src, File dst) throws IOException {
87792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        InputStream in = new FileInputStream(src);
88792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        OutputStream out = new FileOutputStream(dst);
89792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
90792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        // Transfer bytes from in to out
91792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        byte[] buf = new byte[1024];
92792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        int len;
93792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        while ((len = in.read(buf)) > 0) {
94792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project            out.write(buf, 0, len);
95792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        }
96792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        in.close();
97792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        out.close();
98792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        Log.v(TAG, "Copy file");
99792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      }
100792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
101792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      //Rescan the sdcard after copy the file
102792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      private void rescanSdcard() throws Exception{
103792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        Intent scanIntent = new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
104792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project             + Environment.getExternalStorageDirectory()));
105792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        Log.v(TAG,"start the intent");
106792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED);
107792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        intentFilter.addDataScheme("file");
108792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        getActivity().sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
109792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project            + Environment.getExternalStorageDirectory())));
110792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project          Thread.sleep(MusicPlayerNames.WAIT_VERY_LONG_TIME);
111792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      }
112792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
113792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
114792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    /**
115792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     * Test case 1: tests the new playlist added with sorted order.
116792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     * Verification: The new playlist title should be sorted in alphabetical order
117792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     */
118792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    @LargeTest
119792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    public void testAddPlaylist() throws Exception{
120792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      Cursor mCursor;
121792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      addNewPlaylist();
122792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
123792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      //Verify the new playlist is created, check the playlist table
124792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      String[] cols = new String[] {
125792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project          MediaStore.Audio.Playlists.NAME
126792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      };
127792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      ContentResolver resolver = getActivity().getContentResolver();
128792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      if (resolver == null) {
129792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        System.out.println("resolver = null");
130792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      } else {
131792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        String whereclause = MediaStore.Audio.Playlists.NAME + " != ''";
132792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        mCursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
133792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project          cols, whereclause, null,
134792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project          MediaStore.Audio.Playlists.NAME);
135792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        //Check the new playlist
136792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        mCursor.moveToFirst();
137792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
138792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        for (int j=0;j<10;j++){
139792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project          assertEquals("New sorted Playlist title:", MusicPlayerNames.expectedPlaylistTitle[j], mCursor.getString(0));
140792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project          mCursor.moveToNext();
141792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        }
142792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      }
143792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    }
144792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
145792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    /**
146792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     * Test case 2: Set a song as ringtone
147792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     * Test case precondition: The testing device should wipe data before
148792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     * run the test case.
149792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     * Verification: The count of audio.media.is_ringtone equal to 1.
150792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     */
151792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    @LargeTest
152792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    public void testSetRingtone() throws Exception{
153792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      Cursor mCursor;
154792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      Instrumentation inst = getInstrumentation();
155792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      inst.invokeContextMenuAction(getActivity(), MusicUtils.Defs.USE_AS_RINGTONE, 0);
156792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      //This only check if there only 1 ringtone set in music player
157792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      ContentResolver resolver = getActivity().getContentResolver();
158792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      if (resolver == null) {
159792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        System.out.println("resolver = null");
160792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      } else {
161792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        String whereclause = MediaStore.Audio.Media.IS_RINGTONE + " = 1";
162792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        mCursor = resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
163792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project           null, whereclause, null, null);
164792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        //Check the new playlist
165792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        mCursor.moveToFirst();
166792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        int isRingtoneSet = mCursor.getCount();
167792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        assertEquals(TAG, MusicPlayerNames.EXPECTED_NO_RINGTONE, isRingtoneSet);
168792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      }
169792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    }
170792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
171792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    /**
172792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     * Test case 3: Delete a song
173792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     * Test case precondition: Copy a song and rescan the sdcard
174792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     * Verification: The song is deleted from the sdcard and mediastore
175792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project     */
176792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    @LargeTest
177792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    public void testDeleteSong() throws Exception{
178792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      Instrumentation inst = getInstrumentation();
179792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      Cursor mCursor;
180792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
181792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      //Copy a song from the golden directory
182792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      Log.v(TAG, "Copy a temp file to the sdcard");
183792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      File goldenfile = new File(MusicPlayerNames.GOLDENSONG);
184792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      File toBeDeleteSong = new File(MusicPlayerNames.DELETESONG);
185792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      copy(goldenfile, toBeDeleteSong);
186792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      rescanSdcard();
187792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
188792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      //Delete the file from music player
189792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      Thread.sleep(MusicPlayerNames.WAIT_LONG_TIME);
190792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      inst.sendStringSync(MusicPlayerNames.TOBEDELETESONGNAME);
191792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      Thread.sleep(MusicPlayerNames.WAIT_LONG_TIME);
192792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      inst.invokeContextMenuAction(getActivity(), MusicUtils.Defs.DELETE_ITEM, 0);
193792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
194792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
195792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      Thread.sleep(MusicPlayerNames.WAIT_LONG_TIME);
196792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
197792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      //Clear the search string
198792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      for (int j=0; j< MusicPlayerNames.TOBEDELETESONGNAME.length(); j++)
199792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project          inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DEL);
200792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
201792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      //Verfiy the item is removed from sdcard
202792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      File checkDeletedFile = new File(MusicPlayerNames.DELETESONG);
203792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      assertFalse(TAG, checkDeletedFile.exists());
204792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
205792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      ContentResolver resolver = getActivity().getContentResolver();
206792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      if (resolver == null) {
207792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        System.out.println("resolver = null");
208792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      } else {
209792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        String whereclause = MediaStore.Audio.Media.DISPLAY_NAME + " = '" +
210792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        MusicPlayerNames.TOBEDELETESONGNAME + "'";
211792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        mCursor = resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
212792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project           null, whereclause, null, null);
213792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        boolean isEmptyCursor = mCursor.moveToFirst();
214792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project        assertFalse(TAG,isEmptyCursor);
215792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project      }
216792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project    }
217792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project}
218792a2206a4f05f6bd13fce902d3663892d2947afThe Android Open Source Project
219