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

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

Issue 2707043002: [Reading List iOS] Store distillation date and size. (Closed)
Patch Set: Created 3 years, 10 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
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 bool fetching_pdf_; 94 bool fetching_pdf_;
95 95
96 private: 96 private:
97 void DownloadURL(const GURL& url, bool offline_url_exists) override { 97 void DownloadURL(const GURL& url, bool offline_url_exists) override {
98 if (offline_url_exists) { 98 if (offline_url_exists) {
99 DownloadCompletionHandler(url, std::string(), base::FilePath(), 99 DownloadCompletionHandler(url, std::string(), base::FilePath(),
100 DOWNLOAD_EXISTS); 100 DOWNLOAD_EXISTS);
101 return; 101 return;
102 } 102 }
103 original_url_ = url; 103 original_url_ = url;
104 saved_size_ = 0;
104 distiller_.reset(new DistillerViewerTest( 105 distiller_.reset(new DistillerViewerTest(
105 url, 106 url,
106 base::Bind(&URLDownloader::DistillerCallback, base::Unretained(this)), 107 base::Bind(&URLDownloader::DistillerCallback, base::Unretained(this)),
107 this, html_, redirect_url_, mime_type_)); 108 this, html_, redirect_url_, mime_type_));
108 } 109 }
109 110
110 void FetchPDFFile() override { fetching_pdf_ = true; } 111 void FetchPDFFile() override { fetching_pdf_ = true; }
111 112
112 void OnEndDownload(const GURL& url, 113 void OnEndDownload(const GURL& url,
113 const GURL& distilled_url, 114 const GURL& distilled_url,
114 SuccessState success, 115 SuccessState success,
115 const base::FilePath& distilled_path, 116 const base::FilePath& distilled_path,
117 int64_t size,
116 const std::string& title) { 118 const std::string& title) {
117 downloaded_files_.push_back(url); 119 downloaded_files_.push_back(url);
118 DCHECK_EQ(distilled_url, redirect_url_); 120 // Saved data is the string "html".
gambard 2017/02/22 12:30:16 No tests for images?
Olivier 2017/02/22 14:05:11 Added an image "image"
121 EXPECT_EQ(size, 4);
122 EXPECT_EQ(distilled_url, redirect_url_);
119 } 123 }
120 124
121 void OnEndRemove(const GURL& url, bool success) { 125 void OnEndRemove(const GURL& url, bool success) {
122 removed_files_.push_back(url); 126 removed_files_.push_back(url);
123 } 127 }
124 }; 128 };
125 129
126 namespace { 130 namespace {
127 class URLDownloaderTest : public testing::Test { 131 class URLDownloaderTest : public testing::Test {
128 public: 132 public:
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 ASSERT_TRUE(std::find(downloader_->downloaded_files_.begin(), 256 ASSERT_TRUE(std::find(downloader_->downloaded_files_.begin(),
253 downloader_->downloaded_files_.end(), 257 downloader_->downloaded_files_.end(),
254 url) != downloader_->downloaded_files_.end()); 258 url) != downloader_->downloaded_files_.end());
255 ASSERT_TRUE(std::find(downloader_->removed_files_.begin(), 259 ASSERT_TRUE(std::find(downloader_->removed_files_.begin(),
256 downloader_->removed_files_.end(), 260 downloader_->removed_files_.end(),
257 url) != downloader_->removed_files_.end()); 261 url) != downloader_->removed_files_.end());
258 ASSERT_TRUE(downloader_->CheckExistenceOfOfflineURLPagePath(url)); 262 ASSERT_TRUE(downloader_->CheckExistenceOfOfflineURLPagePath(url));
259 } 263 }
260 264
261 } // namespace 265 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698