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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 protected: | 96 protected: |
97 void SetUp() override { | 97 void SetUp() override { |
98 RenderViewHostImplTestHarness::SetUp(); | 98 RenderViewHostImplTestHarness::SetUp(); |
99 | 99 |
100 // Do the initialization in SetUp so contents() is initialized by | 100 // Do the initialization in SetUp so contents() is initialized by |
101 // RenderViewHostImplTestHarness::SetUp. | 101 // RenderViewHostImplTestHarness::SetUp. |
102 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 102 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
103 | 103 |
104 save_package_success_ = | 104 save_package_success_ = new SavePackage( |
105 new SavePackage(contents(), SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | 105 contents(), SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
106 temp_dir_.path().AppendASCII("testfile" HTML_EXTENSION), | 106 temp_dir_.GetPath().AppendASCII("testfile" HTML_EXTENSION), |
107 temp_dir_.path().AppendASCII("testfile_files")); | 107 temp_dir_.GetPath().AppendASCII("testfile_files")); |
108 | 108 |
109 base::FilePath::StringType long_file_name = GetLongFileName(); | 109 base::FilePath::StringType long_file_name = GetLongFileName(); |
110 save_package_fail_ = new SavePackage( | 110 save_package_fail_ = new SavePackage( |
111 contents(), SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | 111 contents(), SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
112 temp_dir_.path().Append(long_file_name + FPL_HTML_EXTENSION), | 112 temp_dir_.GetPath().Append(long_file_name + FPL_HTML_EXTENSION), |
113 temp_dir_.path().Append(long_file_name + FPL("_files"))); | 113 temp_dir_.GetPath().Append(long_file_name + FPL("_files"))); |
114 } | 114 } |
115 | 115 |
116 BrowserContext* CreateBrowserContext() override { | 116 BrowserContext* CreateBrowserContext() override { |
117 // This method is invoked after the browser threads have been created and | 117 // This method is invoked after the browser threads have been created and |
118 // obviously before the BrowserContext is created. This is the correct time | 118 // obviously before the BrowserContext is created. This is the correct time |
119 // to create a ResourceDispatcherHostImpl so that our SavePackage objects | 119 // to create a ResourceDispatcherHostImpl so that our SavePackage objects |
120 // can initialize correctly. | 120 // can initialize correctly. |
121 rdh_.reset(new ResourceDispatcherHostImpl); | 121 rdh_.reset(new ResourceDispatcherHostImpl); |
122 // Initialize the SaveFileManager instance which we will use for the tests. | 122 // Initialize the SaveFileManager instance which we will use for the tests. |
123 save_file_manager_ = new SaveFileManager(); | 123 save_file_manager_ = new SaveFileManager(); |
124 return RenderViewHostImplTestHarness::CreateBrowserContext(); | 124 return RenderViewHostImplTestHarness::CreateBrowserContext(); |
125 } | 125 } |
126 | 126 |
127 void TearDown() override { | 127 void TearDown() override { |
128 DeleteContents(); | 128 DeleteContents(); |
129 base::RunLoop().RunUntilIdle(); | 129 base::RunLoop().RunUntilIdle(); |
130 | 130 |
131 save_package_success_ = nullptr; | 131 save_package_success_ = nullptr; |
132 save_package_fail_ = nullptr; | 132 save_package_fail_ = nullptr; |
133 rdh_.reset(); | 133 rdh_.reset(); |
134 | 134 |
135 RenderViewHostImplTestHarness::TearDown(); | 135 RenderViewHostImplTestHarness::TearDown(); |
136 } | 136 } |
137 | 137 |
138 // Returns a path that is *almost* kMaxFilePathLength long | 138 // Returns a path that is *almost* kMaxFilePathLength long |
139 base::FilePath::StringType GetLongFileName() const { | 139 base::FilePath::StringType GetLongFileName() const { |
140 size_t target_length = | 140 size_t target_length = |
141 kMaxFilePathLength - 9 - temp_dir_.path().value().length(); | 141 kMaxFilePathLength - 9 - temp_dir_.GetPath().value().length(); |
142 return base::FilePath::StringType(target_length, FPL('a')); | 142 return base::FilePath::StringType(target_length, FPL('a')); |
143 } | 143 } |
144 | 144 |
145 private: | 145 private: |
146 // SavePackage for successfully generating file name. | 146 // SavePackage for successfully generating file name. |
147 scoped_refptr<SavePackage> save_package_success_; | 147 scoped_refptr<SavePackage> save_package_success_; |
148 // SavePackage for failed generating file name. | 148 // SavePackage for failed generating file name. |
149 scoped_refptr<SavePackage> save_package_fail_; | 149 scoped_refptr<SavePackage> save_package_fail_; |
150 | 150 |
151 base::ScopedTempDir temp_dir_; | 151 base::ScopedTempDir temp_dir_; |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 GURL mock_url = net::URLRequestMockHTTPJob::GetMockUrl("save_page/a.htm"); | 447 GURL mock_url = net::URLRequestMockHTTPJob::GetMockUrl("save_page/a.htm"); |
448 GURL view_source_url = | 448 GURL view_source_url = |
449 GURL(kViewSourceScheme + std::string(":") + mock_url.spec()); | 449 GURL(kViewSourceScheme + std::string(":") + mock_url.spec()); |
450 GURL actual_url = net::URLRequestMockHTTPJob::GetMockUrl("save_page/a.htm"); | 450 GURL actual_url = net::URLRequestMockHTTPJob::GetMockUrl("save_page/a.htm"); |
451 NavigateAndCommit(view_source_url); | 451 NavigateAndCommit(view_source_url); |
452 EXPECT_EQ(actual_url, GetUrlToBeSaved()); | 452 EXPECT_EQ(actual_url, GetUrlToBeSaved()); |
453 EXPECT_EQ(view_source_url, contents()->GetLastCommittedURL()); | 453 EXPECT_EQ(view_source_url, contents()->GetLastCommittedURL()); |
454 } | 454 } |
455 | 455 |
456 } // namespace content | 456 } // namespace content |
OLD | NEW |