| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "ui/aura/env.h" | 9 #include "ui/aura/env.h" |
| 10 #include "ui/aura/test/event_generator.h" | |
| 11 #include "ui/aura/test/test_window_delegate.h" | 10 #include "ui/aura/test/test_window_delegate.h" |
| 12 #include "ui/aura/window_event_dispatcher.h" | 11 #include "ui/aura/window_event_dispatcher.h" |
| 13 #include "ui/aura/window_tree_host.h" | 12 #include "ui/aura/window_tree_host.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/base/ui_base_paths.h" | 14 #include "ui/base/ui_base_paths.h" |
| 16 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
| 16 #include "ui/events/test/event_generator.h" |
| 17 #include "ui/gl/gl_surface.h" | 17 #include "ui/gl/gl_surface.h" |
| 18 #include "ui/views/test/views_test_base.h" | 18 #include "ui/views/test/views_test_base.h" |
| 19 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
| 20 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 20 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 21 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" | 21 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" |
| 22 #include "ui/views/widget/root_view.h" | 22 #include "ui/views/widget/root_view.h" |
| 23 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 24 | 24 |
| 25 // NOTE: these tests do native capture, so they have to be in | 25 // NOTE: these tests do native capture, so they have to be in |
| 26 // interactive_ui_tests. | 26 // interactive_ui_tests. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 widget->Show(); | 80 widget->Show(); |
| 81 return widget; | 81 return widget; |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Verifies mouse handlers are reset when a window gains capture. Specifically | 84 // Verifies mouse handlers are reset when a window gains capture. Specifically |
| 85 // creates two widgets, does a mouse press in one, sets capture in the other and | 85 // creates two widgets, does a mouse press in one, sets capture in the other and |
| 86 // verifies state is reset in the first. | 86 // verifies state is reset in the first. |
| 87 TEST_F(DesktopCaptureControllerTest, ResetMouseHandlers) { | 87 TEST_F(DesktopCaptureControllerTest, ResetMouseHandlers) { |
| 88 scoped_ptr<Widget> w1(CreateWidget()); | 88 scoped_ptr<Widget> w1(CreateWidget()); |
| 89 scoped_ptr<Widget> w2(CreateWidget()); | 89 scoped_ptr<Widget> w2(CreateWidget()); |
| 90 aura::test::EventGenerator generator1(w1->GetNativeView()->GetRootWindow()); | 90 ui::test::EventGenerator generator1(w1->GetNativeView()->GetRootWindow()); |
| 91 generator1.MoveMouseToCenterOf(w1->GetNativeView()); | 91 generator1.MoveMouseToCenterOf(w1->GetNativeView()); |
| 92 generator1.PressLeftButton(); | 92 generator1.PressLeftButton(); |
| 93 EXPECT_FALSE(w1->HasCapture()); | 93 EXPECT_FALSE(w1->HasCapture()); |
| 94 aura::WindowEventDispatcher* w1_dispatcher = | 94 aura::WindowEventDispatcher* w1_dispatcher = |
| 95 w1->GetNativeView()->GetHost()->dispatcher(); | 95 w1->GetNativeView()->GetHost()->dispatcher(); |
| 96 EXPECT_TRUE(w1_dispatcher->mouse_pressed_handler() != NULL); | 96 EXPECT_TRUE(w1_dispatcher->mouse_pressed_handler() != NULL); |
| 97 EXPECT_TRUE(w1_dispatcher->mouse_moved_handler() != NULL); | 97 EXPECT_TRUE(w1_dispatcher->mouse_moved_handler() != NULL); |
| 98 w2->SetCapture(w2->GetRootView()); | 98 w2->SetCapture(w2->GetRootView()); |
| 99 EXPECT_TRUE(w2->HasCapture()); | 99 EXPECT_TRUE(w2->HasCapture()); |
| 100 EXPECT_TRUE(w1_dispatcher->mouse_pressed_handler() == NULL); | 100 EXPECT_TRUE(w1_dispatcher->mouse_pressed_handler() == NULL); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 EXPECT_TRUE(v2->received_gesture_event()); | 195 EXPECT_TRUE(v2->received_gesture_event()); |
| 196 EXPECT_FALSE(v1->received_gesture_event()); | 196 EXPECT_FALSE(v1->received_gesture_event()); |
| 197 | 197 |
| 198 widget1->CloseNow(); | 198 widget1->CloseNow(); |
| 199 widget2->CloseNow(); | 199 widget2->CloseNow(); |
| 200 RunPendingMessages(); | 200 RunPendingMessages(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace views | 203 } // namespace views |
| OLD | NEW |