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

Side by Side Diff: third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp

Issue 1488543002: DocumentMarkerControllerTest: drop unnecessary caching of Document reference. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 29 matching lines...) Expand all
40 #include "core/html/HTMLElement.h" 40 #include "core/html/HTMLElement.h"
41 #include "core/testing/DummyPageHolder.h" 41 #include "core/testing/DummyPageHolder.h"
42 #include "testing/gtest/include/gtest/gtest.h" 42 #include "testing/gtest/include/gtest/gtest.h"
43 #include "wtf/PassRefPtr.h" 43 #include "wtf/PassRefPtr.h"
44 #include "wtf/RefPtr.h" 44 #include "wtf/RefPtr.h"
45 45
46 namespace blink { 46 namespace blink {
47 47
48 class DocumentMarkerControllerTest : public ::testing::Test { 48 class DocumentMarkerControllerTest : public ::testing::Test {
49 protected: 49 protected:
50 void SetUp() override; 50 DocumentMarkerControllerTest()
51 : m_dummyPageHolder(DummyPageHolder::create(IntSize(800, 600)))
52 {
53 }
51 54
52 Document& document() const { return *m_document; } 55 Document& document() const { return m_dummyPageHolder->document(); }
53 DocumentMarkerController& markerController() const { return m_document->mark ers(); } 56 DocumentMarkerController& markerController() const { return document().marke rs(); }
54 57
55 PassRefPtrWillBeRawPtr<Text> createTextNode(const char*); 58 PassRefPtrWillBeRawPtr<Text> createTextNode(const char*);
56 void markNodeContents(PassRefPtrWillBeRawPtr<Node>); 59 void markNodeContents(PassRefPtrWillBeRawPtr<Node>);
57 void markNodeContentsWithComposition(PassRefPtrWillBeRawPtr<Node>); 60 void markNodeContentsWithComposition(PassRefPtrWillBeRawPtr<Node>);
58 void setBodyInnerHTML(const char*); 61 void setBodyInnerHTML(const char*);
59 62
60 private: 63 private:
61 OwnPtr<DummyPageHolder> m_dummyPageHolder; 64 OwnPtr<DummyPageHolder> m_dummyPageHolder;
62 RefPtrWillBePersistent<Document> m_document;
63 }; 65 };
64 66
65 void DocumentMarkerControllerTest::SetUp()
66 {
67 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
68 m_document = &m_dummyPageHolder->document();
69 ASSERT(m_document);
70 }
71
72 PassRefPtrWillBeRawPtr<Text> DocumentMarkerControllerTest::createTextNode(const char* textContents) 67 PassRefPtrWillBeRawPtr<Text> DocumentMarkerControllerTest::createTextNode(const char* textContents)
73 { 68 {
74 return document().createTextNode(String::fromUTF8(textContents)); 69 return document().createTextNode(String::fromUTF8(textContents));
75 } 70 }
76 71
77 void DocumentMarkerControllerTest::markNodeContents(PassRefPtrWillBeRawPtr<Node> node) 72 void DocumentMarkerControllerTest::markNodeContents(PassRefPtrWillBeRawPtr<Node> node)
78 { 73 {
79 // Force layoutObjects to be created; TextIterator, which is used in 74 // Force layoutObjects to be created; TextIterator, which is used in
80 // DocumentMarkerControllerTest::addMarker(), needs them. 75 // DocumentMarkerControllerTest::addMarker(), needs them.
81 document().updateLayout(); 76 document().updateLayout();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 setBodyInnerHTML("<div style='margin: 100px'>foo</div>"); 247 setBodyInnerHTML("<div style='margin: 100px'>foo</div>");
253 RefPtrWillBeRawPtr<Node> text = document().body()->firstChild()->firstChild( ); 248 RefPtrWillBeRawPtr<Node> text = document().body()->firstChild()->firstChild( );
254 document().updateLayout(); 249 document().updateLayout();
255 markerController().addCompositionMarker(Position(text, 0), Position(text, 1) , Color::black, false, Color::black); 250 markerController().addCompositionMarker(Position(text, 0), Position(text, 1) , Color::black, false, Color::black);
256 markerController().addCompositionMarker(Position(text, 1), Position(text, 3) , Color::black, true, Color::black); 251 markerController().addCompositionMarker(Position(text, 1), Position(text, 3) , Color::black, true, Color::black);
257 252
258 EXPECT_EQ(2u, markerController().markers().size()); 253 EXPECT_EQ(2u, markerController().markers().size());
259 } 254 }
260 255
261 } // namespace blink 256 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698