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

Side by Side Diff: third_party/WebKit/Source/core/testing/CoreTestPrinters.cpp

Issue 1828163002: Remove ASSERT_ARG(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/dom/Document.h" 5 #include "core/editing/Position.h"
6 #include "core/dom/Range.h"
7 #include "core/dom/Text.h"
8 #include "core/html/HTMLElement.h"
9 #include "wtf/text/StringBuilder.h"
10 #include <ios> 6 #include <ios>
11 #include <ostream> // NOLINT 7 #include <ostream> // NOLINT
12 8
13 namespace blink { 9 namespace blink {
14 10
15 namespace { 11 namespace {
16 12
17 // Copied from "dom/Node.cpp".
18 void appendAttributeDesc(const Node& node, StringBuilder& stringBuilder, const Q ualifiedName& name, const char* attrDesc)
19 {
20 if (!node.isElementNode())
21 return;
22
23 String attr = toElement(node).getAttribute(name);
24 if (attr.isEmpty())
25 return;
26
27 stringBuilder.append(attrDesc);
28 stringBuilder.appendLiteral("=\"");
29 stringBuilder.append(attr);
30 stringBuilder.appendLiteral("\"");
31 }
32
33 template <typename PositionType> 13 template <typename PositionType>
34 std::ostream& printPosition(std::ostream& ostream, const PositionType& position) 14 std::ostream& printPosition(std::ostream& ostream, const PositionType& position)
35 { 15 {
36 if (position.isNull()) 16 if (position.isNull())
37 return ostream << "null"; 17 return ostream << "null";
38 ostream << position.anchorNode() << "@"; 18 ostream << position.anchorNode() << "@";
39 if (position.isOffsetInAnchor()) 19 if (position.isOffsetInAnchor())
40 return ostream << position.offsetInContainerNode(); 20 return ostream << position.offsetInContainerNode();
41 return ostream << position.anchorType(); 21 return ostream << position.anchorType();
42 } 22 }
(...skipping 11 matching lines...) Expand all
54 return ostream << "beforeAnchor"; 34 return ostream << "beforeAnchor";
55 case PositionAnchorType::BeforeChildren: 35 case PositionAnchorType::BeforeChildren:
56 return ostream << "beforeChildren"; 36 return ostream << "beforeChildren";
57 case PositionAnchorType::OffsetInAnchor: 37 case PositionAnchorType::OffsetInAnchor:
58 return ostream << "offsetInAnchor"; 38 return ostream << "offsetInAnchor";
59 } 39 }
60 ASSERT_NOT_REACHED(); 40 ASSERT_NOT_REACHED();
61 return ostream << "anchorType=" << static_cast<int>(anchorType); 41 return ostream << "anchorType=" << static_cast<int>(anchorType);
62 } 42 }
63 43
64 // |std::ostream| version of |Node::showNode|
65 std::ostream& operator<<(std::ostream& ostream, const Node& node)
66 {
67 ostream << node.nodeName().utf8().data();
68 if (node.isTextNode())
69 return ostream << " " << node.nodeValue();
70 StringBuilder attrs;
71 appendAttributeDesc(node, attrs, HTMLNames::idAttr, " ID");
72 appendAttributeDesc(node, attrs, HTMLNames::classAttr, " CLASS");
73 appendAttributeDesc(node, attrs, HTMLNames::styleAttr, " STYLE");
74 return ostream << attrs.toString().utf8().data();
75 }
76
77 std::ostream& operator<<(std::ostream& ostream, const Node* node)
78 {
79 if (!node)
80 return ostream << "null";
81 return ostream << *node;
82 }
83
84 std::ostream& operator<<(std::ostream& ostream, const Position& position) 44 std::ostream& operator<<(std::ostream& ostream, const Position& position)
85 { 45 {
86 return printPosition(ostream, position); 46 return printPosition(ostream, position);
87 } 47 }
88 48
89 std::ostream& operator<<(std::ostream& ostream, const PositionInFlatTree& positi on) 49 std::ostream& operator<<(std::ostream& ostream, const PositionInFlatTree& positi on)
90 { 50 {
91 return printPosition(ostream, position); 51 return printPosition(ostream, position);
92 } 52 }
93 53
94 } // namespace blink 54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698