Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/MediaResourceGetterTest.java

Issue 467173002: Allowing metadata to be read from blob urls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding null check Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/MediaResourceGetter.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.pm.PackageManager; 9 import android.content.pm.PackageManager;
10 import android.media.MediaMetadataRetriever; 10 import android.media.MediaMetadataRetriever;
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 public void testConfigure_File_Allowed_Exception() { 419 public void testConfigure_File_Allowed_Exception() {
420 final String path = "/mnt/sdcard/test"; 420 final String path = "/mnt/sdcard/test";
421 final String url = "file://" + path; 421 final String url = "file://" + path;
422 mFakeMRG.mFileExists = true; 422 mFakeMRG.mFileExists = true;
423 mFakeMRG.mThrowExceptionInConfigure = true; 423 mFakeMRG.mThrowExceptionInConfigure = true;
424 assertFalse(mFakeMRG.configure(mMockContext, url, "", null)); 424 assertFalse(mFakeMRG.configure(mMockContext, url, "", null));
425 assertNull(mFakeMRG.mPath); 425 assertNull(mFakeMRG.mPath);
426 } 426 }
427 427
428 @SmallTest 428 @SmallTest
429 public void testConfigure_Blob_Disallow_Null_Cache() {
430 final String path = "/data/data/" + null + "/cache/";
431 final String url = path;
432 mFakeMRG.mFileExists = true;
433 mFakeMRG.mThrowExceptionInConfigure = true;
434 assertFalse(mFakeMRG.configure(mMockContext, url, "", null));
435 assertNull(mFakeMRG.mPath);
436 }
437
438 @SmallTest
439 public void testConfigure_Blob_Disallowed_Incomplete_Path() {
440 final String path = "/data/data/";
441 final String url = path;
442 mFakeMRG.mFileExists = true;
443 mFakeMRG.mThrowExceptionInConfigure = true;
444 assertFalse(mFakeMRG.configure(mMockContext, url, "", null));
445 assertNull(mFakeMRG.mPath);
446 }
447
448 @SmallTest
449 public void testConfigure_Blob_Disallowed_Unknown_Path() {
450 final String path = "/unknown/path/";
451 final String url = path;
452 mFakeMRG.mFileExists = true;
453 mFakeMRG.mThrowExceptionInConfigure = true;
454 assertFalse(mFakeMRG.configure(mMockContext, url, "", null));
455 assertNull(mFakeMRG.mPath);
456 }
457
458 @SmallTest
459 public void testConfigure_Blob_Disallowed_Other_Application() {
460 final String path = "/data/data/org.some.other.app/cache/";
461 final String url = path;
462 mFakeMRG.mFileExists = true;
463 mFakeMRG.mThrowExceptionInConfigure = true;
464 assertFalse(mFakeMRG.configure(mMockContext, url, "", null));
465 assertNull(mFakeMRG.mPath);
466 }
467
468 @SmallTest
429 public void testExtract_NoMetadata() { 469 public void testExtract_NoMetadata() {
430 mFakeMRG.mFileExists = true; 470 mFakeMRG.mFileExists = true;
431 assertEquals(sEmptyMetadata, mFakeMRG.extract( 471 assertEquals(sEmptyMetadata, mFakeMRG.extract(
432 mMockContext, TEST_FILE_URL, null, null)); 472 mMockContext, TEST_FILE_URL, null, null));
433 assertEquals("configured successfully when we shouldn't have", 473 assertEquals("configured successfully when we shouldn't have",
434 TEST_FILE_PATH, mFakeMRG.mPath); // tricky 474 TEST_FILE_PATH, mFakeMRG.mPath); // tricky
435 } 475 }
436 476
437 @SmallTest 477 @SmallTest
438 public void testExtract_WithMetadata_ValidDuration() { 478 public void testExtract_WithMetadata_ValidDuration() {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 assertTrue(MediaResourceGetter.androidDeviceOk( 555 assertTrue(MediaResourceGetter.androidDeviceOk(
516 "GT-I9100", android.os.Build.VERSION_CODES.JELLY_BEAN)); 556 "GT-I9100", android.os.Build.VERSION_CODES.JELLY_BEAN));
517 } 557 }
518 558
519 @SmallTest 559 @SmallTest
520 public void testAndroidDeviceOk_GoodModel_AnyVersion() { 560 public void testAndroidDeviceOk_GoodModel_AnyVersion() {
521 assertTrue(MediaResourceGetter.androidDeviceOk( 561 assertTrue(MediaResourceGetter.androidDeviceOk(
522 "Happy Device", android.os.Build.VERSION_CODES.ICE_CREAM_SANDWIC H)); 562 "Happy Device", android.os.Build.VERSION_CODES.ICE_CREAM_SANDWIC H));
523 } 563 }
524 } 564 }
OLDNEW
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/MediaResourceGetter.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698