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 "content/public/test/layouttest_support.h" | 5 #include "content/public/test/layouttest_support.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
10 #include "content/common/gpu/image_transport_surface.h" | 10 #include "content/common/gpu/image_transport_surface.h" |
11 #include "content/public/common/page_state.h" | 11 #include "content/public/common/page_state.h" |
| 12 #include "content/renderer/history_entry.h" |
12 #include "content/renderer/history_serialization.h" | 13 #include "content/renderer/history_serialization.h" |
13 #include "content/renderer/render_thread_impl.h" | 14 #include "content/renderer/render_thread_impl.h" |
14 #include "content/renderer/render_view_impl.h" | 15 #include "content/renderer/render_view_impl.h" |
15 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 16 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
16 #include "content/shell/renderer/test_runner/TestCommon.h" | 17 #include "content/shell/renderer/test_runner/TestCommon.h" |
17 #include "content/shell/renderer/test_runner/WebFrameTestProxy.h" | 18 #include "content/shell/renderer/test_runner/WebFrameTestProxy.h" |
18 #include "content/shell/renderer/test_runner/WebTestProxy.h" | 19 #include "content/shell/renderer/test_runner/WebTestProxy.h" |
19 #include "content/test/test_media_stream_client.h" | 20 #include "content/test/test_media_stream_client.h" |
20 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" | 21 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" |
21 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" | 22 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 void UseMockMediaStreams(RenderView* render_view) { | 163 void UseMockMediaStreams(RenderView* render_view) { |
163 RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view); | 164 RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view); |
164 render_view_impl->SetMediaStreamClientForTesting( | 165 render_view_impl->SetMediaStreamClientForTesting( |
165 new TestMediaStreamClient(render_view_impl)); | 166 new TestMediaStreamClient(render_view_impl)); |
166 } | 167 } |
167 | 168 |
168 struct ToLower { | 169 struct ToLower { |
169 base::char16 operator()(base::char16 c) { return tolower(c); } | 170 base::char16 operator()(base::char16 c) { return tolower(c); } |
170 }; | 171 }; |
171 | 172 |
172 // Returns True if item1 < item2. | 173 // Returns True if node1 < node2. |
173 bool HistoryItemCompareLess(const blink::WebHistoryItem& item1, | 174 bool HistoryEntryCompareLess(HistoryEntry::HistoryNode* node1, |
174 const blink::WebHistoryItem& item2) { | 175 HistoryEntry::HistoryNode* node2) { |
175 base::string16 target1 = item1.target(); | 176 base::string16 target1 = node1->item().target(); |
176 base::string16 target2 = item2.target(); | 177 base::string16 target2 = node2->item().target(); |
177 std::transform(target1.begin(), target1.end(), target1.begin(), ToLower()); | 178 std::transform(target1.begin(), target1.end(), target1.begin(), ToLower()); |
178 std::transform(target2.begin(), target2.end(), target2.begin(), ToLower()); | 179 std::transform(target2.begin(), target2.end(), target2.begin(), ToLower()); |
179 return target1 < target2; | 180 return target1 < target2; |
180 } | 181 } |
181 | 182 |
182 std::string DumpHistoryItem(const blink::WebHistoryItem& item, | 183 std::string DumpHistoryItem(HistoryEntry::HistoryNode* node, |
183 int indent, | 184 int indent, |
184 bool is_current_index) { | 185 bool is_current_index) { |
185 std::string result; | 186 std::string result; |
186 | 187 |
| 188 const blink::WebHistoryItem& item = node->item(); |
187 if (is_current_index) { | 189 if (is_current_index) { |
188 result.append("curr->"); | 190 result.append("curr->"); |
189 result.append(indent - 6, ' '); // 6 == "curr->".length() | 191 result.append(indent - 6, ' '); // 6 == "curr->".length() |
190 } else { | 192 } else { |
191 result.append(indent, ' '); | 193 result.append(indent, ' '); |
192 } | 194 } |
193 | 195 |
194 std::string url = | 196 std::string url = |
195 WebTestRunner::normalizeLayoutTestURL(item.urlString().utf8()); | 197 WebTestRunner::normalizeLayoutTestURL(item.urlString().utf8()); |
196 result.append(url); | 198 result.append(url); |
197 if (!item.target().isEmpty()) { | 199 if (!item.target().isEmpty()) { |
198 result.append(" (in frame \""); | 200 result.append(" (in frame \""); |
199 result.append(item.target().utf8()); | 201 result.append(item.target().utf8()); |
200 result.append("\")"); | 202 result.append("\")"); |
201 } | 203 } |
202 result.append("\n"); | 204 result.append("\n"); |
203 | 205 |
204 const blink::WebVector<blink::WebHistoryItem>& children = item.children(); | 206 std::vector<HistoryEntry::HistoryNode*> children = node->children(); |
205 if (!children.isEmpty()) { | 207 if (!children.empty()) { |
206 // Must sort to eliminate arbitrary result ordering which defeats | 208 std::sort(children.begin(), children.end(), HistoryEntryCompareLess); |
207 // reproducible testing. | |
208 // FIXME: WebVector should probably just be a std::vector!! | |
209 std::vector<blink::WebHistoryItem> sortedChildren; | |
210 for (size_t i = 0; i < children.size(); ++i) | 209 for (size_t i = 0; i < children.size(); ++i) |
211 sortedChildren.push_back(children[i]); | 210 result += DumpHistoryItem(children[i], indent + 4, false); |
212 std::sort(sortedChildren.begin(), | |
213 sortedChildren.end(), | |
214 HistoryItemCompareLess); | |
215 for (size_t i = 0; i < sortedChildren.size(); ++i) | |
216 result += DumpHistoryItem(sortedChildren[i], indent + 4, false); | |
217 } | 211 } |
218 | 212 |
219 return result; | 213 return result; |
220 } | 214 } |
221 | 215 |
222 std::string DumpBackForwardList(std::vector<PageState>& page_state, | 216 std::string DumpBackForwardList(std::vector<PageState>& page_state, |
223 size_t current_index) { | 217 size_t current_index) { |
224 std::string result; | 218 std::string result; |
225 result.append("\n============== Back Forward List ==============\n"); | 219 result.append("\n============== Back Forward List ==============\n"); |
226 for (size_t index = 0; index < page_state.size(); ++index) { | 220 for (size_t index = 0; index < page_state.size(); ++index) { |
227 result.append(DumpHistoryItem( | 221 scoped_ptr<HistoryEntry> entry( |
228 PageStateToHistoryItem(page_state[index]), 8, index == current_index)); | 222 PageStateToHistoryEntry(page_state[index])); |
| 223 result.append( |
| 224 DumpHistoryItem(entry->root_history_node(), |
| 225 8, |
| 226 index == current_index)); |
229 } | 227 } |
230 result.append("===============================================\n"); | 228 result.append("===============================================\n"); |
231 return result; | 229 return result; |
232 } | 230 } |
233 | 231 |
234 } // namespace content | 232 } // namespace content |
OLD | NEW |