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

Side by Side Diff: chrome/browser/android/download/download_manager_service_unittest.cc

Issue 2160063002: Allow user to pause/resume incognito downloads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix clang warning Created 4 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 | « chrome/browser/android/download/download_manager_service.cc ('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 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 void StartDownload(const std::string& download_guid) { 72 void StartDownload(const std::string& download_guid) {
73 JNIEnv* env = base::android::AttachCurrentThread(); 73 JNIEnv* env = base::android::AttachCurrentThread();
74 service_->set_resume_callback_for_testing(base::Bind( 74 service_->set_resume_callback_for_testing(base::Bind(
75 &DownloadManagerServiceTest::OnResumptionDone, base::Unretained(this))); 75 &DownloadManagerServiceTest::OnResumptionDone, base::Unretained(this)));
76 service_->ResumeDownload( 76 service_->ResumeDownload(
77 env, nullptr, 77 env, nullptr,
78 JavaParamRef<jstring>( 78 JavaParamRef<jstring>(
79 env, 79 env,
80 base::android::ConvertUTF8ToJavaString(env, download_guid).obj())); 80 base::android::ConvertUTF8ToJavaString(env, download_guid).obj()),
81 false);
81 EXPECT_FALSE(success_); 82 EXPECT_FALSE(success_);
82 service_->OnHistoryQueryComplete(); 83 service_->OnHistoryQueryComplete();
83 while (!finished_) 84 while (!finished_)
84 message_loop_.RunUntilIdle(); 85 message_loop_.RunUntilIdle();
85 } 86 }
86 87
87 protected: 88 protected:
88 base::MessageLoop message_loop_; 89 base::MessageLoop message_loop_;
89 MockDownloadManagerService* service_; 90 MockDownloadManagerService* service_;
90 bool finished_; 91 bool finished_;
91 bool success_; 92 bool success_;
92 93
93 DISALLOW_COPY_AND_ASSIGN(DownloadManagerServiceTest); 94 DISALLOW_COPY_AND_ASSIGN(DownloadManagerServiceTest);
94 }; 95 };
95 96
96 // Test that resumption succeeds if the download item is found and can be 97 // Test that resumption succeeds if the download item is found and can be
97 // resumed. 98 // resumed.
98 TEST_F(DownloadManagerServiceTest, ResumptionWithResumableItem) { 99 TEST_F(DownloadManagerServiceTest, ResumptionWithResumableItem) {
99 service_->CreateDownloadItem(true); 100 service_->CreateDownloadItem(true);
100 StartDownload("0000"); 101 StartDownload("0000");
101 EXPECT_TRUE(success_); 102 EXPECT_TRUE(success_);
102 } 103 }
103 104
104 // 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.
105 TEST_F(DownloadManagerServiceTest, ResumptionWithNonResumableItem) { 106 TEST_F(DownloadManagerServiceTest, ResumptionWithNonResumableItem) {
106 service_->CreateDownloadItem(false); 107 service_->CreateDownloadItem(false);
107 StartDownload("0000"); 108 StartDownload("0000");
108 EXPECT_FALSE(success_); 109 EXPECT_FALSE(success_);
109 } 110 }
OLDNEW
« no previous file with comments | « chrome/browser/android/download/download_manager_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698