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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "content/browser/browser_thread_impl.h" |
12 #include "content/browser/download/save_package.h" | 13 #include "content/browser/download/save_package.h" |
13 #include "content/browser/net/url_request_mock_http_job.h" | 14 #include "content/browser/net/url_request_mock_http_job.h" |
14 #include "content/browser/renderer_host/test_render_view_host.h" | 15 #include "content/browser/renderer_host/test_render_view_host.h" |
15 #include "content/browser/tab_contents/test_tab_contents.h" | 16 #include "content/browser/tab_contents/test_tab_contents.h" |
16 #include "content/test/test_browser_thread.h" | |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
| 20 using content::BrowserThreadImpl; |
| 21 |
20 #define FPL FILE_PATH_LITERAL | 22 #define FPL FILE_PATH_LITERAL |
21 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
22 #define HTML_EXTENSION ".htm" | 24 #define HTML_EXTENSION ".htm" |
23 // This second define is needed because MSVC is broken. | 25 // This second define is needed because MSVC is broken. |
24 #define FPL_HTML_EXTENSION L".htm" | 26 #define FPL_HTML_EXTENSION L".htm" |
25 #else | 27 #else |
26 #define HTML_EXTENSION ".html" | 28 #define HTML_EXTENSION ".html" |
27 #define FPL_HTML_EXTENSION ".html" | 29 #define FPL_HTML_EXTENSION ".html" |
28 #endif | 30 #endif |
29 | 31 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 long_file_name += long_file_name; | 114 long_file_name += long_file_name; |
113 long_file_name.resize( | 115 long_file_name.resize( |
114 kMaxFilePathLength - 9 - temp_dir_.path().value().length()); | 116 kMaxFilePathLength - 9 - temp_dir_.path().value().length()); |
115 | 117 |
116 save_package_fail_ = new SavePackage(contents(), | 118 save_package_fail_ = new SavePackage(contents(), |
117 temp_dir_.path().AppendASCII(long_file_name + HTML_EXTENSION), | 119 temp_dir_.path().AppendASCII(long_file_name + HTML_EXTENSION), |
118 temp_dir_.path().AppendASCII(long_file_name + "_files")); | 120 temp_dir_.path().AppendASCII(long_file_name + "_files")); |
119 } | 121 } |
120 | 122 |
121 private: | 123 private: |
122 content::TestBrowserThread browser_thread_; | 124 BrowserThreadImpl browser_thread_; |
123 | 125 |
124 // SavePackage for successfully generating file name. | 126 // SavePackage for successfully generating file name. |
125 scoped_refptr<SavePackage> save_package_success_; | 127 scoped_refptr<SavePackage> save_package_success_; |
126 // SavePackage for failed generating file name. | 128 // SavePackage for failed generating file name. |
127 scoped_refptr<SavePackage> save_package_fail_; | 129 scoped_refptr<SavePackage> save_package_fail_; |
128 | 130 |
129 ScopedTempDir temp_dir_; | 131 ScopedTempDir temp_dir_; |
130 | 132 |
131 DISALLOW_COPY_AND_ASSIGN(SavePackageTest); | 133 DISALLOW_COPY_AND_ASSIGN(SavePackageTest); |
132 }; | 134 }; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 TEST_F(SavePackageTest, TestGetUrlToBeSavedViewSource) { | 419 TEST_F(SavePackageTest, TestGetUrlToBeSavedViewSource) { |
418 FilePath file_name(FILE_PATH_LITERAL("a.htm")); | 420 FilePath file_name(FILE_PATH_LITERAL("a.htm")); |
419 GURL view_source_url = URLRequestMockHTTPJob::GetMockViewSourceUrl( | 421 GURL view_source_url = URLRequestMockHTTPJob::GetMockViewSourceUrl( |
420 FilePath(kTestDir).Append(file_name)); | 422 FilePath(kTestDir).Append(file_name)); |
421 GURL actual_url = URLRequestMockHTTPJob::GetMockUrl( | 423 GURL actual_url = URLRequestMockHTTPJob::GetMockUrl( |
422 FilePath(kTestDir).Append(file_name)); | 424 FilePath(kTestDir).Append(file_name)); |
423 NavigateAndCommit(view_source_url); | 425 NavigateAndCommit(view_source_url); |
424 EXPECT_EQ(actual_url, GetUrlToBeSaved()); | 426 EXPECT_EQ(actual_url, GetUrlToBeSaved()); |
425 EXPECT_EQ(view_source_url, contents()->GetURL()); | 427 EXPECT_EQ(view_source_url, contents()->GetURL()); |
426 } | 428 } |
OLD | NEW |