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

Side by Side Diff: Source/core/editing/iterators/TextIteratorTest.cpp

Issue 1041463003: Remove methods of TextIterator that take Range objects (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add assertions Created 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void TextIteratorTest::SetUp() 78 void TextIteratorTest::SetUp()
79 { 79 {
80 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); 80 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
81 m_document = toHTMLDocument(&m_dummyPageHolder->document()); 81 m_document = toHTMLDocument(&m_dummyPageHolder->document());
82 ASSERT(m_document); 82 ASSERT(m_document);
83 } 83 }
84 84
85 Vector<String> TextIteratorTest::iterate(TextIteratorBehavior iteratorBehavior) 85 Vector<String> TextIteratorTest::iterate(TextIteratorBehavior iteratorBehavior)
86 { 86 {
87 RefPtrWillBeRawPtr<Range> range = getBodyRange(); 87 RefPtrWillBeRawPtr<Range> range = getBodyRange();
88 TextIterator iterator(range.get(), iteratorBehavior); 88 TextIterator iterator(range->startPosition(), range->endPosition(), iterator Behavior);
89 return iterateWithIterator(iterator); 89 return iterateWithIterator(iterator);
90 } 90 }
91 91
92 Vector<String> TextIteratorTest::iteratePartial(const Position& start, const Pos ition& end, TextIteratorBehavior iteratorBehavior) 92 Vector<String> TextIteratorTest::iteratePartial(const Position& start, const Pos ition& end, TextIteratorBehavior iteratorBehavior)
93 { 93 {
94 TextIterator iterator(start, end, iteratorBehavior); 94 TextIterator iterator(start, end, iteratorBehavior);
95 return iterateWithIterator(iterator); 95 return iterateWithIterator(iterator);
96 } 96 }
97 97
98 Vector<String> TextIteratorTest::iterateWithIterator(TextIterator& iterator) 98 Vector<String> TextIteratorTest::iterateWithIterator(TextIterator& iterator)
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 TEST_F(TextIteratorTest, RangeLengthWithReplacedElements) 581 TEST_F(TextIteratorTest, RangeLengthWithReplacedElements)
582 { 582 {
583 static const char* bodyContent = 583 static const char* bodyContent =
584 "<div id=\"div\" contenteditable=\"true\">1<img src=\"foo.png\">3</div>" ; 584 "<div id=\"div\" contenteditable=\"true\">1<img src=\"foo.png\">3</div>" ;
585 setBodyInnerHTML(bodyContent); 585 setBodyInnerHTML(bodyContent);
586 document().view()->updateLayoutAndStyleIfNeededRecursive(); 586 document().view()->updateLayoutAndStyleIfNeededRecursive();
587 587
588 Node* divNode = document().getElementById("div"); 588 Node* divNode = document().getElementById("div");
589 RefPtrWillBeRawPtr<Range> range = Range::create(document(), divNode, 0, divN ode, 3); 589 RefPtrWillBeRawPtr<Range> range = Range::create(document(), divNode, 0, divN ode, 3);
590 590
591 EXPECT_EQ(3, TextIterator::rangeLength(range.get())); 591 EXPECT_EQ(3, TextIterator::rangeLength(range->startPosition(), range->endPos ition()));
592 } 592 }
593 593
594 TEST_F(TextIteratorTest, SubrangeWithReplacedElements) 594 TEST_F(TextIteratorTest, SubrangeWithReplacedElements)
595 { 595 {
596 static const char* bodyContent = 596 static const char* bodyContent =
597 "<div id=\"div\" contenteditable=\"true\">1<img src=\"foo.png\">345</div >"; 597 "<div id=\"div\" contenteditable=\"true\">1<img src=\"foo.png\">345</div >";
598 setBodyInnerHTML(bodyContent); 598 setBodyInnerHTML(bodyContent);
599 document().view()->updateLayoutAndStyleIfNeededRecursive(); 599 document().view()->updateLayoutAndStyleIfNeededRecursive();
600 600
601 Node* divNode = document().getElementById("div"); 601 Node* divNode = document().getElementById("div");
602 RefPtrWillBeRawPtr<Range> entireRange = Range::create(document(), divNode, 0 , divNode, 3); 602 RefPtrWillBeRawPtr<Range> entireRange = Range::create(document(), divNode, 0 , divNode, 3);
603 603
604 RefPtrWillBeRawPtr<Range> subrange = TextIterator::subrange(entireRange.get( ), 2, 3); 604 RefPtrWillBeRawPtr<Range> subrange = TextIterator::subrange(entireRange.get( ), 2, 3);
605 EXPECT_EQ(0, subrange->startOffset()); 605 EXPECT_EQ(0, subrange->startOffset());
606 EXPECT_EQ(3, subrange->endOffset()); 606 EXPECT_EQ(3, subrange->endOffset());
607 } 607 }
608 608
609 } 609 }
OLDNEW
« no previous file with comments | « Source/core/editing/iterators/TextIterator.cpp ('k') | Source/core/html/HTMLTextFormControlElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698