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/test/aura_test_base.h" | 9 #include "ui/aura/test/aura_test_base.h" |
10 #include "ui/aura/test/event_generator.h" | 10 #include "ui/aura/test/event_generator.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // mouse_pressed_handler()) are cleared when another root window takes capture. | 93 // mouse_pressed_handler()) are cleared when another root window takes capture. |
94 TEST_F(CaptureControllerTest, ResetMouseEventHandlerOnCapture) { | 94 TEST_F(CaptureControllerTest, ResetMouseEventHandlerOnCapture) { |
95 // Create a window inside the WindowEventDispatcher. | 95 // Create a window inside the WindowEventDispatcher. |
96 scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 96 scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
97 | 97 |
98 // Make a synthesized mouse down event. Ensure that the WindowEventDispatcher | 98 // Make a synthesized mouse down event. Ensure that the WindowEventDispatcher |
99 // will dispatch further mouse events to |w1|. | 99 // will dispatch further mouse events to |w1|. |
100 ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), | 100 ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), |
101 gfx::Point(5, 5), 0, 0); | 101 gfx::Point(5, 5), 0, 0); |
102 DispatchEventUsingWindowDispatcher(&mouse_pressed_event); | 102 DispatchEventUsingWindowDispatcher(&mouse_pressed_event); |
103 EXPECT_EQ(w1.get(), dispatcher()->mouse_pressed_handler()); | 103 EXPECT_EQ(w1.get(), host()->dispatcher()->mouse_pressed_handler()); |
104 | 104 |
105 // Build a window in the second WindowEventDispatcher. | 105 // Build a window in the second WindowEventDispatcher. |
106 scoped_ptr<aura::Window> w2( | 106 scoped_ptr<aura::Window> w2( |
107 CreateNormalWindow(2, second_host_->window(), NULL)); | 107 CreateNormalWindow(2, second_host_->window(), NULL)); |
108 | 108 |
109 // The act of having the second window take capture should clear out mouse | 109 // The act of having the second window take capture should clear out mouse |
110 // pressed handler in the first WindowEventDispatcher. | 110 // pressed handler in the first WindowEventDispatcher. |
111 w2->SetCapture(); | 111 w2->SetCapture(); |
112 EXPECT_EQ(NULL, dispatcher()->mouse_pressed_handler()); | 112 EXPECT_EQ(NULL, host()->dispatcher()->mouse_pressed_handler()); |
113 } | 113 } |
114 | 114 |
115 // Makes sure that when one window gets capture, it forces the release on the | 115 // Makes sure that when one window gets capture, it forces the release on the |
116 // other. This is needed has to be handled explicitly on Linux, and is a sanity | 116 // other. This is needed has to be handled explicitly on Linux, and is a sanity |
117 // check on Windows. | 117 // check on Windows. |
118 TEST_F(CaptureControllerTest, ResetOtherWindowCaptureOnCapture) { | 118 TEST_F(CaptureControllerTest, ResetOtherWindowCaptureOnCapture) { |
119 // Create a window inside the WindowEventDispatcher. | 119 // Create a window inside the WindowEventDispatcher. |
120 scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 120 scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
121 w1->SetCapture(); | 121 w1->SetCapture(); |
122 // Both capture clients should return the same capture window. | 122 // Both capture clients should return the same capture window. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetCaptureWindow()); | 159 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetCaptureWindow()); |
160 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetSecondCaptureWindow()); | 160 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetSecondCaptureWindow()); |
161 ui::TouchEvent touch_event( | 161 ui::TouchEvent touch_event( |
162 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, 0, ui::EventTimeForNow(), 1.0f, | 162 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, 0, ui::EventTimeForNow(), 1.0f, |
163 1.0f, 1.0f, 1.0f); | 163 1.0f, 1.0f, 1.0f); |
164 EXPECT_EQ(static_cast<ui::GestureConsumer*>(w2.get()), | 164 EXPECT_EQ(static_cast<ui::GestureConsumer*>(w2.get()), |
165 ui::GestureRecognizer::Get()->GetTouchLockedTarget(touch_event)); | 165 ui::GestureRecognizer::Get()->GetTouchLockedTarget(touch_event)); |
166 } | 166 } |
167 | 167 |
168 } // namespace views | 168 } // namespace views |
OLD | NEW |