| 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 "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
| 10 #include "net/url_request/url_request_context.h" | 10 #include "net/url_request/url_request_context.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 FilePath expected_frame_url = | 121 FilePath expected_frame_url = |
| 122 page_file_path.AppendASCII(expected_frame_links[i]); | 122 page_file_path.AppendASCII(expected_frame_links[i]); |
| 123 expected_resources_set.insert( | 123 expected_resources_set.insert( |
| 124 net::FilePathToFileURL(expected_frame_url)); | 124 net::FilePathToFileURL(expected_frame_url)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 page_file_path = page_file_path.AppendASCII("youtube_2.htm"); | 127 page_file_path = page_file_path.AppendASCII("youtube_2.htm"); |
| 128 GetSavableResourceLinksForPage(page_file_path, expected_resources_set); | 128 GetSavableResourceLinksForPage(page_file_path, expected_resources_set); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Tests ParseIconSizes with various input. | |
| 132 TEST_F(DomOperationsTests, ParseIconSizes) { | |
| 133 struct TestData { | |
| 134 const char* input; | |
| 135 const bool expected_result; | |
| 136 const bool is_any; | |
| 137 const size_t expected_size_count; | |
| 138 const int width1; | |
| 139 const int height1; | |
| 140 const int width2; | |
| 141 const int height2; | |
| 142 } data[] = { | |
| 143 // Bogus input cases. | |
| 144 { "10", false, false, 0, 0, 0, 0, 0 }, | |
| 145 { "10 10", false, false, 0, 0, 0, 0, 0 }, | |
| 146 { "010", false, false, 0, 0, 0, 0, 0 }, | |
| 147 { " 010 ", false, false, 0, 0, 0, 0, 0 }, | |
| 148 { " 10x ", false, false, 0, 0, 0, 0, 0 }, | |
| 149 { " x10 ", false, false, 0, 0, 0, 0, 0 }, | |
| 150 { "any 10x10", false, false, 0, 0, 0, 0, 0 }, | |
| 151 { "", false, false, 0, 0, 0, 0, 0 }, | |
| 152 { "10ax11", false, false, 0, 0, 0, 0, 0 }, | |
| 153 | |
| 154 // Any. | |
| 155 { "any", true, true, 0, 0, 0, 0, 0 }, | |
| 156 { " any", true, true, 0, 0, 0, 0, 0 }, | |
| 157 { " any ", true, true, 0, 0, 0, 0, 0 }, | |
| 158 | |
| 159 // Sizes. | |
| 160 { "10x11", true, false, 1, 10, 11, 0, 0 }, | |
| 161 { " 10x11 ", true, false, 1, 10, 11, 0, 0 }, | |
| 162 { " 10x11 1x2", true, false, 2, 10, 11, 1, 2 }, | |
| 163 }; | |
| 164 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | |
| 165 bool is_any; | |
| 166 std::vector<gfx::Size> sizes; | |
| 167 bool result = webkit_glue::ParseIconSizes( | |
| 168 ASCIIToUTF16(data[i].input), &sizes, &is_any); | |
| 169 ASSERT_EQ(result, data[i].expected_result); | |
| 170 if (result) { | |
| 171 ASSERT_EQ(data[i].is_any, is_any); | |
| 172 ASSERT_EQ(data[i].expected_size_count, sizes.size()); | |
| 173 if (sizes.size() > 0) { | |
| 174 ASSERT_EQ(data[i].width1, sizes[0].width()); | |
| 175 ASSERT_EQ(data[i].height1, sizes[0].height()); | |
| 176 } | |
| 177 if (sizes.size() > 1) { | |
| 178 ASSERT_EQ(data[i].width2, sizes[1].width()); | |
| 179 ASSERT_EQ(data[i].height2, sizes[1].height()); | |
| 180 } | |
| 181 } | |
| 182 } | |
| 183 } | |
| 184 | |
| 185 } // namespace | 131 } // namespace |
| OLD | NEW |