summaryrefslogtreecommitdiffstats
path: root/chrome/browser/android/download/download_manager_service_unittest.cc
diff options
context:
space:
mode:
authorqinmin <qinmin@chromium.org>2016-03-25 21:13:38 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-26 04:14:58 +0000
commit30ac0f57a0fcae1a13e6374c05927a04caf526e5 (patch)
treebb56349228c53a3ee588e25971e935af6996f5fb /chrome/browser/android/download/download_manager_service_unittest.cc
parent220c7edc3243b54970a13d91c690b2dffc15732d (diff)
downloadchromium_src-30ac0f57a0fcae1a13e6374c05927a04caf526e5.zip
chromium_src-30ac0f57a0fcae1a13e6374c05927a04caf526e5.tar.gz
chromium_src-30ac0f57a0fcae1a13e6374c05927a04caf526e5.tar.bz2
Switch to use download GUID to indentify download items
Download GUID is introduced by http://crrev.com/eef62b0282ec19ebc040785d0b7ac36de398cbc1 Unlike download Id, the GUID can live across browser sessions and will not be reused. This change switches the java class to also use the GUID. Chrome will temporarily use the old download Id as the notification Id. This is because the android notification requires an int to identify it, rather than a string. In the future, we will generate the notification Id from java side. The download Ids generated by the Android DownloadManager are not affected by this CL. However, they are only used in OMA downloads and when we call addCompletedDownload(). BUG=593020 Review URL: https://codereview.chromium.org/1809203006 Cr-Commit-Position: refs/heads/master@{#383443}
Diffstat (limited to 'chrome/browser/android/download/download_manager_service_unittest.cc')
-rw-r--r--chrome/browser/android/download/download_manager_service_unittest.cc21
1 files changed, 13 insertions, 8 deletions
diff --git a/chrome/browser/android/download/download_manager_service_unittest.cc b/chrome/browser/android/download/download_manager_service_unittest.cc
index b987c8b..c5d60d7a 100644
--- a/chrome/browser/android/download/download_manager_service_unittest.cc
+++ b/chrome/browser/android/download/download_manager_service_unittest.cc
@@ -36,9 +36,10 @@ class DownloadManagerServiceTest : public testing::Test {
&manager_)),
finished_(false),
success_(false) {
- ON_CALL(manager_, GetDownload(_))
+ ON_CALL(manager_, GetDownloadByGuid(_))
.WillByDefault(
- ::testing::Invoke(this, &DownloadManagerServiceTest::GetDownload));
+ ::testing::Invoke(this,
+ &DownloadManagerServiceTest::GetDownloadByGuid));
}
void OnResumptionDone(bool success) {
@@ -46,12 +47,14 @@ class DownloadManagerServiceTest : public testing::Test {
success_ = success;
}
- void StartDownload(int download_id) {
+ void StartDownload(const std::string& download_guid) {
JNIEnv* env = base::android::AttachCurrentThread();
service_->set_resume_callback_for_testing(base::Bind(
&DownloadManagerServiceTest::OnResumptionDone, base::Unretained(this)));
service_->ResumeDownload(
- env, nullptr, download_id,
+ env, nullptr, 0, JavaParamRef<jstring>(
+ env, base::android::ConvertUTF8ToJavaString(
+ env, download_guid).obj()),
base::android::ConvertUTF8ToJavaString(env, "test").obj());
while (!finished_)
message_loop_.RunUntilIdle();
@@ -64,7 +67,9 @@ class DownloadManagerServiceTest : public testing::Test {
}
protected:
- content::DownloadItem* GetDownload(uint32_t) { return download_.get(); }
+ content::DownloadItem* GetDownloadByGuid(const std::string&) {
+ return download_.get();
+ }
base::MessageLoop message_loop_;
scoped_ptr<content::MockDownloadItem> download_;
@@ -78,7 +83,7 @@ class DownloadManagerServiceTest : public testing::Test {
// Test that resumption will fail if no download item is found before times out.
TEST_F(DownloadManagerServiceTest, ResumptionTimeOut) {
- StartDownload(1);
+ StartDownload("0000");
EXPECT_FALSE(success_);
}
@@ -86,13 +91,13 @@ TEST_F(DownloadManagerServiceTest, ResumptionTimeOut) {
// resumed.
TEST_F(DownloadManagerServiceTest, ResumptionWithResumableItem) {
CreateDownloadItem(true);
- StartDownload(1);
+ StartDownload("0000");
EXPECT_TRUE(success_);
}
// Test that resumption fails if the target download item is not resumable.
TEST_F(DownloadManagerServiceTest, ResumptionWithNonResumableItem) {
CreateDownloadItem(false);
- StartDownload(1);
+ StartDownload("0000");
EXPECT_FALSE(success_);
}