| OLD | NEW |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 class TextIteratorTest : public ::testing::Test { | 58 class TextIteratorTest : public ::testing::Test { |
| 59 protected: | 59 protected: |
| 60 virtual void SetUp() OVERRIDE; | 60 virtual void SetUp() OVERRIDE; |
| 61 | 61 |
| 62 HTMLDocument& document() const; | 62 HTMLDocument& document() const; |
| 63 | 63 |
| 64 Vector<String> iterate(TextIteratorBehavior = TextIteratorDefaultBehavior); | 64 Vector<String> iterate(TextIteratorBehavior = TextIteratorDefaultBehavior); |
| 65 | 65 |
| 66 void setBodyInnerHTML(const char*); | 66 void setBodyInnerHTML(const char*); |
| 67 PassRefPtr<Range> getBodyRange() const; | 67 PassRefPtrWillBeRawPtr<Range> getBodyRange() const; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 70 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| 71 | 71 |
| 72 HTMLDocument* m_document; | 72 HTMLDocument* m_document; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 void TextIteratorTest::SetUp() | 75 void TextIteratorTest::SetUp() |
| 76 { | 76 { |
| 77 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | 77 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| 78 m_document = toHTMLDocument(&m_dummyPageHolder->document()); | 78 m_document = toHTMLDocument(&m_dummyPageHolder->document()); |
| 79 ASSERT(m_document); | 79 ASSERT(m_document); |
| 80 } | 80 } |
| 81 | 81 |
| 82 Vector<String> TextIteratorTest::iterate(TextIteratorBehavior iteratorBehavior) | 82 Vector<String> TextIteratorTest::iterate(TextIteratorBehavior iteratorBehavior) |
| 83 { | 83 { |
| 84 document().view()->updateLayoutAndStyleIfNeededRecursive(); // Force rendere
rs to be created; TextIterator needs them. | 84 document().view()->updateLayoutAndStyleIfNeededRecursive(); // Force rendere
rs to be created; TextIterator needs them. |
| 85 | 85 |
| 86 RefPtr<Range> range = getBodyRange(); | 86 RefPtrWillBeRawPtr<Range> range = getBodyRange(); |
| 87 TextIterator textIterator(range.get(), iteratorBehavior); | 87 TextIterator textIterator(range.get(), iteratorBehavior); |
| 88 Vector<String> textChunks; | 88 Vector<String> textChunks; |
| 89 while (!textIterator.atEnd()) { | 89 while (!textIterator.atEnd()) { |
| 90 textChunks.append(textIterator.substring(0, textIterator.length())); | 90 textChunks.append(textIterator.substring(0, textIterator.length())); |
| 91 textIterator.advance(); | 91 textIterator.advance(); |
| 92 } | 92 } |
| 93 return textChunks; | 93 return textChunks; |
| 94 } | 94 } |
| 95 | 95 |
| 96 HTMLDocument& TextIteratorTest::document() const | 96 HTMLDocument& TextIteratorTest::document() const |
| 97 { | 97 { |
| 98 return *m_document; | 98 return *m_document; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void TextIteratorTest::setBodyInnerHTML(const char* bodyContent) | 101 void TextIteratorTest::setBodyInnerHTML(const char* bodyContent) |
| 102 { | 102 { |
| 103 document().body()->setInnerHTML(String::fromUTF8(bodyContent), ASSERT_NO_EXC
EPTION); | 103 document().body()->setInnerHTML(String::fromUTF8(bodyContent), ASSERT_NO_EXC
EPTION); |
| 104 } | 104 } |
| 105 | 105 |
| 106 PassRefPtr<Range> TextIteratorTest::getBodyRange() const | 106 PassRefPtrWillBeRawPtr<Range> TextIteratorTest::getBodyRange() const |
| 107 { | 107 { |
| 108 RefPtr<Range> range(Range::create(document())); | 108 RefPtrWillBeRawPtr<Range> range(Range::create(document())); |
| 109 range->selectNode(document().body()); | 109 range->selectNode(document().body()); |
| 110 return range.release(); | 110 return range.release(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 Vector<String> createVectorString(const char* const* rawStrings, size_t size) | 113 Vector<String> createVectorString(const char* const* rawStrings, size_t size) |
| 114 { | 114 { |
| 115 Vector<String> result; | 115 Vector<String> result; |
| 116 result.append(rawStrings, size); | 116 result.append(rawStrings, size); |
| 117 return result; | 117 return result; |
| 118 } | 118 } |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 // Vector<String> expectedTextChunks = createVectorString(expectedTextChunks
RawString, WTF_ARRAY_LENGTH(expectedTextChunksRawString)); | 422 // Vector<String> expectedTextChunks = createVectorString(expectedTextChunks
RawString, WTF_ARRAY_LENGTH(expectedTextChunksRawString)); |
| 423 Vector<String> expectedTextChunks; // Empty. | 423 Vector<String> expectedTextChunks; // Empty. |
| 424 | 424 |
| 425 setBodyInnerHTML(bodyContent); | 425 setBodyInnerHTML(bodyContent); |
| 426 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); | 426 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); |
| 427 | 427 |
| 428 EXPECT_EQ(expectedTextChunks, iterate(TextIteratorEntersAuthorShadowRoots)); | 428 EXPECT_EQ(expectedTextChunks, iterate(TextIteratorEntersAuthorShadowRoots)); |
| 429 } | 429 } |
| 430 | 430 |
| 431 } | 431 } |
| OLD | NEW |