Move test to a different CTS test and expand it.

Move the file deletion test from the thumbnails to the media test, which
is a better fit for this test, and expand it to also test the new "deletedata"
parameter.

Change-Id: I1fd5a8eafcea96203342c03e6c218dc171ef5d04
diff --git a/tests/tests/provider/src/android/provider/cts/MediaStore_Video_MediaTest.java b/tests/tests/provider/src/android/provider/cts/MediaStore_Video_MediaTest.java
index 7036e90..36612cf 100644
--- a/tests/tests/provider/src/android/provider/cts/MediaStore_Video_MediaTest.java
+++ b/tests/tests/provider/src/android/provider/cts/MediaStore_Video_MediaTest.java
@@ -17,26 +17,31 @@
 package android.provider.cts;
 
 
+import com.android.cts.stub.R;
+
 import android.content.ContentResolver;
 import android.content.ContentValues;
+import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
 import android.os.Environment;
 import android.os.cts.FileUtils;
 import android.provider.MediaStore;
 import android.provider.MediaStore.Video.Media;
-import android.test.InstrumentationTestCase;
+import android.provider.MediaStore.Video.VideoColumns;
+import android.test.AndroidTestCase;
 
 import java.io.File;
+import java.io.IOException;
 
-public class MediaStore_Video_MediaTest extends InstrumentationTestCase {
+public class MediaStore_Video_MediaTest extends AndroidTestCase {
     private ContentResolver mContentResolver;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
 
-        mContentResolver = getInstrumentation().getContext().getContentResolver();
+        mContentResolver = getContext().getContentResolver();
     }
 
     public void testGetContentUri() {
@@ -175,6 +180,24 @@
             // delete
             assertEquals(1, mContentResolver.delete(uri, null, null));
         }
+
+        // check that the video file is removed when deleting the database entry
+        Context context = getContext();
+        Uri videoUri = insertVideo(context);
+        File videofile = new File(Environment.getExternalStorageDirectory(), "testVideo.3gp");
+        assertTrue(videofile.exists());
+        mContentResolver.delete(videoUri, null, null);
+        assertFalse(videofile.exists());
+
+        // insert again, then delete with the "delete data" parameter set to false
+        videoUri = insertVideo(context);
+        assertTrue(videofile.exists());
+        Uri.Builder builder = videoUri.buildUpon();
+        builder.appendQueryParameter(MediaStore.PARAM_DELETE_DATA, "false");
+        mContentResolver.delete(builder.build(), null, null);
+        assertTrue(videofile.exists());
+        videofile.delete();
+
     }
 
     public void testStoreVideoMediaInternal() {
@@ -187,4 +210,13 @@
             // expected
         }
     }
+
+    private Uri insertVideo(Context context) throws IOException {
+        File file = new File(Environment.getExternalStorageDirectory(), "testVideo.3gp");
+        new FileCopyHelper(context).copyToExternalStorage(R.raw.testvideo, file);
+
+        ContentValues values = new ContentValues();
+        values.put(VideoColumns.DATA, file.getAbsolutePath());
+        return context.getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
+    }
 }
diff --git a/tests/tests/provider/src/android/provider/cts/MediaStore_Video_ThumbnailsTest.java b/tests/tests/provider/src/android/provider/cts/MediaStore_Video_ThumbnailsTest.java
index 16a4778..2a4b46c 100644
--- a/tests/tests/provider/src/android/provider/cts/MediaStore_Video_ThumbnailsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/MediaStore_Video_ThumbnailsTest.java
@@ -99,12 +99,6 @@
             assertFalse("thumbnail file should no longer exist", new File(path).exists());
         }
         c.close();
-
-        // not technically a thumbnail test, but needs testing anyway: check that the video file
-        // is removed when deleting the database entry
-        assertTrue(new File(Environment.getExternalStorageDirectory(), "testVideo.3gp").exists());
-        mResolver.delete(videoUri, null, null);
-        assertFalse(new File(Environment.getExternalStorageDirectory(), "testVideo.3gp").exists());
     }
 
     private Uri insertVideo() throws IOException {