| OLD | NEW |
| 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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #import "base/test/ios/wait_util.h" | 13 #import "base/test/ios/wait_util.h" |
| 14 #include "ios/chrome/browser/chrome_paths.h" | 14 #include "ios/chrome/browser/chrome_paths.h" |
| 15 #include "ios/chrome/browser/dom_distiller/distiller_viewer.h" | 15 #include "ios/chrome/browser/dom_distiller/distiller_viewer.h" |
| 16 #include "ios/chrome/browser/reading_list/offline_url_utils.h" |
| 16 #include "ios/web/public/test/test_web_thread_bundle.h" | 17 #include "ios/web/public/test/test_web_thread_bundle.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 class DistillerViewerTest : public dom_distiller::DistillerViewerInterface { | 22 class DistillerViewerTest : public dom_distiller::DistillerViewerInterface { |
| 22 public: | 23 public: |
| 23 DistillerViewerTest(const GURL& url, | 24 DistillerViewerTest(const GURL& url, |
| 24 const DistillationFinishedCallback& callback) | 25 const DistillationFinishedCallback& callback) |
| 25 : dom_distiller::DistillerViewerInterface(nil, nil) { | 26 : dom_distiller::DistillerViewerInterface(nil, nil) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 40 MockURLDownloader(base::FilePath path) | 41 MockURLDownloader(base::FilePath path) |
| 41 : URLDownloader(nil, | 42 : URLDownloader(nil, |
| 42 nil, | 43 nil, |
| 43 path, | 44 path, |
| 44 base::Bind(&MockURLDownloader::OnEndDownload, | 45 base::Bind(&MockURLDownloader::OnEndDownload, |
| 45 base::Unretained(this)), | 46 base::Unretained(this)), |
| 46 base::Bind(&MockURLDownloader::OnEndRemove, | 47 base::Bind(&MockURLDownloader::OnEndRemove, |
| 47 base::Unretained(this))) {} | 48 base::Unretained(this))) {} |
| 48 | 49 |
| 49 void RemoveOfflineFilesDirectory() { | 50 void RemoveOfflineFilesDirectory() { |
| 50 base::DeleteFile(OfflineRootDirectoryPath(), true); | 51 base::DeleteFile(reading_list::OfflineRootDirectoryPath(base_directory_), |
| 52 true); |
| 51 } | 53 } |
| 52 | 54 |
| 53 void ClearCompletionTrackers() { | 55 void ClearCompletionTrackers() { |
| 54 downloaded_files_.clear(); | 56 downloaded_files_.clear(); |
| 55 removed_files_.clear(); | 57 removed_files_.clear(); |
| 56 } | 58 } |
| 57 | 59 |
| 58 bool CheckExistenceOfOfflineURLPagePath(const GURL& url) { | 60 bool CheckExistenceOfOfflineURLPagePath(const GURL& url) { |
| 59 return base::PathExists(OfflinePageAbsolutePath(url)); | 61 return base::PathExists( |
| 62 reading_list::OfflinePageAbsolutePath(base_directory_, url)); |
| 60 } | 63 } |
| 61 | 64 |
| 62 void FakeWorking() { working_ = true; } | 65 void FakeWorking() { working_ = true; } |
| 63 | 66 |
| 64 void FakeEndWorking() { | 67 void FakeEndWorking() { |
| 65 working_ = false; | 68 working_ = false; |
| 66 HandleNextTask(); | 69 HandleNextTask(); |
| 67 } | 70 } |
| 68 | 71 |
| 69 std::vector<GURL> downloaded_files_; | 72 std::vector<GURL> downloaded_files_; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 ASSERT_TRUE(std::find(downloader_->downloaded_files_.begin(), | 182 ASSERT_TRUE(std::find(downloader_->downloaded_files_.begin(), |
| 180 downloader_->downloaded_files_.end(), | 183 downloader_->downloaded_files_.end(), |
| 181 url) != downloader_->downloaded_files_.end()); | 184 url) != downloader_->downloaded_files_.end()); |
| 182 ASSERT_TRUE(std::find(downloader_->removed_files_.begin(), | 185 ASSERT_TRUE(std::find(downloader_->removed_files_.begin(), |
| 183 downloader_->removed_files_.end(), | 186 downloader_->removed_files_.end(), |
| 184 url) != downloader_->removed_files_.end()); | 187 url) != downloader_->removed_files_.end()); |
| 185 ASSERT_TRUE(downloader_->CheckExistenceOfOfflineURLPagePath(url)); | 188 ASSERT_TRUE(downloader_->CheckExistenceOfOfflineURLPagePath(url)); |
| 186 } | 189 } |
| 187 | 190 |
| 188 } // namespace | 191 } // namespace |
| OLD | NEW |