OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/character_encoding.h" | 9 #include "chrome/browser/character_encoding.h" |
10 #include "chrome/browser/net/url_request_mock_util.h" | 10 #include "chrome/browser/net/url_request_mock_util.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 class SavePackageFinishedObserver : public content::DownloadManager::Observer { | 75 class SavePackageFinishedObserver : public content::DownloadManager::Observer { |
76 public: | 76 public: |
77 SavePackageFinishedObserver(content::DownloadManager* manager, | 77 SavePackageFinishedObserver(content::DownloadManager* manager, |
78 const base::Closure& callback) | 78 const base::Closure& callback) |
79 : download_manager_(manager), | 79 : download_manager_(manager), |
80 callback_(callback) { | 80 callback_(callback) { |
81 download_manager_->AddObserver(this); | 81 download_manager_->AddObserver(this); |
82 } | 82 } |
83 | 83 |
84 virtual ~SavePackageFinishedObserver() { | 84 ~SavePackageFinishedObserver() override { |
85 if (download_manager_) | 85 if (download_manager_) |
86 download_manager_->RemoveObserver(this); | 86 download_manager_->RemoveObserver(this); |
87 } | 87 } |
88 | 88 |
89 // DownloadManager::Observer: | 89 // DownloadManager::Observer: |
90 virtual void OnSavePackageSuccessfullyFinished( | 90 void OnSavePackageSuccessfullyFinished(content::DownloadManager* manager, |
91 content::DownloadManager* manager, content::DownloadItem* item) override { | 91 content::DownloadItem* item) override { |
92 callback_.Run(); | 92 callback_.Run(); |
93 } | 93 } |
94 virtual void ManagerGoingDown(content::DownloadManager* manager) override { | 94 void ManagerGoingDown(content::DownloadManager* manager) override { |
95 download_manager_->RemoveObserver(this); | 95 download_manager_->RemoveObserver(this); |
96 download_manager_ = NULL; | 96 download_manager_ = NULL; |
97 } | 97 } |
98 | 98 |
99 private: | 99 private: |
100 content::DownloadManager* download_manager_; | 100 content::DownloadManager* download_manager_; |
101 base::Closure callback_; | 101 base::Closure callback_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(SavePackageFinishedObserver); | 103 DISALLOW_COPY_AND_ASSIGN(SavePackageFinishedObserver); |
104 }; | 104 }; |
(...skipping 30 matching lines...) Expand all Loading... |
135 full_file_name, temp_sub_resource_dir_, | 135 full_file_name, temp_sub_resource_dir_, |
136 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML); | 136 content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML); |
137 loop_runner->Run(); | 137 loop_runner->Run(); |
138 | 138 |
139 base::FilePath expected_file_name = ui_test_utils::GetTestFilePath( | 139 base::FilePath expected_file_name = ui_test_utils::GetTestFilePath( |
140 base::FilePath(kTestDir), expected); | 140 base::FilePath(kTestDir), expected); |
141 | 141 |
142 EXPECT_TRUE(base::ContentsEqual(full_file_name, expected_file_name)); | 142 EXPECT_TRUE(base::ContentsEqual(full_file_name, expected_file_name)); |
143 } | 143 } |
144 | 144 |
145 virtual void SetUpOnMainThread() override { | 145 void SetUpOnMainThread() override { |
146 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 146 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
147 save_dir_ = temp_dir_.path(); | 147 save_dir_ = temp_dir_.path(); |
148 temp_sub_resource_dir_ = save_dir_.AppendASCII("sub_resource_files"); | 148 temp_sub_resource_dir_ = save_dir_.AppendASCII("sub_resource_files"); |
149 | 149 |
150 BrowserThread::PostTask( | 150 BrowserThread::PostTask( |
151 BrowserThread::IO, FROM_HERE, | 151 BrowserThread::IO, FROM_HERE, |
152 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); | 152 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
153 } | 153 } |
154 | 154 |
155 base::ScopedTempDir temp_dir_; | 155 base::ScopedTempDir temp_dir_; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 // Dump the page, the content of dump page should be equal with our expect | 337 // Dump the page, the content of dump page should be equal with our expect |
338 // result file. | 338 // result file. |
339 base::FilePath expected_result_file_name = | 339 base::FilePath expected_result_file_name = |
340 base::FilePath().AppendASCII(kAutoDetectDir). | 340 base::FilePath().AppendASCII(kAutoDetectDir). |
341 AppendASCII(kExpectedResultDir). | 341 AppendASCII(kExpectedResultDir). |
342 AppendASCII(kTestDatas[i].expected_result); | 342 AppendASCII(kTestDatas[i].expected_result); |
343 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); | 343 SaveAndCompare(kTestDatas[i].test_file_name, expected_result_file_name); |
344 } | 344 } |
345 } | 345 } |
OLD | NEW |