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/download/save_package.h" | 12 #include "content/browser/download/save_package.h" |
13 #include "content/browser/net/url_request_mock_http_job.h" | 13 #include "content/browser/net/url_request_mock_http_job.h" |
14 #include "content/browser/renderer_host/test_render_view_host.h" | 14 #include "content/browser/renderer_host/test_render_view_host.h" |
15 #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" | 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" |
27 #define FPL_HTML_EXTENSION ".html" | 27 #define FPL_HTML_EXTENSION ".html" |
28 #endif | 28 #endif |
29 | 29 |
| 30 using content::BrowserThread; |
| 31 |
30 namespace { | 32 namespace { |
31 | 33 |
32 // This constant copied from save_package.cc. | 34 // This constant copied from save_package.cc. |
33 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
34 const uint32 kMaxFilePathLength = MAX_PATH - 1; | 36 const uint32 kMaxFilePathLength = MAX_PATH - 1; |
35 const uint32 kMaxFileNameLength = MAX_PATH - 1; | 37 const uint32 kMaxFileNameLength = MAX_PATH - 1; |
36 #elif defined(OS_POSIX) | 38 #elif defined(OS_POSIX) |
37 const uint32 kMaxFilePathLength = PATH_MAX - 1; | 39 const uint32 kMaxFilePathLength = PATH_MAX - 1; |
38 const uint32 kMaxFileNameLength = NAME_MAX; | 40 const uint32 kMaxFileNameLength = NAME_MAX; |
39 #endif | 41 #endif |
(...skipping 377 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 |