| 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 #include "chrome/browser/android/download/download_manager_service.h" | 5 #include "chrome/browser/android/download/download_manager_service.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 class BrowserContext; | 25 class BrowserContext; |
| 26 class ByteStreamReader; | 26 class ByteStreamReader; |
| 27 class DownloadManagerDelegate; | 27 class DownloadManagerDelegate; |
| 28 struct DownloadCreateInfo; | 28 struct DownloadCreateInfo; |
| 29 } | 29 } |
| 30 | 30 |
| 31 class MockDownloadManagerService : public DownloadManagerService { | 31 class MockDownloadManagerService : public DownloadManagerService { |
| 32 public: | 32 public: |
| 33 MockDownloadManagerService() | 33 MockDownloadManagerService() : DownloadManagerService() { |
| 34 : DownloadManagerService(base::android::AttachCurrentThread(), nullptr) { | |
| 35 ON_CALL(manager_, GetDownloadByGuid(_)).WillByDefault( | 34 ON_CALL(manager_, GetDownloadByGuid(_)).WillByDefault( |
| 36 ::testing::Invoke(this, | 35 ::testing::Invoke(this, |
| 37 &MockDownloadManagerService::GetDownloadByGuid)); | 36 &MockDownloadManagerService::GetDownloadByGuid)); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void CreateDownloadItem(bool can_resume) { | 39 void CreateDownloadItem(bool can_resume) { |
| 41 download_.reset(new content::MockDownloadItem()); | 40 download_.reset(new content::MockDownloadItem()); |
| 42 ON_CALL(*download_, CanResume()).WillByDefault( | 41 ON_CALL(*download_, CanResume()).WillByDefault( |
| 43 ::testing::Return(can_resume)); | 42 ::testing::Return(can_resume)); |
| 44 } | 43 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 StartDownload("0000"); | 101 StartDownload("0000"); |
| 103 EXPECT_TRUE(success_); | 102 EXPECT_TRUE(success_); |
| 104 } | 103 } |
| 105 | 104 |
| 106 // Test that resumption fails if the target download item is not resumable. | 105 // Test that resumption fails if the target download item is not resumable. |
| 107 TEST_F(DownloadManagerServiceTest, ResumptionWithNonResumableItem) { | 106 TEST_F(DownloadManagerServiceTest, ResumptionWithNonResumableItem) { |
| 108 service_->CreateDownloadItem(false); | 107 service_->CreateDownloadItem(false); |
| 109 StartDownload("0000"); | 108 StartDownload("0000"); |
| 110 EXPECT_FALSE(success_); | 109 EXPECT_FALSE(success_); |
| 111 } | 110 } |
| OLD | NEW |