OLD | NEW |
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 Loading... |
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_Allowed_Data_Cache() { |
| 430 // This is not an actual app, so PACKAGE_NAME will be null |
| 431 final String path = "/data/data/" + null + "/cache/"; |
| 432 final String url = path; |
| 433 mFakeMRG.mFileExists = true; |
| 434 assertTrue(mFakeMRG.configure(mMockContext, url, "", null)); |
| 435 assertEquals(path, mFakeMRG.mPath); |
| 436 assertNull(mFakeMRG.mUri); |
| 437 assertNull(mFakeMRG.mHeaders); |
| 438 } |
| 439 |
| 440 @SmallTest |
| 441 public void testConfigure_Blob_Disallowed_Incomplete_Path() { |
| 442 final String path = "/data/data/"; |
| 443 final String url = path; |
| 444 mFakeMRG.mFileExists = true; |
| 445 mFakeMRG.mThrowExceptionInConfigure = true; |
| 446 assertFalse(mFakeMRG.configure(mMockContext, url, "", null)); |
| 447 assertNull(mFakeMRG.mPath); |
| 448 } |
| 449 |
| 450 @SmallTest |
| 451 public void testConfigure_Blob_Disallowed_Unknown_Path() { |
| 452 final String path = "/unknown/path/"; |
| 453 final String url = path; |
| 454 mFakeMRG.mFileExists = true; |
| 455 mFakeMRG.mThrowExceptionInConfigure = true; |
| 456 assertFalse(mFakeMRG.configure(mMockContext, url, "", null)); |
| 457 assertNull(mFakeMRG.mPath); |
| 458 } |
| 459 |
| 460 @SmallTest |
| 461 public void testConfigure_Blob_Disallowed_Other_Application() { |
| 462 final String path = "/data/data/org.some.other.app/cache/"; |
| 463 final String url = path; |
| 464 mFakeMRG.mFileExists = true; |
| 465 mFakeMRG.mThrowExceptionInConfigure = true; |
| 466 assertFalse(mFakeMRG.configure(mMockContext, url, "", null)); |
| 467 assertNull(mFakeMRG.mPath); |
| 468 } |
| 469 |
| 470 @SmallTest |
429 public void testExtract_NoMetadata() { | 471 public void testExtract_NoMetadata() { |
430 mFakeMRG.mFileExists = true; | 472 mFakeMRG.mFileExists = true; |
431 assertEquals(sEmptyMetadata, mFakeMRG.extract( | 473 assertEquals(sEmptyMetadata, mFakeMRG.extract( |
432 mMockContext, TEST_FILE_URL, null, null)); | 474 mMockContext, TEST_FILE_URL, null, null)); |
433 assertEquals("configured successfully when we shouldn't have", | 475 assertEquals("configured successfully when we shouldn't have", |
434 TEST_FILE_PATH, mFakeMRG.mPath); // tricky | 476 TEST_FILE_PATH, mFakeMRG.mPath); // tricky |
435 } | 477 } |
436 | 478 |
437 @SmallTest | 479 @SmallTest |
438 public void testExtract_WithMetadata_ValidDuration() { | 480 public void testExtract_WithMetadata_ValidDuration() { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 assertTrue(MediaResourceGetter.androidDeviceOk( | 557 assertTrue(MediaResourceGetter.androidDeviceOk( |
516 "GT-I9100", android.os.Build.VERSION_CODES.JELLY_BEAN)); | 558 "GT-I9100", android.os.Build.VERSION_CODES.JELLY_BEAN)); |
517 } | 559 } |
518 | 560 |
519 @SmallTest | 561 @SmallTest |
520 public void testAndroidDeviceOk_GoodModel_AnyVersion() { | 562 public void testAndroidDeviceOk_GoodModel_AnyVersion() { |
521 assertTrue(MediaResourceGetter.androidDeviceOk( | 563 assertTrue(MediaResourceGetter.androidDeviceOk( |
522 "Happy Device", android.os.Build.VERSION_CODES.ICE_CREAM_SANDWIC
H)); | 564 "Happy Device", android.os.Build.VERSION_CODES.ICE_CREAM_SANDWIC
H)); |
523 } | 565 } |
524 } | 566 } |
OLD | NEW |