Commit 1898ca85 authored by yosin@chromium.org's avatar yosin@chromium.org

Re-introduce printers for Node, Position, PositionAnchorType in GTest

This patch is inspired by http://crrev.com/1257203002, which makes printer for
|WTFString| in GTest.

This patch re-introduces printers for Node, Position and PositionAnchorType in
GTest rather than printing address of pointer by fixing ODR violation for
improving test authoring experience.

In http://crrev.com/1095913003, we introduced |Node| and |Position| printers for
GTest in "CoreTestHelpers.h". However, due by ODR violation, these printers
aren't used in GTest, since some test files uses |Node| as parameters for
GTest macros without including "CoreTestHelpers.h".

Note: ODR stands for One Definition Rule.

See details explanation in http://crrev.com/1257203002.

BUG=514330
TEST=webkit_unit_tests --gtest_fitler=EditingUtilitiesTest.*,VisibleUnitsTest.*

Review URL: https://codereview.chromium.org/1313283002

git-svn-id: svn://svn.chromium.org/blink/trunk@201207 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 784dbf3b
...@@ -3656,8 +3656,7 @@ ...@@ -3656,8 +3656,7 @@
'webcore_testing_files': [ 'webcore_testing_files': [
'<(blink_core_output_dir)/testing/InternalSettingsGenerated.cpp', '<(blink_core_output_dir)/testing/InternalSettingsGenerated.cpp',
'<(blink_core_output_dir)/testing/InternalSettingsGenerated.h', '<(blink_core_output_dir)/testing/InternalSettingsGenerated.h',
'testing/CoreTestHelpers.cpp', 'testing/CoreTestPrinters.cpp',
'testing/CoreTestHelpers.h',
'testing/DictionaryTest.cpp', 'testing/DictionaryTest.cpp',
'testing/DictionaryTest.h', 'testing/DictionaryTest.h',
'testing/DummyPageHolder.cpp', 'testing/DummyPageHolder.cpp',
......
...@@ -897,6 +897,11 @@ PassRefPtrWillBeRawPtr<T> T::create(Document& document) \ ...@@ -897,6 +897,11 @@ PassRefPtrWillBeRawPtr<T> T::create(Document& document) \
return adoptRefWillBeNoop(new T(document)); \ return adoptRefWillBeNoop(new T(document)); \
} }
// These printers are available only for testing in "webkit_unit_tests", and
// implemented in "core/testing/CoreTestPrinters.cpp".
std::ostream& operator<<(std::ostream&, const Node&);
std::ostream& operator<<(std::ostream&, const Node*);
} // namespace blink } // namespace blink
#ifndef NDEBUG #ifndef NDEBUG
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define EditingTestBase_h #define EditingTestBase_h
#include "core/editing/Position.h" #include "core/editing/Position.h"
#include "core/testing/CoreTestHelpers.h"
#include "wtf/Forward.h" #include "wtf/Forward.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
......
...@@ -390,6 +390,15 @@ inline PositionInComposedTree fromPositionInDOMTree<EditingInComposedTreeStrateg ...@@ -390,6 +390,15 @@ inline PositionInComposedTree fromPositionInDOMTree<EditingInComposedTreeStrateg
return toPositionInComposedTree(position); return toPositionInComposedTree(position);
} }
// These printers are available only for testing in "webkit_unit_tests", and
// implemented in "core/testing/CoreTestPrinters.cpp".
std::ostream& operator<<(std::ostream&, const Node&);
std::ostream& operator<<(std::ostream&, const Node*);
std::ostream& operator<<(std::ostream&, PositionAnchorType);
std::ostream& operator<<(std::ostream&, const Position&);
std::ostream& operator<<(std::ostream&, const PositionInComposedTree&);
} // namespace blink } // namespace blink
#ifndef NDEBUG #ifndef NDEBUG
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "core/html/HTMLDocument.h" #include "core/html/HTMLDocument.h"
#include "core/page/AutoscrollController.h" #include "core/page/AutoscrollController.h"
#include "core/page/Page.h" #include "core/page/Page.h"
#include "core/testing/CoreTestHelpers.h"
#include "core/testing/DummyPageHolder.h" #include "core/testing/DummyPageHolder.h"
#include "platform/PlatformMouseEvent.h" #include "platform/PlatformMouseEvent.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
......
// 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.
#ifndef CoreTestHelpers_h
#define CoreTestHelpers_h
#include "core/editing/Position.h"
namespace blink {
class Node;
std::ostream& operator<<(std::ostream&, const Node&);
std::ostream& operator<<(std::ostream&, const Node*);
std::ostream& operator<<(std::ostream&, PositionAnchorType);
std::ostream& operator<<(std::ostream&, const Position&);
std::ostream& operator<<(std::ostream&, const PositionInComposedTree&);
} // namespace blink
#endif // CoreTestHelpers_h
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "config.h" #include "config.h"
#include "core/testing/CoreTestHelpers.h"
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/dom/Range.h" #include "core/dom/Range.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment