Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(829)

Side by Side Diff: content/shell/renderer/test_runner/WebTestProxy.cpp

Issue 246163006: Move history serialization from contet/public/renderer/ to content/renderer/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/shell/renderer/test_runner/WebTestProxy.h" 5 #include "content/shell/renderer/test_runner/WebTestProxy.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/shell/renderer/test_runner/event_sender.h" 10 #include "content/shell/renderer/test_runner/event_sender.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 result += data; 297 result += data;
298 } 298 }
299 299
300 if (!recursive) 300 if (!recursive)
301 return result; 301 return result;
302 for (WebFrame* child = frame->firstChild(); child; child = child->nextSiblin g()) 302 for (WebFrame* child = frame->firstChild(); child; child = child->nextSiblin g())
303 result += dumpFrameScrollPosition(child, recursive); 303 result += dumpFrameScrollPosition(child, recursive);
304 return result; 304 return result;
305 } 305 }
306 306
307 struct ToLower {
308 base::char16 operator()(base::char16 c) { return tolower(c); }
309 };
310
311 // Returns True if item1 < item2.
312 bool HistoryItemCompareLess(const WebHistoryItem& item1, const WebHistoryItem& i tem2)
313 {
314 base::string16 target1 = item1.target();
315 base::string16 target2 = item2.target();
316 std::transform(target1.begin(), target1.end(), target1.begin(), ToLower());
317 std::transform(target2.begin(), target2.end(), target2.begin(), ToLower());
318 return target1 < target2;
319 }
320
321 string dumpHistoryItem(const WebHistoryItem& item, int indent, bool isCurrent)
322 {
323 string result;
324
325 if (isCurrent) {
326 result.append("curr->");
327 result.append(indent - 6, ' '); // 6 == "curr->".length()
328 } else
329 result.append(indent, ' ');
330
331 string url = normalizeLayoutTestURL(item.urlString().utf8());
332 result.append(url);
333 if (!item.target().isEmpty()) {
334 result.append(" (in frame \"");
335 result.append(item.target().utf8());
336 result.append("\")");
337 }
338 result.append("\n");
339
340 const WebVector<WebHistoryItem>& children = item.children();
341 if (!children.isEmpty()) {
342 // Must sort to eliminate arbitrary result ordering which defeats
343 // reproducible testing.
344 // FIXME: WebVector should probably just be a std::vector!!
345 std::vector<WebHistoryItem> sortedChildren;
346 for (size_t i = 0; i < children.size(); ++i)
347 sortedChildren.push_back(children[i]);
348 std::sort(sortedChildren.begin(), sortedChildren.end(), HistoryItemCompa reLess);
349 for (size_t i = 0; i < sortedChildren.size(); ++i)
350 result += dumpHistoryItem(sortedChildren[i], indent + 4, false);
351 }
352
353 return result;
354 }
355
356 void dumpBackForwardList(const WebVector<WebHistoryItem>& history, size_t curren tEntryIndex, string& result)
357 {
358 result.append("\n============== Back Forward List ==============\n");
359 for (size_t index = 0; index < history.size(); ++index)
360 result.append(dumpHistoryItem(history[index], 8, index == currentEntryIn dex));
361 result.append("===============================================\n");
362 }
363
364 string dumpAllBackForwardLists(TestInterfaces* interfaces, WebTestDelegate* dele gate) 307 string dumpAllBackForwardLists(TestInterfaces* interfaces, WebTestDelegate* dele gate)
365 { 308 {
366 string result; 309 string result;
367 const vector<WebTestProxyBase*>& windowList = interfaces->windowList(); 310 const vector<WebTestProxyBase*>& windowList = interfaces->windowList();
368 for (unsigned i = 0; i < windowList.size(); ++i) { 311 for (unsigned i = 0; i < windowList.size(); ++i)
369 size_t currentEntryIndex = 0; 312 result.append(delegate->dumpHistoryForWindow(windowList.at(i)));
370 WebVector<WebHistoryItem> history;
371 delegate->captureHistoryForWindow(windowList.at(i), &history, &currentEn tryIndex);
372 dumpBackForwardList(history, currentEntryIndex, result);
373 }
374 return result; 313 return result;
375 } 314 }
376 315
377 } 316 }
378 317
379 WebTestProxyBase::WebTestProxyBase() 318 WebTestProxyBase::WebTestProxyBase()
380 : m_testInterfaces(0) 319 : m_testInterfaces(0)
381 , m_delegate(0) 320 , m_delegate(0)
382 , m_webWidget(0) 321 , m_webWidget(0)
383 , m_spellcheck(new SpellCheckClient(this)) 322 , m_spellcheck(new SpellCheckClient(this))
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 1291
1353 void WebTestProxyBase::resetInputMethod() 1292 void WebTestProxyBase::resetInputMethod()
1354 { 1293 {
1355 // If a composition text exists, then we need to let the browser process 1294 // If a composition text exists, then we need to let the browser process
1356 // to cancel the input method's ongoing composition session. 1295 // to cancel the input method's ongoing composition session.
1357 if (m_webWidget) 1296 if (m_webWidget)
1358 m_webWidget->confirmComposition(); 1297 m_webWidget->confirmComposition();
1359 } 1298 }
1360 1299
1361 } // namespace content 1300 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698