| 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; |
| 11 import android.net.ConnectivityManager; | 11 import android.net.ConnectivityManager; |
| 12 import android.net.Uri; |
| 12 import android.test.InstrumentationTestCase; | 13 import android.test.InstrumentationTestCase; |
| 13 import android.test.mock.MockContext; | 14 import android.test.mock.MockContext; |
| 14 import android.test.suitebuilder.annotation.SmallTest; | 15 import android.test.suitebuilder.annotation.SmallTest; |
| 15 import android.util.SparseArray; | 16 import android.util.SparseArray; |
| 16 | 17 |
| 17 import org.chromium.content.browser.MediaResourceGetter.MediaMetadata; | 18 import org.chromium.content.browser.MediaResourceGetter.MediaMetadata; |
| 18 | 19 |
| 19 import java.io.File; | 20 import java.io.File; |
| 20 import java.util.Collections; | 21 import java.util.Collections; |
| 21 import java.util.HashMap; | 22 import java.util.HashMap; |
| 22 import java.util.Map; | 23 import java.util.Map; |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * Tests for MediaResourceGetter. | 26 * Tests for MediaResourceGetter. |
| 26 */ | 27 */ |
| 27 @SuppressLint("SdCardPath") | 28 @SuppressLint("SdCardPath") |
| 28 public class MediaResourceGetterTest extends InstrumentationTestCase { | 29 public class MediaResourceGetterTest extends InstrumentationTestCase { |
| 29 private static final String TEST_HTTP_URL = "http://example.com"; | 30 private static final String TEST_HTTP_URL = "http://example.com"; |
| 30 private static final String TEST_USER_AGENT = // Anything, really | 31 private static final String TEST_USER_AGENT = // Anything, really |
| 31 "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 " | 32 "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 " |
| 32 + "(KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"; | 33 + "(KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"; |
| 33 private static final String TEST_FILE_PATH = "/mnt/sdcard/test"; | 34 private static final String TEST_FILE_PATH = "/mnt/sdcard/test"; |
| 34 private static final String TEST_FILE_URL = "file://" + TEST_FILE_PATH; | 35 private static final String TEST_FILE_URL = "file://" + TEST_FILE_PATH; |
| 36 private static final String TEST_CONTENT_URI = |
| 37 "content://com.android.providers.media.documents/document/video:113"
; |
| 35 private static final String TEST_COOKIES = "yum yum yum!"; | 38 private static final String TEST_COOKIES = "yum yum yum!"; |
| 36 private static final MediaMetadata sEmptyMetadata = new MediaMetadata(0, 0,
0, false); | 39 private static final MediaMetadata sEmptyMetadata = new MediaMetadata(0, 0,
0, false); |
| 37 private static final String sExternalStorageDirectory = "/test_external_stor
age"; | 40 private static final String sExternalStorageDirectory = "/test_external_stor
age"; |
| 38 | 41 |
| 39 private static final Map<String, String> sHeadersCookieOnly; | 42 private static final Map<String, String> sHeadersCookieOnly; |
| 40 private static final Map<String, String> sHeadersCookieAndUA; | 43 private static final Map<String, String> sHeadersCookieAndUA; |
| 41 private static final Map<String, String> sHeadersUAOnly; | 44 private static final Map<String, String> sHeadersUAOnly; |
| 42 static { | 45 static { |
| 43 Map<String, String> headers = new HashMap<String, String>(); | 46 Map<String, String> headers = new HashMap<String, String>(); |
| 44 headers.put("Cookie", TEST_COOKIES); | 47 headers.put("Cookie", TEST_COOKIES); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 * Helper class that fakes functionality we cannot perform without real | 93 * Helper class that fakes functionality we cannot perform without real |
| 91 * media resources. The class being faked here has been architected | 94 * media resources. The class being faked here has been architected |
| 92 * carefully to allow most of the functionality to be tested. What remains | 95 * carefully to allow most of the functionality to be tested. What remains |
| 93 * here is overrides of trivial functionality. | 96 * here is overrides of trivial functionality. |
| 94 */ | 97 */ |
| 95 private static class FakeMediaResourceGetter extends MediaResourceGetter { | 98 private static class FakeMediaResourceGetter extends MediaResourceGetter { |
| 96 // Read these back in tests to ensure proper values passed through | 99 // Read these back in tests to ensure proper values passed through |
| 97 String mUri = null; | 100 String mUri = null; |
| 98 Map<String, String> mHeaders = null; | 101 Map<String, String> mHeaders = null; |
| 99 String mPath = null; | 102 String mPath = null; |
| 103 String mContentUri = null; |
| 100 int mFd; | 104 int mFd; |
| 101 long mOffset; | 105 long mOffset; |
| 102 long mLength; | 106 long mLength; |
| 103 | 107 |
| 104 // Write these before tests to configure functionality | 108 // Write these before tests to configure functionality |
| 105 SparseArray<String> mMetadata = null; | 109 SparseArray<String> mMetadata = null; |
| 106 Integer mNetworkType = null; | 110 Integer mNetworkType = null; |
| 107 boolean mThrowExceptionInConfigure = false; | 111 boolean mThrowExceptionInConfigure = false; |
| 108 boolean mThrowExceptionInExtract = false; | 112 boolean mThrowExceptionInExtract = false; |
| 109 boolean mFileExists = false; | 113 boolean mFileExists = false; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 133 @Override | 137 @Override |
| 134 public void configure(String path) { | 138 public void configure(String path) { |
| 135 if (mThrowExceptionInConfigure) { | 139 if (mThrowExceptionInConfigure) { |
| 136 throw new RuntimeException("test exception"); | 140 throw new RuntimeException("test exception"); |
| 137 } | 141 } |
| 138 mPath = path; | 142 mPath = path; |
| 139 } | 143 } |
| 140 | 144 |
| 141 // Can't use a real MediaMetadataRetriever as we have no media | 145 // Can't use a real MediaMetadataRetriever as we have no media |
| 142 @Override | 146 @Override |
| 147 public void configure(Context context, Uri uri) { |
| 148 if (mThrowExceptionInConfigure) { |
| 149 throw new RuntimeException("test exception"); |
| 150 } |
| 151 mContentUri = uri.toString(); |
| 152 } |
| 153 |
| 154 // Can't use a real MediaMetadataRetriever as we have no media |
| 155 @Override |
| 143 public String extractMetadata(int key) { | 156 public String extractMetadata(int key) { |
| 144 if (mThrowExceptionInExtract) { | 157 if (mThrowExceptionInExtract) { |
| 145 throw new RuntimeException("test exception"); | 158 throw new RuntimeException("test exception"); |
| 146 } | 159 } |
| 147 if (mMetadata == null) { | 160 if (mMetadata == null) { |
| 148 return null; | 161 return null; |
| 149 } | 162 } |
| 150 return mMetadata.get(key); | 163 return mMetadata.get(key); |
| 151 } | 164 } |
| 152 | 165 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 301 |
| 289 @SmallTest | 302 @SmallTest |
| 290 public void testConfigure_Net_Allowed_Ethernet_Cookies_NoUA() { | 303 public void testConfigure_Net_Allowed_Ethernet_Cookies_NoUA() { |
| 291 mMockContext.mAllowPermission = true; | 304 mMockContext.mAllowPermission = true; |
| 292 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_ETHERNET; | 305 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_ETHERNET; |
| 293 assertTrue(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, | 306 assertTrue(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, |
| 294 TEST_COOKIES, null)); | 307 TEST_COOKIES, null)); |
| 295 assertEquals(TEST_HTTP_URL, mFakeMRG.mUri); | 308 assertEquals(TEST_HTTP_URL, mFakeMRG.mUri); |
| 296 assertEquals(sHeadersCookieOnly, mFakeMRG.mHeaders); | 309 assertEquals(sHeadersCookieOnly, mFakeMRG.mHeaders); |
| 297 assertNull(mFakeMRG.mPath); | 310 assertNull(mFakeMRG.mPath); |
| 311 assertNull(mFakeMRG.mContentUri); |
| 298 } | 312 } |
| 299 | 313 |
| 300 @SmallTest | 314 @SmallTest |
| 301 public void testConfigure_Net_Allowed_Wifi_Cookies_NoUA() { | 315 public void testConfigure_Net_Allowed_Wifi_Cookies_NoUA() { |
| 302 mMockContext.mAllowPermission = true; | 316 mMockContext.mAllowPermission = true; |
| 303 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_WIFI; | 317 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_WIFI; |
| 304 assertTrue(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, | 318 assertTrue(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, |
| 305 TEST_COOKIES, null)); | 319 TEST_COOKIES, null)); |
| 306 assertEquals(TEST_HTTP_URL, mFakeMRG.mUri); | 320 assertEquals(TEST_HTTP_URL, mFakeMRG.mUri); |
| 307 assertEquals(sHeadersCookieOnly, mFakeMRG.mHeaders); | 321 assertEquals(sHeadersCookieOnly, mFakeMRG.mHeaders); |
| 308 assertNull(mFakeMRG.mPath); | 322 assertNull(mFakeMRG.mPath); |
| 323 assertNull(mFakeMRG.mContentUri); |
| 309 } | 324 } |
| 310 | 325 |
| 311 @SmallTest | 326 @SmallTest |
| 312 public void testConfigure_Net_Allowed_Ethernet_NoCookies_NoUA() { | 327 public void testConfigure_Net_Allowed_Ethernet_NoCookies_NoUA() { |
| 313 mMockContext.mAllowPermission = true; | 328 mMockContext.mAllowPermission = true; |
| 314 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_ETHERNET; | 329 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_ETHERNET; |
| 315 assertTrue(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, | 330 assertTrue(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, |
| 316 "", null)); | 331 "", null)); |
| 317 assertEquals(TEST_HTTP_URL, mFakeMRG.mUri); | 332 assertEquals(TEST_HTTP_URL, mFakeMRG.mUri); |
| 318 assertEquals(Collections.emptyMap(), mFakeMRG.mHeaders); | 333 assertEquals(Collections.emptyMap(), mFakeMRG.mHeaders); |
| 319 assertNull(mFakeMRG.mPath); | 334 assertNull(mFakeMRG.mPath); |
| 335 assertNull(mFakeMRG.mContentUri); |
| 320 } | 336 } |
| 321 | 337 |
| 322 @SmallTest | 338 @SmallTest |
| 323 public void testConfigure_Net_Allowed_Ethernet_Cookies_WithUA() { | 339 public void testConfigure_Net_Allowed_Ethernet_Cookies_WithUA() { |
| 324 mMockContext.mAllowPermission = true; | 340 mMockContext.mAllowPermission = true; |
| 325 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_ETHERNET; | 341 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_ETHERNET; |
| 326 assertTrue(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, | 342 assertTrue(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, |
| 327 TEST_COOKIES, TEST_USER_AGENT)); | 343 TEST_COOKIES, TEST_USER_AGENT)); |
| 328 assertEquals(TEST_HTTP_URL, mFakeMRG.mUri); | 344 assertEquals(TEST_HTTP_URL, mFakeMRG.mUri); |
| 329 assertEquals(sHeadersCookieAndUA, mFakeMRG.mHeaders); | 345 assertEquals(sHeadersCookieAndUA, mFakeMRG.mHeaders); |
| 330 assertNull(mFakeMRG.mPath); | 346 assertNull(mFakeMRG.mPath); |
| 347 assertNull(mFakeMRG.mContentUri); |
| 331 } | 348 } |
| 332 | 349 |
| 333 @SmallTest | 350 @SmallTest |
| 334 public void testConfigure_Net_Allowed_Ethernet_NoCookies_WithUA() { | 351 public void testConfigure_Net_Allowed_Ethernet_NoCookies_WithUA() { |
| 335 mMockContext.mAllowPermission = true; | 352 mMockContext.mAllowPermission = true; |
| 336 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_ETHERNET; | 353 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_ETHERNET; |
| 337 assertTrue(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, | 354 assertTrue(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, |
| 338 "", TEST_USER_AGENT)); | 355 "", TEST_USER_AGENT)); |
| 339 assertEquals(TEST_HTTP_URL, mFakeMRG.mUri); | 356 assertEquals(TEST_HTTP_URL, mFakeMRG.mUri); |
| 340 assertEquals(sHeadersUAOnly, mFakeMRG.mHeaders); | 357 assertEquals(sHeadersUAOnly, mFakeMRG.mHeaders); |
| 341 assertNull(mFakeMRG.mPath); | 358 assertNull(mFakeMRG.mPath); |
| 359 assertNull(mFakeMRG.mContentUri); |
| 342 } | 360 } |
| 343 | 361 |
| 344 @SmallTest | 362 @SmallTest |
| 345 public void testConfigure_Net_Allowed_Ethernet_Exception() { | 363 public void testConfigure_Net_Allowed_Ethernet_Exception() { |
| 346 mMockContext.mAllowPermission = true; | 364 mMockContext.mAllowPermission = true; |
| 347 mFakeMRG.mThrowExceptionInConfigure = true; | 365 mFakeMRG.mThrowExceptionInConfigure = true; |
| 348 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_ETHERNET; | 366 mFakeMRG.mNetworkType = ConnectivityManager.TYPE_ETHERNET; |
| 349 assertFalse(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, | 367 assertFalse(mFakeMRG.configure(mMockContext, TEST_HTTP_URL, |
| 350 "", TEST_USER_AGENT)); | 368 "", TEST_USER_AGENT)); |
| 351 assertNull(mFakeMRG.mUri); | 369 assertNull(mFakeMRG.mUri); |
| 352 assertNull(mFakeMRG.mHeaders); | 370 assertNull(mFakeMRG.mHeaders); |
| 353 } | 371 } |
| 354 | 372 |
| 355 @SmallTest | 373 @SmallTest |
| 356 public void testConfigure_Net_Allowed_LocalHost_WithNoNetwork() { | 374 public void testConfigure_Net_Allowed_LocalHost_WithNoNetwork() { |
| 357 String[] localHostUrls = { | 375 String[] localHostUrls = { |
| 358 "http://LocalHost", | 376 "http://LocalHost", |
| 359 "https://127.0.0.1/", | 377 "https://127.0.0.1/", |
| 360 "http://[::1]:8888/", | 378 "http://[::1]:8888/", |
| 361 }; | 379 }; |
| 362 mMockContext.mAllowPermission = true; | 380 mMockContext.mAllowPermission = true; |
| 363 mFakeMRG.mNetworkType = null; | 381 mFakeMRG.mNetworkType = null; |
| 364 for (String localHostUrl : localHostUrls) { | 382 for (String localHostUrl : localHostUrls) { |
| 365 assertTrue(mFakeMRG.configure(mMockContext, localHostUrl, | 383 assertTrue(mFakeMRG.configure(mMockContext, localHostUrl, |
| 366 TEST_COOKIES, TEST_USER_AGENT)); | 384 TEST_COOKIES, TEST_USER_AGENT)); |
| 367 assertEquals(localHostUrl, mFakeMRG.mUri); | 385 assertEquals(localHostUrl, mFakeMRG.mUri); |
| 368 assertEquals(sHeadersCookieAndUA, mFakeMRG.mHeaders); | 386 assertEquals(sHeadersCookieAndUA, mFakeMRG.mHeaders); |
| 369 assertNull(mFakeMRG.mPath); | 387 assertNull(mFakeMRG.mPath); |
| 388 assertNull(mFakeMRG.mContentUri); |
| 370 } | 389 } |
| 371 } | 390 } |
| 372 | 391 |
| 373 @SmallTest | 392 @SmallTest |
| 374 public void testConfigure_File_Allowed_MntSdcard() { | 393 public void testConfigure_File_Allowed_MntSdcard() { |
| 375 final String path = "/mnt/sdcard/test"; | 394 final String path = "/mnt/sdcard/test"; |
| 376 final String url = "file://" + path; | 395 final String url = "file://" + path; |
| 377 mFakeMRG.mFileExists = true; | 396 mFakeMRG.mFileExists = true; |
| 378 assertTrue(mFakeMRG.configure(mMockContext, url, "", null)); | 397 assertTrue(mFakeMRG.configure(mMockContext, url, "", null)); |
| 379 assertEquals(path, mFakeMRG.mPath); | 398 assertEquals(path, mFakeMRG.mPath); |
| 380 assertNull(mFakeMRG.mUri); | 399 assertNull(mFakeMRG.mUri); |
| 400 assertNull(mFakeMRG.mContentUri); |
| 381 assertNull(mFakeMRG.mHeaders); | 401 assertNull(mFakeMRG.mHeaders); |
| 382 } | 402 } |
| 383 | 403 |
| 384 @SmallTest | 404 @SmallTest |
| 385 public void testConfigure_File_Allowed_Sdcard() { | 405 public void testConfigure_File_Allowed_Sdcard() { |
| 386 final String path = "/sdcard/test"; | 406 final String path = "/sdcard/test"; |
| 387 final String url = "file://" + path; | 407 final String url = "file://" + path; |
| 388 mFakeMRG.mFileExists = true; | 408 mFakeMRG.mFileExists = true; |
| 389 assertTrue(mFakeMRG.configure(mMockContext, url, "", null)); | 409 assertTrue(mFakeMRG.configure(mMockContext, url, "", null)); |
| 390 assertEquals(path, mFakeMRG.mPath); | 410 assertEquals(path, mFakeMRG.mPath); |
| 391 assertNull(mFakeMRG.mUri); | 411 assertNull(mFakeMRG.mUri); |
| 412 assertNull(mFakeMRG.mContentUri); |
| 392 assertNull(mFakeMRG.mHeaders); | 413 assertNull(mFakeMRG.mHeaders); |
| 393 } | 414 } |
| 394 | 415 |
| 395 @SmallTest | 416 @SmallTest |
| 396 public void testConfigure_File_Allowed_Sdcard_DoesntExist() { | 417 public void testConfigure_File_Allowed_Sdcard_DoesntExist() { |
| 397 final String path = "/sdcard/test"; | 418 final String path = "/sdcard/test"; |
| 398 final String url = "file://" + path; | 419 final String url = "file://" + path; |
| 399 mFakeMRG.mFileExists = false; | 420 mFakeMRG.mFileExists = false; |
| 400 assertFalse(mFakeMRG.configure(mMockContext, url, "", null)); | 421 assertFalse(mFakeMRG.configure(mMockContext, url, "", null)); |
| 401 assertNull(mFakeMRG.mPath); | 422 assertNull(mFakeMRG.mPath); |
| 402 } | 423 } |
| 403 | 424 |
| 404 @SmallTest | 425 @SmallTest |
| 405 public void testConfigure_File_Allowed_ExternalStorage() { | 426 public void testConfigure_File_Allowed_ExternalStorage() { |
| 406 final String path = sExternalStorageDirectory + "/test"; | 427 final String path = sExternalStorageDirectory + "/test"; |
| 407 final String url = "file://" + path; | 428 final String url = "file://" + path; |
| 408 mFakeMRG.mFileExists = true; | 429 mFakeMRG.mFileExists = true; |
| 409 assertTrue(mFakeMRG.configure(mMockContext, url, "", null)); | 430 assertTrue(mFakeMRG.configure(mMockContext, url, "", null)); |
| 410 assertEquals(path, mFakeMRG.mPath); | 431 assertEquals(path, mFakeMRG.mPath); |
| 411 assertNull(mFakeMRG.mUri); | 432 assertNull(mFakeMRG.mUri); |
| 433 assertNull(mFakeMRG.mContentUri); |
| 412 assertNull(mFakeMRG.mHeaders); | 434 assertNull(mFakeMRG.mHeaders); |
| 413 } | 435 } |
| 414 | 436 |
| 415 @SmallTest | 437 @SmallTest |
| 416 public void testConfigure_File_Disallowed_Innocent() { | 438 public void testConfigure_File_Disallowed_Innocent() { |
| 417 final String path = "/malicious/path"; | 439 final String path = "/malicious/path"; |
| 418 final String url = "file://" + path; | 440 final String url = "file://" + path; |
| 419 mFakeMRG.mFileExists = true; | 441 mFakeMRG.mFileExists = true; |
| 420 assertFalse(mFakeMRG.configure(mMockContext, url, "", null)); | 442 assertFalse(mFakeMRG.configure(mMockContext, url, "", null)); |
| 421 assertNull(mFakeMRG.mPath); | 443 assertNull(mFakeMRG.mPath); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 public void testConfigure_Blob_Disallowed_Other_Application() { | 496 public void testConfigure_Blob_Disallowed_Other_Application() { |
| 475 final String path = "/data/data/org.some.other.app/cache/"; | 497 final String path = "/data/data/org.some.other.app/cache/"; |
| 476 final String url = path; | 498 final String url = path; |
| 477 mFakeMRG.mFileExists = true; | 499 mFakeMRG.mFileExists = true; |
| 478 mFakeMRG.mThrowExceptionInConfigure = true; | 500 mFakeMRG.mThrowExceptionInConfigure = true; |
| 479 assertFalse(mFakeMRG.configure(mMockContext, url, "", null)); | 501 assertFalse(mFakeMRG.configure(mMockContext, url, "", null)); |
| 480 assertNull(mFakeMRG.mPath); | 502 assertNull(mFakeMRG.mPath); |
| 481 } | 503 } |
| 482 | 504 |
| 483 @SmallTest | 505 @SmallTest |
| 506 public void testConfigure_Content_Uri_Allowed() { |
| 507 assertTrue(mFakeMRG.configure(mMockContext, TEST_CONTENT_URI, "", null))
; |
| 508 assertNull(mFakeMRG.mPath); |
| 509 assertNull(mFakeMRG.mUri); |
| 510 assertEquals(TEST_CONTENT_URI, mFakeMRG.mContentUri); |
| 511 } |
| 512 |
| 513 @SmallTest |
| 514 public void testConfigure_Content_Uri_Disallowed() { |
| 515 mFakeMRG.mThrowExceptionInConfigure = true; |
| 516 assertFalse(mFakeMRG.configure(mMockContext, TEST_CONTENT_URI, "", null)
); |
| 517 assertNull(mFakeMRG.mPath); |
| 518 assertNull(mFakeMRG.mUri); |
| 519 assertNull(mFakeMRG.mContentUri); |
| 520 } |
| 521 |
| 522 @SmallTest |
| 484 public void testExtract_NoMetadata() { | 523 public void testExtract_NoMetadata() { |
| 485 mFakeMRG.mFileExists = true; | 524 mFakeMRG.mFileExists = true; |
| 486 assertEquals(sEmptyMetadata, mFakeMRG.extract( | 525 assertEquals(sEmptyMetadata, mFakeMRG.extract( |
| 487 mMockContext, TEST_FILE_URL, null, null)); | 526 mMockContext, TEST_FILE_URL, null, null)); |
| 488 assertEquals("configured successfully when we shouldn't have", | 527 assertEquals("configured successfully when we shouldn't have", |
| 489 TEST_FILE_PATH, mFakeMRG.mPath); // tricky | 528 TEST_FILE_PATH, mFakeMRG.mPath); // tricky |
| 490 } | 529 } |
| 491 | 530 |
| 492 @SmallTest | 531 @SmallTest |
| 493 public void testExtract_WithMetadata_ValidDuration() { | 532 public void testExtract_WithMetadata_ValidDuration() { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 final MediaMetadata expected = new MediaMetadata(1, 2, 3, true); | 607 final MediaMetadata expected = new MediaMetadata(1, 2, 3, true); |
| 569 int fd = 1234; | 608 int fd = 1234; |
| 570 long offset = 1000; | 609 long offset = 1000; |
| 571 long length = 9000; | 610 long length = 9000; |
| 572 assertEquals(expected, mFakeMRG.extract(fd, offset, length)); | 611 assertEquals(expected, mFakeMRG.extract(fd, offset, length)); |
| 573 assertEquals(fd, mFakeMRG.mFd); | 612 assertEquals(fd, mFakeMRG.mFd); |
| 574 assertEquals(offset, mFakeMRG.mOffset); | 613 assertEquals(offset, mFakeMRG.mOffset); |
| 575 assertEquals(length, mFakeMRG.mLength); | 614 assertEquals(length, mFakeMRG.mLength); |
| 576 } | 615 } |
| 577 } | 616 } |
| OLD | NEW |