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/views/corewm/capture_controller.h" | 5 #include "ui/views/corewm/capture_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/aura/env.h" | 8 #include "ui/aura/env.h" |
9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Makes sure that internal details that are set on mouse down (such as | 96 // Makes sure that internal details that are set on mouse down (such as |
97 // mouse_pressed_handler()) are cleared when another root window takes capture. | 97 // mouse_pressed_handler()) are cleared when another root window takes capture. |
98 TEST_F(CaptureControllerTest, ResetMouseEventHandlerOnCapture) { | 98 TEST_F(CaptureControllerTest, ResetMouseEventHandlerOnCapture) { |
99 // Create a window inside the RootWindow. | 99 // Create a window inside the RootWindow. |
100 scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 100 scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
101 | 101 |
102 // Make a synthesized mouse down event. Ensure that the RootWindow will | 102 // Make a synthesized mouse down event. Ensure that the RootWindow will |
103 // dispatch further mouse events to |w1|. | 103 // dispatch further mouse events to |w1|. |
104 ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), | 104 ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), |
105 gfx::Point(5, 5), 0, 0); | 105 gfx::Point(5, 5), 0, 0); |
106 dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent( | 106 DispatchEventUsingWindowDispatcher(&mouse_pressed_event); |
107 &mouse_pressed_event); | |
108 EXPECT_EQ(w1.get(), dispatcher()->mouse_pressed_handler()); | 107 EXPECT_EQ(w1.get(), dispatcher()->mouse_pressed_handler()); |
109 | 108 |
110 // Build a window in the second RootWindow. | 109 // Build a window in the second RootWindow. |
111 scoped_ptr<aura::Window> w2( | 110 scoped_ptr<aura::Window> w2( |
112 CreateNormalWindow(2, second_root_->window(), NULL)); | 111 CreateNormalWindow(2, second_root_->window(), NULL)); |
113 | 112 |
114 // The act of having the second window take capture should clear out mouse | 113 // The act of having the second window take capture should clear out mouse |
115 // pressed handler in the first RootWindow. | 114 // pressed handler in the first RootWindow. |
116 w2->SetCapture(); | 115 w2->SetCapture(); |
117 EXPECT_EQ(NULL, dispatcher()->mouse_pressed_handler()); | 116 EXPECT_EQ(NULL, dispatcher()->mouse_pressed_handler()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetCaptureWindow()); | 162 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetCaptureWindow()); |
164 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetSecondCaptureWindow()); | 163 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetSecondCaptureWindow()); |
165 ui::TouchEvent touch_event( | 164 ui::TouchEvent touch_event( |
166 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, 0, ui::EventTimeForNow(), 1.0f, | 165 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, 0, ui::EventTimeForNow(), 1.0f, |
167 1.0f, 1.0f, 1.0f); | 166 1.0f, 1.0f, 1.0f); |
168 EXPECT_EQ(static_cast<ui::GestureConsumer*>(w2.get()), | 167 EXPECT_EQ(static_cast<ui::GestureConsumer*>(w2.get()), |
169 ui::GestureRecognizer::Get()->GetTouchLockedTarget(touch_event)); | 168 ui::GestureRecognizer::Get()->GetTouchLockedTarget(touch_event)); |
170 } | 169 } |
171 | 170 |
172 } // namespace views | 171 } // namespace views |
OLD | NEW |