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

Side by Side Diff: ios/chrome/browser/reading_list/url_downloader_unittest.cc

Issue 2491383002: Use Distilled path instead of DistilledURL. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/reading_list/url_downloader.h" 5 #include "ios/chrome/browser/reading_list/url_downloader.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #import "base/mac/bind_objc_block.h" 10 #import "base/mac/bind_objc_block.h"
(...skipping 29 matching lines...) Expand all
40 MockURLDownloader(base::FilePath path) 40 MockURLDownloader(base::FilePath path)
41 : URLDownloader(nil, 41 : URLDownloader(nil,
42 nil, 42 nil,
43 path, 43 path,
44 base::Bind(&MockURLDownloader::OnEndDownload, 44 base::Bind(&MockURLDownloader::OnEndDownload,
45 base::Unretained(this)), 45 base::Unretained(this)),
46 base::Bind(&MockURLDownloader::OnEndRemove, 46 base::Bind(&MockURLDownloader::OnEndRemove,
47 base::Unretained(this))) {} 47 base::Unretained(this))) {}
48 48
49 void RemoveOfflineFilesDirectory() { 49 void RemoveOfflineFilesDirectory() {
50 base::DeleteFile(OfflineDirectoryPath(), true); 50 base::DeleteFile(OfflineRootDirectoryPath(), true);
51 } 51 }
52 52
53 void ClearCompletionTrackers() { 53 void ClearCompletionTrackers() {
54 downloaded_files_.clear(); 54 downloaded_files_.clear();
55 removed_files_.clear(); 55 removed_files_.clear();
56 } 56 }
57 57
58 bool CheckExistenceOfOfflineURLPagePath(const GURL& url) { 58 bool CheckExistenceOfOfflineURLPagePath(const GURL& url) {
59 return base::PathExists(OfflineURLPagePath(url)); 59 return base::PathExists(OfflinePageAbsolutePath(url));
60 } 60 }
61 61
62 void FakeWorking() { working_ = true; } 62 void FakeWorking() { working_ = true; }
63 63
64 void FakeEndWorking() { 64 void FakeEndWorking() {
65 working_ = false; 65 working_ = false;
66 HandleNextTask(); 66 HandleNextTask();
67 } 67 }
68 68
69 std::vector<GURL> downloaded_files_; 69 std::vector<GURL> downloaded_files_;
70 std::vector<GURL> removed_files_; 70 std::vector<GURL> removed_files_;
71 71
72 private: 72 private:
73 void DownloadURL(GURL url, bool offlineURLExists) override { 73 void DownloadURL(GURL url, bool offlineURLExists) override {
74 if (offlineURLExists) { 74 if (offlineURLExists) {
75 DownloadCompletionHandler(url, std::string(), DOWNLOAD_EXISTS); 75 DownloadCompletionHandler(url, std::string(), DOWNLOAD_EXISTS);
76 return; 76 return;
77 } 77 }
78 distiller_.reset(new DistillerViewerTest( 78 distiller_.reset(new DistillerViewerTest(
79 url, 79 url,
80 base::Bind(&URLDownloader::DistillerCallback, base::Unretained(this)))); 80 base::Bind(&URLDownloader::DistillerCallback, base::Unretained(this))));
81 } 81 }
82 82
83 void OnEndDownload(const GURL& url, 83 void OnEndDownload(const GURL& url,
84 SuccessState success, 84 SuccessState success,
85 const GURL& distilledURL, 85 const base::FilePath& distilled_path,
86 const std::string& title) { 86 const std::string& title) {
87 downloaded_files_.push_back(url); 87 downloaded_files_.push_back(url);
88 } 88 }
89 89
90 void OnEndRemove(const GURL& url, bool success) { 90 void OnEndRemove(const GURL& url, bool success) {
91 removed_files_.push_back(url); 91 removed_files_.push_back(url);
92 } 92 }
93 }; 93 };
94 94
95 namespace { 95 namespace {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 ASSERT_TRUE(std::find(downloader_->downloaded_files_.begin(), 179 ASSERT_TRUE(std::find(downloader_->downloaded_files_.begin(),
180 downloader_->downloaded_files_.end(), 180 downloader_->downloaded_files_.end(),
181 url) != downloader_->downloaded_files_.end()); 181 url) != downloader_->downloaded_files_.end());
182 ASSERT_TRUE(std::find(downloader_->removed_files_.begin(), 182 ASSERT_TRUE(std::find(downloader_->removed_files_.begin(),
183 downloader_->removed_files_.end(), 183 downloader_->removed_files_.end(),
184 url) != downloader_->removed_files_.end()); 184 url) != downloader_->removed_files_.end());
185 ASSERT_TRUE(downloader_->CheckExistenceOfOfflineURLPagePath(url)); 185 ASSERT_TRUE(downloader_->CheckExistenceOfOfflineURLPagePath(url));
186 } 186 }
187 187
188 } // namespace 188 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698