| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser.download; | 5 package org.chromium.chrome.browser.download; |
| 6 | 6 |
| 7 import android.app.DownloadManager; | 7 import android.app.DownloadManager; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.database.Cursor; | 9 import android.database.Cursor; |
| 10 import android.os.Environment; | 10 import android.os.Environment; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 ApplicationUtils.waitForLibraryDependencies(getInstrumentation()); | 211 ApplicationUtils.waitForLibraryDependencies(getInstrumentation()); |
| 212 final Context context = getInstrumentation().getTargetContext().getAppli
cationContext(); | 212 final Context context = getInstrumentation().getTargetContext().getAppli
cationContext(); |
| 213 | 213 |
| 214 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 214 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 215 @Override | 215 @Override |
| 216 public void run() { | 216 public void run() { |
| 217 mSavedDownloadManagerService = DownloadManagerService.setDownloa
dManagerService( | 217 mSavedDownloadManagerService = DownloadManagerService.setDownloa
dManagerService( |
| 218 new TestDownloadManagerService(context, new SystemDownlo
adNotifier(context), | 218 new TestDownloadManagerService(context, new SystemDownlo
adNotifier(context), |
| 219 new Handler(), UPDATE_DELAY_MILLIS)); | 219 new Handler(), UPDATE_DELAY_MILLIS)); |
| 220 DownloadController.setDownloadNotificationService( | 220 DownloadController.setDownloadNotificationService( |
| 221 DownloadManagerService.getDownloadManagerService(context
)); | 221 DownloadManagerService.getDownloadManagerService()); |
| 222 } | 222 } |
| 223 }); | 223 }); |
| 224 } | 224 } |
| 225 | 225 |
| 226 @Override | 226 @Override |
| 227 protected void tearDown() throws Exception { | 227 protected void tearDown() throws Exception { |
| 228 cleanUpAllDownloads(); | 228 cleanUpAllDownloads(); |
| 229 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 229 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 230 @Override | 230 @Override |
| 231 public void run() { | 231 public void run() { |
| 232 DownloadManagerService.setDownloadManagerService(mSavedDownloadM
anagerService); | 232 DownloadManagerService.setDownloadManagerService(mSavedDownloadM
anagerService); |
| 233 DownloadController.setDownloadNotificationService(mSavedDownload
ManagerService); | 233 DownloadController.setDownloadNotificationService(mSavedDownload
ManagerService); |
| 234 } | 234 } |
| 235 }); | 235 }); |
| 236 super.tearDown(); | 236 super.tearDown(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 protected void deleteFilesInDownloadDirectory(String...filenames) { | 239 protected void deleteFilesInDownloadDirectory(String...filenames) { |
| 240 for (String filename : filenames) { | 240 for (String filename : filenames) { |
| 241 final File fileToDelete = new File(DOWNLOAD_DIRECTORY, filename); | 241 final File fileToDelete = new File(DOWNLOAD_DIRECTORY, filename); |
| 242 if (fileToDelete.exists()) { | 242 if (fileToDelete.exists()) { |
| 243 assertTrue("Could not delete file that would block this test", | 243 assertTrue("Could not delete file that would block this test", |
| 244 fileToDelete.delete()); | 244 fileToDelete.delete()); |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 } | 248 } |
| OLD | NEW |