OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/dom/Document.h" |
| 6 #include "core/editing/DOMSelection.h" |
| 7 #include "core/frame/LocalDOMWindow.h" |
| 8 #include "core/html/HTMLElement.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "web/tests/sim/SimCompositor.h" |
| 11 #include "web/tests/sim/SimDisplayItemList.h" |
| 12 #include "web/tests/sim/SimRequest.h" |
| 13 #include "web/tests/sim/SimTest.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 class TextSelectionRepaintTest : public SimTest {}; |
| 18 |
| 19 TEST_F(TextSelectionRepaintTest, RepaintSelectionOnFocus) { |
| 20 SimRequest mainResource("https://example.com/test.html", "text/html"); |
| 21 |
| 22 loadURL("https://example.com/test.html"); |
| 23 |
| 24 mainResource.complete( |
| 25 "<!DOCTYPE html>" |
| 26 "Text to select."); |
| 27 |
| 28 // Focus the window. |
| 29 EXPECT_FALSE(page().isFocused()); |
| 30 page().setFocused(true); |
| 31 |
| 32 // First frame with nothing selected. |
| 33 compositor().beginFrame(); |
| 34 |
| 35 // Select some text. |
| 36 auto* body = document().body(); |
| 37 window().getSelection()->setBaseAndExtent(body, 0, body, 1); |
| 38 |
| 39 // Unfocus the page and check for a pending frame. |
| 40 page().setFocused(false); |
| 41 EXPECT_TRUE(compositor().needsBeginFrame()); |
| 42 |
| 43 // Frame with the unfocused selection appearance. |
| 44 compositor().beginFrame(); |
| 45 |
| 46 // Focus the page and check for a pending frame. |
| 47 page().setFocused(true); |
| 48 EXPECT_TRUE(compositor().needsBeginFrame()); |
| 49 } |
| 50 |
| 51 } // namespace blink |
OLD | NEW |