| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/mus/ws/event_dispatcher.h" | 5 #include "components/mus/ws/event_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 // one. | 1498 // one. |
| 1499 w1.reset(); | 1499 w1.reset(); |
| 1500 EXPECT_EQ(w3.get(), GetActiveSystemModalWindow()); | 1500 EXPECT_EQ(w3.get(), GetActiveSystemModalWindow()); |
| 1501 | 1501 |
| 1502 // Remove the last remaining system modal window. There should be no active | 1502 // Remove the last remaining system modal window. There should be no active |
| 1503 // one anymore. | 1503 // one anymore. |
| 1504 w3.reset(); | 1504 w3.reset(); |
| 1505 EXPECT_EQ(nullptr, GetActiveSystemModalWindow()); | 1505 EXPECT_EQ(nullptr, GetActiveSystemModalWindow()); |
| 1506 } | 1506 } |
| 1507 | 1507 |
| 1508 TEST_F(EventDispatcherTest, CaptureNotResetOnParentChange) { |
| 1509 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1510 DisableHitTest(w1.get()); |
| 1511 std::unique_ptr<ServerWindow> w11 = |
| 1512 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); |
| 1513 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| 1514 DisableHitTest(w2.get()); |
| 1515 |
| 1516 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1517 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1518 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); |
| 1519 w2->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1520 |
| 1521 // Send event that is over |w11|. |
| 1522 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1523 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1524 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1525 event_dispatcher()->ProcessEvent(mouse_pressed); |
| 1526 event_dispatcher()->SetCaptureWindow(w11.get(), false); |
| 1527 |
| 1528 std::unique_ptr<DispatchedEventDetails> details = |
| 1529 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1530 ASSERT_TRUE(details); |
| 1531 EXPECT_EQ(w11.get(), details->window); |
| 1532 EXPECT_FALSE(details->in_nonclient_area); |
| 1533 |
| 1534 // Move |w11| to |w2| and verify the mouse is still down, and |w11| has |
| 1535 // capture. |
| 1536 w2->Add(w11.get()); |
| 1537 EXPECT_TRUE(IsMouseButtonDown()); |
| 1538 EXPECT_EQ(w11.get(), |
| 1539 EventDispatcherTestApi(event_dispatcher()).capture_window()); |
| 1540 } |
| 1541 |
| 1508 } // namespace test | 1542 } // namespace test |
| 1509 } // namespace ws | 1543 } // namespace ws |
| 1510 } // namespace mus | 1544 } // namespace mus |
| OLD | NEW |