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