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

Unified Diff: Source/core/testing/CoreTestHelpers.cpp

Issue 1313283002: Re-introduce printers for Node, Position, PositionAnchorType in GTest (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-26T14:32:13 Add comments for printers which are only for testing Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/testing/CoreTestHelpers.h ('k') | Source/core/testing/CoreTestPrinters.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/testing/CoreTestHelpers.cpp
diff --git a/Source/core/testing/CoreTestHelpers.cpp b/Source/core/testing/CoreTestHelpers.cpp
deleted file mode 100644
index 935422f0627adc2df383e81a98ad5a531c1ee50d..0000000000000000000000000000000000000000
--- a/Source/core/testing/CoreTestHelpers.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "core/testing/CoreTestHelpers.h"
-
-#include "core/dom/Document.h"
-#include "core/dom/Range.h"
-#include "core/dom/Text.h"
-#include "core/html/HTMLElement.h"
-#include "wtf/text/StringBuilder.h"
-#include <ios>
-#include <ostream> // NOLINT
-
-namespace blink {
-
-namespace {
-
-// Copied from "dom/Node.cpp".
-void appendAttributeDesc(const Node& node, StringBuilder& stringBuilder, const QualifiedName& name, const char* attrDesc)
-{
- if (!node.isElementNode())
- return;
-
- String attr = toElement(node).getAttribute(name);
- if (attr.isEmpty())
- return;
-
- stringBuilder.append(attrDesc);
- stringBuilder.appendLiteral("=\"");
- stringBuilder.append(attr);
- stringBuilder.appendLiteral("\"");
-}
-
-template <typename PositionType>
-std::ostream& printPosition(std::ostream& ostream, const PositionType& position)
-{
- if (position.isNull())
- return ostream << "null";
- ostream << position.anchorNode() << "@";
- if (position.isOffsetInAnchor())
- return ostream << position.offsetInContainerNode();
- return ostream << position.anchorType();
-}
-
-} // namespace
-
-std::ostream& operator<<(std::ostream& ostream, PositionAnchorType anchorType)
-{
- switch (anchorType) {
- case PositionAnchorType::AfterAnchor:
- return ostream << "afterAnchor";
- case PositionAnchorType::AfterChildren:
- return ostream << "afterChildren";
- case PositionAnchorType::BeforeAnchor:
- return ostream << "beforeAnchor";
- case PositionAnchorType::BeforeChildren:
- return ostream << "beforeChildren";
- case PositionAnchorType::OffsetInAnchor:
- return ostream << "offsetInAnchor";
- }
- ASSERT_NOT_REACHED();
- return ostream << "anchorType=" << static_cast<int>(anchorType);
-}
-
-// |std::ostream| version of |Node::showNode|
-std::ostream& operator<<(std::ostream& ostream, const Node& node)
-{
- ostream << node.nodeName().utf8().data();
- if (node.isTextNode())
- return ostream << " " << node.nodeValue();
- StringBuilder attrs;
- appendAttributeDesc(node, attrs, HTMLNames::idAttr, " ID");
- appendAttributeDesc(node, attrs, HTMLNames::classAttr, " CLASS");
- appendAttributeDesc(node, attrs, HTMLNames::styleAttr, " STYLE");
- return ostream << attrs.toString().utf8().data();
-}
-
-std::ostream& operator<<(std::ostream& ostream, const Node* node)
-{
- if (!node)
- return ostream << "null";
- return ostream << *node;
-}
-
-std::ostream& operator<<(std::ostream& ostream, const Position& position)
-{
- return printPosition(ostream, position);
-}
-
-std::ostream& operator<<(std::ostream& ostream, const PositionInComposedTree& position)
-{
- return printPosition(ostream, position);
-}
-
-} // namespace blink
« no previous file with comments | « Source/core/testing/CoreTestHelpers.h ('k') | Source/core/testing/CoreTestPrinters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698