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

Side by Side Diff: Source/core/editing/FrameSelectionTest.cpp

Issue 1217943010: Add a FrameView lifecycle method that just updates layout, style and compositing. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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 // 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/editing/FrameSelection.h" 6 #include "core/editing/FrameSelection.h"
7 7
8 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 8 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 VisibleSelection invalidSelection; 92 VisibleSelection invalidSelection;
93 invalidSelection.setWithoutValidation(Position(anotherText, 0), Position(ano therText, 5)); 93 invalidSelection.setWithoutValidation(Position(anotherText, 0), Position(ano therText, 5));
94 setSelection(invalidSelection); 94 setSelection(invalidSelection);
95 95
96 EXPECT_TRUE(selection().isNone()); 96 EXPECT_TRUE(selection().isNone());
97 } 97 }
98 98
99 TEST_F(FrameSelectionTest, InvalidateCaretRect) 99 TEST_F(FrameSelectionTest, InvalidateCaretRect)
100 { 100 {
101 RefPtrWillBeRawPtr<Text> text = appendTextNode("Hello, World!"); 101 RefPtrWillBeRawPtr<Text> text = appendTextNode("Hello, World!");
102 document().view()->updateLayoutAndStyleForPainting(); 102 document().view()->updateAllLifecyclePhases();
103 103
104 VisibleSelection validSelection(Position(text, 0), Position(text, 0)); 104 VisibleSelection validSelection(Position(text, 0), Position(text, 0));
105 setSelection(validSelection); 105 setSelection(validSelection);
106 selection().setCaretRectNeedsUpdate(); 106 selection().setCaretRectNeedsUpdate();
107 EXPECT_TRUE(selection().isCaretBoundsDirty()); 107 EXPECT_TRUE(selection().isCaretBoundsDirty());
108 selection().invalidateCaretRect(); 108 selection().invalidateCaretRect();
109 EXPECT_FALSE(selection().isCaretBoundsDirty()); 109 EXPECT_FALSE(selection().isCaretBoundsDirty());
110 110
111 document().body()->removeChild(text); 111 document().body()->removeChild(text);
112 document().updateLayoutIgnorePendingStylesheets(); 112 document().updateLayoutIgnorePendingStylesheets();
113 selection().setCaretRectNeedsUpdate(); 113 selection().setCaretRectNeedsUpdate();
114 EXPECT_TRUE(selection().isCaretBoundsDirty()); 114 EXPECT_TRUE(selection().isCaretBoundsDirty());
115 selection().invalidateCaretRect(); 115 selection().invalidateCaretRect();
116 EXPECT_FALSE(selection().isCaretBoundsDirty()); 116 EXPECT_FALSE(selection().isCaretBoundsDirty());
117 } 117 }
118 118
119 TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) 119 TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout)
120 { 120 {
121 RefPtrWillBeRawPtr<Text> text = appendTextNode("Hello, World!"); 121 RefPtrWillBeRawPtr<Text> text = appendTextNode("Hello, World!");
122 document().view()->updateLayoutAndStyleForPainting(); 122 document().view()->updateAllLifecyclePhases();
123 123
124 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); 124 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION);
125 document().body()->focus(); 125 document().body()->focus();
126 EXPECT_TRUE(document().body()->focused()); 126 EXPECT_TRUE(document().body()->focused());
127 127
128 VisibleSelection validSelection(Position(text, 0), Position(text, 0)); 128 VisibleSelection validSelection(Position(text, 0), Position(text, 0));
129 selection().setCaretVisible(true); 129 selection().setCaretVisible(true);
130 setSelection(validSelection); 130 setSelection(validSelection);
131 EXPECT_TRUE(selection().isCaret()); 131 EXPECT_TRUE(selection().isCaret());
132 EXPECT_TRUE(selection().ShouldPaintCaretForTesting()); 132 EXPECT_TRUE(selection().ShouldPaintCaretForTesting());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 EXPECT_EQ_SELECTED_TEXT("Bar Baz"); 180 EXPECT_EQ_SELECTED_TEXT("Bar Baz");
181 // "Fo<o B|ar Baz," with the Character granularity. 181 // "Fo<o B|ar Baz," with the Character granularity.
182 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo sition(Position(text, 2)), CharacterGranularity); 182 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo sition(Position(text, 2)), CharacterGranularity);
183 EXPECT_EQ_SELECTED_TEXT("o B"); 183 EXPECT_EQ_SELECTED_TEXT("o B");
184 // "Fo<o B|ar Baz," with the Word granularity. 184 // "Fo<o B|ar Baz," with the Word granularity.
185 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo sition(Position(text, 2)), WordGranularity); 185 selection().moveRangeSelection(VisiblePosition(Position(text, 5)), VisiblePo sition(Position(text, 2)), WordGranularity);
186 EXPECT_EQ_SELECTED_TEXT("Foo Bar"); 186 EXPECT_EQ_SELECTED_TEXT("Foo Bar");
187 } 187 }
188 188
189 } // namespace blink 189 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/EditingTestBase.cpp ('k') | Source/core/editing/GranularityStrategyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698