| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "net/base/net_util.h" | 8 #include "net/base/net_util.h" |
| 9 #include "net/url_request/url_request_context.h" | 9 #include "net/url_request/url_request_context.h" |
| 10 #include "webkit/glue/dom_operations.h" | 10 #include "webkit/glue/dom_operations.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 | 36 |
| 37 void DomOperationsTests::GetSavableResourceLinksForPage( | 37 void DomOperationsTests::GetSavableResourceLinksForPage( |
| 38 const FilePath& page_file_path, | 38 const FilePath& page_file_path, |
| 39 const std::set<GURL>& expected_resources_set) { | 39 const std::set<GURL>& expected_resources_set) { |
| 40 // Convert local file path to file URL. | 40 // Convert local file path to file URL. |
| 41 GURL file_url = net::FilePathToFileURL(page_file_path); | 41 GURL file_url = net::FilePathToFileURL(page_file_path); |
| 42 // Load the test file. | 42 // Load the test file. |
| 43 test_shell_->ResetTestController(); | 43 test_shell_->ResetTestController(); |
| 44 std::wstring file_wurl = ASCIIToWide(file_url.spec()); | 44 test_shell_->LoadURL(file_url); |
| 45 test_shell_->LoadURL(file_wurl.c_str()); | |
| 46 test_shell_->WaitTestFinished(); | 45 test_shell_->WaitTestFinished(); |
| 47 // Get all savable resource links for the page. | 46 // Get all savable resource links for the page. |
| 48 std::vector<GURL> resources_list; | 47 std::vector<GURL> resources_list; |
| 49 std::vector<GURL> referrers_list; | 48 std::vector<GURL> referrers_list; |
| 50 std::vector<GURL> frames_list; | 49 std::vector<GURL> frames_list; |
| 51 webkit_glue::SavableResourcesResult result(&resources_list, | 50 webkit_glue::SavableResourcesResult result(&resources_list, |
| 52 &referrers_list, | 51 &referrers_list, |
| 53 &frames_list); | 52 &frames_list); |
| 54 | 53 |
| 55 GURL main_page_gurl(WideToUTF8(file_wurl)); | |
| 56 ASSERT_TRUE(webkit_glue::GetAllSavableResourceLinksForCurrentPage( | 54 ASSERT_TRUE(webkit_glue::GetAllSavableResourceLinksForCurrentPage( |
| 57 test_shell_->webView(), main_page_gurl, &result)); | 55 test_shell_->webView(), file_url, &result)); |
| 58 // Check all links of sub-resource | 56 // Check all links of sub-resource |
| 59 for (std::vector<GURL>::const_iterator cit = resources_list.begin(); | 57 for (std::vector<GURL>::const_iterator cit = resources_list.begin(); |
| 60 cit != resources_list.end(); ++cit) { | 58 cit != resources_list.end(); ++cit) { |
| 61 ASSERT_TRUE(expected_resources_set.find(*cit) != | 59 ASSERT_TRUE(expected_resources_set.find(*cit) != |
| 62 expected_resources_set.end()); | 60 expected_resources_set.end()); |
| 63 } | 61 } |
| 64 // Check all links of frame. | 62 // Check all links of frame. |
| 65 for (std::vector<GURL>::const_iterator cit = frames_list.begin(); | 63 for (std::vector<GURL>::const_iterator cit = frames_list.begin(); |
| 66 cit != frames_list.end(); ++cit) { | 64 cit != frames_list.end(); ++cit) { |
| 67 ASSERT_TRUE(expected_resources_set.find(*cit) != | 65 ASSERT_TRUE(expected_resources_set.find(*cit) != |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 168 } |
| 171 if (sizes.size() > 1) { | 169 if (sizes.size() > 1) { |
| 172 ASSERT_EQ(data[i].width2, sizes[1].width()); | 170 ASSERT_EQ(data[i].width2, sizes[1].width()); |
| 173 ASSERT_EQ(data[i].height2, sizes[1].height()); | 171 ASSERT_EQ(data[i].height2, sizes[1].height()); |
| 174 } | 172 } |
| 175 } | 173 } |
| 176 } | 174 } |
| 177 } | 175 } |
| 178 | 176 |
| 179 } // namespace | 177 } // namespace |
| OLD | NEW |