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

Unified Diff: Source/core/editing/EditingTestBase.cpp

Issue 1204953002: Introduce EditingTestBase to share code among test files for editing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-24T15:31:52 Rebase for chaning bot(?) Created 5 years, 6 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/editing/EditingTestBase.h ('k') | Source/core/editing/VisiblePositionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/EditingTestBase.cpp
diff --git a/Source/core/editing/EditingTestBase.cpp b/Source/core/editing/EditingTestBase.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d22b8d7e0fb046feb7439be5d14418472fa7a593
--- /dev/null
+++ b/Source/core/editing/EditingTestBase.cpp
@@ -0,0 +1,61 @@
+// 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/editing/EditingTestBase.h"
+
+#include "core/dom/Document.h"
+#include "core/dom/Range.h"
+#include "core/dom/Text.h"
+#include "core/html/HTMLElement.h"
+#include "core/testing/DummyPageHolder.h"
+
+namespace blink {
+
+EditingTestBase::EditingTestBase()
+{
+}
+
+EditingTestBase::~EditingTestBase()
+{
+}
+
+Document& EditingTestBase::document() const
+{
+ return m_dummyPageHolder->document();
+}
+
+void EditingTestBase::SetUp()
+{
+ m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
+}
+
+PassRefPtrWillBeRawPtr<ShadowRoot> EditingTestBase::createShadowRootForElementWithIDAndSetInnerHTML(TreeScope& scope, const char* hostElementID, const char* shadowRootContent)
+{
+ RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = scope.getElementById(AtomicString::fromUTF8(hostElementID))->createShadowRoot(ASSERT_NO_EXCEPTION);
+ shadowRoot->setInnerHTML(String::fromUTF8(shadowRootContent), ASSERT_NO_EXCEPTION);
+ return shadowRoot.release();
+}
+
+void EditingTestBase::setBodyContent(const char* bodyContent)
+{
+ document().body()->setInnerHTML(String::fromUTF8(bodyContent), ASSERT_NO_EXCEPTION);
+}
+
+PassRefPtrWillBeRawPtr<ShadowRoot> EditingTestBase::setShadowContent(const char* shadowContent)
+{
+ return createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent);
+}
+
+Position EditingTestBase::positionInDOMTree(Node& anchor, int offset)
+{
+ return Position(&anchor, offset, Position::PositionIsOffsetInAnchor);
+}
+
+PositionInComposedTree EditingTestBase::positionInComposedTree(Node& anchor, int offset)
+{
+ return PositionInComposedTree(&anchor, offset, PositionInComposedTree::PositionIsOffsetInAnchor);
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/editing/EditingTestBase.h ('k') | Source/core/editing/VisiblePositionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698