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

Side by Side Diff: Source/core/dom/RangeTest.cpp

Issue 224113002: Oilpan: move Range object to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use STACK_ALLOCATED() + incorporate ager's overview of macros in this area. Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/dom/Range.h" 6 #include "core/dom/Range.h"
7 7
8 #include "bindings/v8/ExceptionStatePlaceholder.h" 8 #include "bindings/v8/ExceptionStatePlaceholder.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/Text.h" 10 #include "core/dom/Text.h"
11 #include "core/html/HTMLBodyElement.h" 11 #include "core/html/HTMLBodyElement.h"
12 #include "core/html/HTMLDocument.h" 12 #include "core/html/HTMLDocument.h"
13 #include "core/html/HTMLElement.h" 13 #include "core/html/HTMLElement.h"
14 #include "core/html/HTMLHtmlElement.h" 14 #include "core/html/HTMLHtmlElement.h"
15 #include "platform/heap/Handle.h"
15 #include "wtf/Compiler.h" 16 #include "wtf/Compiler.h"
16 #include "wtf/RefPtr.h" 17 #include "wtf/RefPtr.h"
17 #include "wtf/text/AtomicString.h" 18 #include "wtf/text/AtomicString.h"
18 #include <gtest/gtest.h> 19 #include <gtest/gtest.h>
19 20
20 using namespace WebCore; 21 using namespace WebCore;
21 22
22 namespace { 23 namespace {
23 24
24 class RangeTest : public ::testing::Test { 25 class RangeTest : public ::testing::Test {
(...skipping 17 matching lines...) Expand all
42 HTMLDocument& RangeTest::document() const 43 HTMLDocument& RangeTest::document() const
43 { 44 {
44 return *m_document; 45 return *m_document;
45 } 46 }
46 47
47 TEST_F(RangeTest, SplitTextNodeRangeWithinText) 48 TEST_F(RangeTest, SplitTextNodeRangeWithinText)
48 { 49 {
49 document().body()->setInnerHTML("1234", ASSERT_NO_EXCEPTION); 50 document().body()->setInnerHTML("1234", ASSERT_NO_EXCEPTION);
50 Text* oldText = toText(document().body()->firstChild()); 51 Text* oldText = toText(document().body()->firstChild());
51 52
52 RefPtr<Range> range04 = Range::create(document(), oldText, 0, oldText, 4); 53 RefPtrWillBeRawPtr<Range> range04 = Range::create(document(), oldText, 0, ol dText, 4);
53 RefPtr<Range> range02 = Range::create(document(), oldText, 0, oldText, 2); 54 RefPtrWillBeRawPtr<Range> range02 = Range::create(document(), oldText, 0, ol dText, 2);
54 RefPtr<Range> range22 = Range::create(document(), oldText, 2, oldText, 2); 55 RefPtrWillBeRawPtr<Range> range22 = Range::create(document(), oldText, 2, ol dText, 2);
55 RefPtr<Range> range24 = Range::create(document(), oldText, 2, oldText, 4); 56 RefPtrWillBeRawPtr<Range> range24 = Range::create(document(), oldText, 2, ol dText, 4);
56 57
57 oldText->splitText(2, ASSERT_NO_EXCEPTION); 58 oldText->splitText(2, ASSERT_NO_EXCEPTION);
58 Text* newText = toText(oldText->nextSibling()); 59 Text* newText = toText(oldText->nextSibling());
59 60
60 EXPECT_TRUE(range04->boundaryPointsValid()); 61 EXPECT_TRUE(range04->boundaryPointsValid());
61 EXPECT_EQ(oldText, range04->startContainer()); 62 EXPECT_EQ(oldText, range04->startContainer());
62 EXPECT_EQ(0, range04->startOffset()); 63 EXPECT_EQ(0, range04->startOffset());
63 EXPECT_EQ(newText, range04->endContainer()); 64 EXPECT_EQ(newText, range04->endContainer());
64 EXPECT_EQ(2, range04->endOffset()); 65 EXPECT_EQ(2, range04->endOffset());
65 66
(...skipping 19 matching lines...) Expand all
85 86
86 TEST_F(RangeTest, SplitTextNodeRangeOutsideText) 87 TEST_F(RangeTest, SplitTextNodeRangeOutsideText)
87 { 88 {
88 document().body()->setInnerHTML("<span id=\"outer\">0<span id=\"inner-left\" >1</span>SPLITME<span id=\"inner-right\">2</span>3</span>", ASSERT_NO_EXCEPTION) ; 89 document().body()->setInnerHTML("<span id=\"outer\">0<span id=\"inner-left\" >1</span>SPLITME<span id=\"inner-right\">2</span>3</span>", ASSERT_NO_EXCEPTION) ;
89 90
90 Element* outer = document().getElementById(AtomicString::fromUTF8("outer")); 91 Element* outer = document().getElementById(AtomicString::fromUTF8("outer"));
91 Element* innerLeft = document().getElementById(AtomicString::fromUTF8("inner -left")); 92 Element* innerLeft = document().getElementById(AtomicString::fromUTF8("inner -left"));
92 Element* innerRight = document().getElementById(AtomicString::fromUTF8("inne r-right")); 93 Element* innerRight = document().getElementById(AtomicString::fromUTF8("inne r-right"));
93 Text* oldText = toText(outer->childNodes()->item(2)); 94 Text* oldText = toText(outer->childNodes()->item(2));
94 95
95 RefPtr<Range> rangeOuterOutside = Range::create(document(), outer, 0, outer, 5); 96 RefPtrWillBeRawPtr<Range> rangeOuterOutside = Range::create(document(), oute r, 0, outer, 5);
96 RefPtr<Range> rangeOuterInside = Range::create(document(), outer, 1, outer, 4); 97 RefPtrWillBeRawPtr<Range> rangeOuterInside = Range::create(document(), outer , 1, outer, 4);
97 RefPtr<Range> rangeOuterSurroundingText = Range::create(document(), outer, 2 , outer, 3); 98 RefPtrWillBeRawPtr<Range> rangeOuterSurroundingText = Range::create(document (), outer, 2, outer, 3);
98 RefPtr<Range> rangeInnerLeft = Range::create(document(), innerLeft, 0, inner Left, 1); 99 RefPtrWillBeRawPtr<Range> rangeInnerLeft = Range::create(document(), innerLe ft, 0, innerLeft, 1);
99 RefPtr<Range> rangeInnerRight = Range::create(document(), innerRight, 0, inn erRight, 1); 100 RefPtrWillBeRawPtr<Range> rangeInnerRight = Range::create(document(), innerR ight, 0, innerRight, 1);
100 RefPtr<Range> rangeFromTextToMiddleOfElement = Range::create(document(), old Text, 6, outer, 3); 101 RefPtrWillBeRawPtr<Range> rangeFromTextToMiddleOfElement = Range::create(doc ument(), oldText, 6, outer, 3);
101 102
102 oldText->splitText(3, ASSERT_NO_EXCEPTION); 103 oldText->splitText(3, ASSERT_NO_EXCEPTION);
103 Text* newText = toText(oldText->nextSibling()); 104 Text* newText = toText(oldText->nextSibling());
104 105
105 EXPECT_TRUE(rangeOuterOutside->boundaryPointsValid()); 106 EXPECT_TRUE(rangeOuterOutside->boundaryPointsValid());
106 EXPECT_EQ(outer, rangeOuterOutside->startContainer()); 107 EXPECT_EQ(outer, rangeOuterOutside->startContainer());
107 EXPECT_EQ(0, rangeOuterOutside->startOffset()); 108 EXPECT_EQ(0, rangeOuterOutside->startOffset());
108 EXPECT_EQ(outer, rangeOuterOutside->endContainer()); 109 EXPECT_EQ(outer, rangeOuterOutside->endContainer());
109 EXPECT_EQ(6, rangeOuterOutside->endOffset()); // Increased by 1 since a new node is inserted. 110 EXPECT_EQ(6, rangeOuterOutside->endOffset()); // Increased by 1 since a new node is inserted.
110 111
(...skipping 22 matching lines...) Expand all
133 EXPECT_EQ(1, rangeInnerRight->endOffset()); 134 EXPECT_EQ(1, rangeInnerRight->endOffset());
134 135
135 EXPECT_TRUE(rangeFromTextToMiddleOfElement->boundaryPointsValid()); 136 EXPECT_TRUE(rangeFromTextToMiddleOfElement->boundaryPointsValid());
136 EXPECT_EQ(newText, rangeFromTextToMiddleOfElement->startContainer()); 137 EXPECT_EQ(newText, rangeFromTextToMiddleOfElement->startContainer());
137 EXPECT_EQ(3, rangeFromTextToMiddleOfElement->startOffset()); 138 EXPECT_EQ(3, rangeFromTextToMiddleOfElement->startOffset());
138 EXPECT_EQ(outer, rangeFromTextToMiddleOfElement->endContainer()); 139 EXPECT_EQ(outer, rangeFromTextToMiddleOfElement->endContainer());
139 EXPECT_EQ(4, rangeFromTextToMiddleOfElement->endOffset()); 140 EXPECT_EQ(4, rangeFromTextToMiddleOfElement->endOffset());
140 } 141 }
141 142
142 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698