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

Unified Diff: third_party/WebKit/Source/web/tests/TextSelectionRepaintTest.cpp

Issue 2521043003: Replace LayoutTests/paint/invalidation/text-selection-focus.html with a SimTest. (Closed)
Patch Set: copyrights. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/TextSelectionRepaintTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/TextSelectionRepaintTest.cpp b/third_party/WebKit/Source/web/tests/TextSelectionRepaintTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..053ecc23ca3f9ac02fa32a850fa07dea7592dbf2
--- /dev/null
+++ b/third_party/WebKit/Source/web/tests/TextSelectionRepaintTest.cpp
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/dom/Document.h"
+#include "core/editing/DOMSelection.h"
+#include "core/frame/LocalDOMWindow.h"
+#include "core/html/HTMLElement.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "web/tests/sim/SimCompositor.h"
+#include "web/tests/sim/SimDisplayItemList.h"
+#include "web/tests/sim/SimRequest.h"
+#include "web/tests/sim/SimTest.h"
+
+namespace blink {
+
+class TextSelectionRepaintTest : public SimTest {};
+
+TEST_F(TextSelectionRepaintTest, RepaintSelectionOnFocus) {
+ SimRequest mainResource("https://example.com/test.html", "text/html");
+
+ loadURL("https://example.com/test.html");
+
+ mainResource.complete(
+ "<!DOCTYPE html>"
+ "Text to select.");
+
+ // Focus the window.
+ EXPECT_FALSE(page().isFocused());
+ page().setFocused(true);
+
+ // First frame with nothing selected.
+ compositor().beginFrame();
+
+ // Select some text.
+ auto* body = document().body();
+ window().getSelection()->setBaseAndExtent(body, 0, body, 1);
+
+ // Unfocus the page and check for a pending frame.
+ page().setFocused(false);
+ EXPECT_TRUE(compositor().needsBeginFrame());
+
+ // Frame with the unfocused selection appearance.
+ compositor().beginFrame();
+
+ // Focus the page and check for a pending frame.
+ page().setFocused(true);
+ EXPECT_TRUE(compositor().needsBeginFrame());
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698