| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 class DocumentMarkerControllerTest : public ::testing::Test { | 49 class DocumentMarkerControllerTest : public ::testing::Test { |
| 50 protected: | 50 protected: |
| 51 virtual void SetUp() OVERRIDE; | 51 virtual void SetUp() OVERRIDE; |
| 52 | 52 |
| 53 Document& document() const { return *m_document; } | 53 Document& document() const { return *m_document; } |
| 54 DocumentMarkerController& markerController() const { return m_document->mark
ers(); } | 54 DocumentMarkerController& markerController() const { return m_document->mark
ers(); } |
| 55 | 55 |
| 56 PassRefPtrWillBeRawPtr<Text> createTextNode(const char*); | 56 PassRefPtrWillBeRawPtr<Text> createTextNode(const char*); |
| 57 void markNodeContents(PassRefPtr<Node>); | 57 void markNodeContents(PassRefPtrWillBeRawPtr<Node>); |
| 58 void setBodyInnerHTML(const char*); | 58 void setBodyInnerHTML(const char*); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 61 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| 62 Document* m_document; | 62 Document* m_document; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 void DocumentMarkerControllerTest::SetUp() | 65 void DocumentMarkerControllerTest::SetUp() |
| 66 { | 66 { |
| 67 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | 67 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| 68 m_document = &m_dummyPageHolder->document(); | 68 m_document = &m_dummyPageHolder->document(); |
| 69 ASSERT(m_document); | 69 ASSERT(m_document); |
| 70 } | 70 } |
| 71 | 71 |
| 72 PassRefPtrWillBeRawPtr<Text> DocumentMarkerControllerTest::createTextNode(const
char* textContents) | 72 PassRefPtrWillBeRawPtr<Text> DocumentMarkerControllerTest::createTextNode(const
char* textContents) |
| 73 { | 73 { |
| 74 return document().createTextNode(String::fromUTF8(textContents)); | 74 return document().createTextNode(String::fromUTF8(textContents)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void DocumentMarkerControllerTest::markNodeContents(PassRefPtr<Node> node) | 77 void DocumentMarkerControllerTest::markNodeContents(PassRefPtrWillBeRawPtr<Node>
node) |
| 78 { | 78 { |
| 79 // Force renderers to be created; TextIterator, which is used in | 79 // Force renderers to be created; TextIterator, which is used in |
| 80 // DocumentMarkerControllerTest::addMarker(), needs them. | 80 // DocumentMarkerControllerTest::addMarker(), needs them. |
| 81 document().updateLayout(); | 81 document().updateLayout(); |
| 82 RefPtrWillBeRawPtr<Range> range = rangeOfContents(node.get()); | 82 RefPtrWillBeRawPtr<Range> range = rangeOfContents(node.get()); |
| 83 markerController().addMarker(range.get(), DocumentMarker::Spelling); | 83 markerController().addMarker(range.get(), DocumentMarker::Spelling); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void DocumentMarkerControllerTest::setBodyInnerHTML(const char* bodyContent) | 86 void DocumentMarkerControllerTest::setBodyInnerHTML(const char* bodyContent) |
| 87 { | 87 { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 markNodeContents(parent); | 194 markNodeContents(parent); |
| 195 EXPECT_EQ(1u, markerController().markers().size()); | 195 EXPECT_EQ(1u, markerController().markers().size()); |
| 196 setBodyInnerHTML(""); | 196 setBodyInnerHTML(""); |
| 197 } | 197 } |
| 198 // No more reference to marked node. | 198 // No more reference to marked node. |
| 199 Heap::collectAllGarbage(); | 199 Heap::collectAllGarbage(); |
| 200 EXPECT_EQ(0u, markerController().markers().size()); | 200 EXPECT_EQ(0u, markerController().markers().size()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 } | 203 } |
| OLD | NEW |