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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « Source/core/editing/EditingTestBase.h ('k') | Source/core/editing/VisiblePositionTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/editing/EditingTestBase.h"
7
8 #include "core/dom/Document.h"
9 #include "core/dom/Range.h"
10 #include "core/dom/Text.h"
11 #include "core/html/HTMLElement.h"
12 #include "core/testing/DummyPageHolder.h"
13
14 namespace blink {
15
16 EditingTestBase::EditingTestBase()
17 {
18 }
19
20 EditingTestBase::~EditingTestBase()
21 {
22 }
23
24 Document& EditingTestBase::document() const
25 {
26 return m_dummyPageHolder->document();
27 }
28
29 void EditingTestBase::SetUp()
30 {
31 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
32 }
33
34 PassRefPtrWillBeRawPtr<ShadowRoot> EditingTestBase::createShadowRootForElementWi thIDAndSetInnerHTML(TreeScope& scope, const char* hostElementID, const char* sha dowRootContent)
35 {
36 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = scope.getElementById(AtomicStrin g::fromUTF8(hostElementID))->createShadowRoot(ASSERT_NO_EXCEPTION);
37 shadowRoot->setInnerHTML(String::fromUTF8(shadowRootContent), ASSERT_NO_EXCE PTION);
38 return shadowRoot.release();
39 }
40
41 void EditingTestBase::setBodyContent(const char* bodyContent)
42 {
43 document().body()->setInnerHTML(String::fromUTF8(bodyContent), ASSERT_NO_EXC EPTION);
44 }
45
46 PassRefPtrWillBeRawPtr<ShadowRoot> EditingTestBase::setShadowContent(const char* shadowContent)
47 {
48 return createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", s hadowContent);
49 }
50
51 Position EditingTestBase::positionInDOMTree(Node& anchor, int offset)
52 {
53 return Position(&anchor, offset, Position::PositionIsOffsetInAnchor);
54 }
55
56 PositionInComposedTree EditingTestBase::positionInComposedTree(Node& anchor, int offset)
57 {
58 return PositionInComposedTree(&anchor, offset, PositionInComposedTree::Posit ionIsOffsetInAnchor);
59 }
60
61 } // namespace blink
OLDNEW
« 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