OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 6 #include "base/file_path.h" |
6 #include "base/file_util.h" | 7 #include "base/file_util.h" |
7 #include "base/path_service.h" | 8 #include "base/path_service.h" |
8 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
9 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 11 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
11 #include "chrome/browser/download/download_history.h" | 12 #include "chrome/browser/download/download_history.h" |
| 13 #include "chrome/browser/net/url_request_mock_util.h" |
12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/webui/active_downloads_ui.h" | 17 #include "chrome/browser/ui/webui/active_downloads_ui.h" |
16 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/browser/download/download_item.h" | 22 #include "content/browser/download/download_item.h" |
21 #include "content/browser/download/download_manager.h" | 23 #include "content/browser/download/download_manager.h" |
(...skipping 10 matching lines...) Expand all Loading... |
32 | 34 |
33 static const char* kAppendedExtension = | 35 static const char* kAppendedExtension = |
34 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
35 ".htm"; | 37 ".htm"; |
36 #else | 38 #else |
37 ".html"; | 39 ".html"; |
38 #endif | 40 #endif |
39 | 41 |
40 class SavePageBrowserTest : public InProcessBrowserTest { | 42 class SavePageBrowserTest : public InProcessBrowserTest { |
41 protected: | 43 protected: |
42 void SetUp() { | 44 void SetUp() OVERRIDE { |
43 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir_)); | 45 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir_)); |
44 ASSERT_TRUE(save_dir_.CreateUniqueTempDir()); | 46 ASSERT_TRUE(save_dir_.CreateUniqueTempDir()); |
45 InProcessBrowserTest::SetUp(); | 47 InProcessBrowserTest::SetUp(); |
46 } | 48 } |
47 | 49 |
| 50 void SetUpOnMainThread() OVERRIDE { |
| 51 BrowserThread::PostTask( |
| 52 BrowserThread::IO, FROM_HERE, |
| 53 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
| 54 } |
| 55 |
48 GURL NavigateToMockURL(const std::string& prefix) { | 56 GURL NavigateToMockURL(const std::string& prefix) { |
49 GURL url = URLRequestMockHTTPJob::GetMockUrl( | 57 GURL url = URLRequestMockHTTPJob::GetMockUrl( |
50 FilePath(kTestDir).AppendASCII(prefix + ".htm")); | 58 FilePath(kTestDir).AppendASCII(prefix + ".htm")); |
51 ui_test_utils::NavigateToURL(browser(), url); | 59 ui_test_utils::NavigateToURL(browser(), url); |
52 return url; | 60 return url; |
53 } | 61 } |
54 | 62 |
55 // Returns full paths of destination file and directory. | 63 // Returns full paths of destination file and directory. |
56 void GetDestinationPaths(const std::string& prefix, | 64 void GetDestinationPaths(const std::string& prefix, |
57 FilePath* full_file_name, | 65 FilePath* full_file_name, |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, ExplicitCancel) { | 345 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, ExplicitCancel) { |
338 GURL url = NavigateToMockURL("a"); | 346 GURL url = NavigateToMockURL("a"); |
339 FilePath full_file_name, dir; | 347 FilePath full_file_name, dir; |
340 GetDestinationPaths("a", &full_file_name, &dir); | 348 GetDestinationPaths("a", &full_file_name, &dir); |
341 scoped_refptr<SavePackage> save_package(new SavePackage(GetCurrentTab(), | 349 scoped_refptr<SavePackage> save_package(new SavePackage(GetCurrentTab(), |
342 SavePackage::SAVE_AS_ONLY_HTML, full_file_name, dir)); | 350 SavePackage::SAVE_AS_ONLY_HTML, full_file_name, dir)); |
343 save_package->Cancel(true); | 351 save_package->Cancel(true); |
344 } | 352 } |
345 | 353 |
346 } // namespace | 354 } // namespace |
OLD | NEW |