| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/wm/core/capture_controller.h" | 5 #include "ui/wm/core/capture_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 // Makes sure that internal details that are set on mouse down (such as | 109 // Makes sure that internal details that are set on mouse down (such as |
| 110 // mouse_pressed_handler()) are cleared when another root window takes capture. | 110 // mouse_pressed_handler()) are cleared when another root window takes capture. |
| 111 TEST_F(CaptureControllerTest, ResetMouseEventHandlerOnCapture) { | 111 TEST_F(CaptureControllerTest, ResetMouseEventHandlerOnCapture) { |
| 112 // Create a window inside the WindowEventDispatcher. | 112 // Create a window inside the WindowEventDispatcher. |
| 113 std::unique_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 113 std::unique_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
| 114 | 114 |
| 115 // Make a synthesized mouse down event. Ensure that the WindowEventDispatcher | 115 // Make a synthesized mouse down event. Ensure that the WindowEventDispatcher |
| 116 // will dispatch further mouse events to |w1|. | 116 // will dispatch further mouse events to |w1|. |
| 117 ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), | 117 ui::MouseEvent mouse_pressed_event( |
| 118 gfx::Point(5, 5), ui::EventTimeForNow(), 0, | 118 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 119 0); | 119 ui::EventTimeForNow(), 0, 0, |
| 120 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 120 DispatchEventUsingWindowDispatcher(&mouse_pressed_event); | 121 DispatchEventUsingWindowDispatcher(&mouse_pressed_event); |
| 121 EXPECT_EQ(w1.get(), host()->dispatcher()->mouse_pressed_handler()); | 122 EXPECT_EQ(w1.get(), host()->dispatcher()->mouse_pressed_handler()); |
| 122 | 123 |
| 123 // Build a window in the second WindowEventDispatcher. | 124 // Build a window in the second WindowEventDispatcher. |
| 124 std::unique_ptr<aura::Window> w2( | 125 std::unique_ptr<aura::Window> w2( |
| 125 CreateNormalWindow(2, second_host_->window(), NULL)); | 126 CreateNormalWindow(2, second_host_->window(), NULL)); |
| 126 | 127 |
| 127 // The act of having the second window take capture should clear out mouse | 128 // The act of having the second window take capture should clear out mouse |
| 128 // pressed handler in the first WindowEventDispatcher. | 129 // pressed handler in the first WindowEventDispatcher. |
| 129 w2->SetCapture(); | 130 w2->SetCapture(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 // and should release capture on it. | 251 // and should release capture on it. |
| 251 delegate->window()->SetCapture(); | 252 delegate->window()->SetCapture(); |
| 252 | 253 |
| 253 // capture should not be set upon exit from SetCapture() above. | 254 // capture should not be set upon exit from SetCapture() above. |
| 254 aura::client::CaptureClient* capture_client = | 255 aura::client::CaptureClient* capture_client = |
| 255 aura::client::GetCaptureClient(root_window()); | 256 aura::client::GetCaptureClient(root_window()); |
| 256 ASSERT_NE(nullptr, capture_client); | 257 ASSERT_NE(nullptr, capture_client); |
| 257 EXPECT_EQ(nullptr, capture_client->GetCaptureWindow()); | 258 EXPECT_EQ(nullptr, capture_client->GetCaptureWindow()); |
| 258 | 259 |
| 259 // Send a mouse click. We no longer hold capture so this should not crash. | 260 // Send a mouse click. We no longer hold capture so this should not crash. |
| 260 ui::MouseEvent mouse_press(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 261 ui::MouseEvent mouse_press( |
| 261 base::TimeTicks(), 0, 0); | 262 ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), base::TimeTicks(), 0, 0, |
| 263 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 262 DispatchEventUsingWindowDispatcher(&mouse_press); | 264 DispatchEventUsingWindowDispatcher(&mouse_press); |
| 263 } | 265 } |
| 264 | 266 |
| 265 } // namespace wm | 267 } // namespace wm |
| OLD | NEW |