| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "services/window_manager/focus_controller.h" | 5 #include "services/window_manager/focus_controller.h" |
| 6 | 6 |
| 7 #include "ui/events/event_utils.h" |
| 7 #include "mojo/converters/geometry/geometry_type_converters.h" | 8 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 8 #include "services/window_manager/basic_focus_rules.h" | 9 #include "services/window_manager/basic_focus_rules.h" |
| 9 #include "services/window_manager/capture_controller.h" | 10 #include "services/window_manager/capture_controller.h" |
| 10 #include "services/window_manager/focus_controller_observer.h" | 11 #include "services/window_manager/focus_controller_observer.h" |
| 11 #include "services/window_manager/view_event_dispatcher.h" | 12 #include "services/window_manager/view_event_dispatcher.h" |
| 12 #include "services/window_manager/view_targeter.h" | 13 #include "services/window_manager/view_targeter.h" |
| 13 #include "services/window_manager/window_manager_test_util.h" | 14 #include "services/window_manager/window_manager_test_util.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 16 | 17 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 View* GetViewById(int id) { return root_view_->GetChildById(id); } | 407 View* GetViewById(int id) { return root_view_->GetChildById(id); } |
| 407 | 408 |
| 408 void ClickLeftButton(View* view) { | 409 void ClickLeftButton(View* view) { |
| 409 // Get the center bounds of |target| in |root_view_| coordinate space. | 410 // Get the center bounds of |target| in |root_view_| coordinate space. |
| 410 gfx::Point center = | 411 gfx::Point center = |
| 411 gfx::Rect(view->bounds().To<gfx::Rect>().size()).CenterPoint(); | 412 gfx::Rect(view->bounds().To<gfx::Rect>().size()).CenterPoint(); |
| 412 ViewTarget::ConvertPointToTarget(ViewTarget::TargetFromView(view), | 413 ViewTarget::ConvertPointToTarget(ViewTarget::TargetFromView(view), |
| 413 root_view_->target(), ¢er); | 414 root_view_->target(), ¢er); |
| 414 | 415 |
| 415 ui::MouseEvent button_down(ui::ET_MOUSE_PRESSED, center, center, | 416 ui::MouseEvent button_down(ui::ET_MOUSE_PRESSED, center, center, |
| 417 ui::EventTimeForNow(), |
| 416 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_NONE); | 418 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_NONE); |
| 417 ui::EventDispatchDetails details = | 419 ui::EventDispatchDetails details = |
| 418 view_event_dispatcher_->OnEventFromSource(&button_down); | 420 view_event_dispatcher_->OnEventFromSource(&button_down); |
| 419 CHECK(!details.dispatcher_destroyed); | 421 CHECK(!details.dispatcher_destroyed); |
| 420 | 422 |
| 421 ui::MouseEvent button_up(ui::ET_MOUSE_RELEASED, center, center, | 423 ui::MouseEvent button_up(ui::ET_MOUSE_RELEASED, center, center, |
| 424 ui::EventTimeForNow(), |
| 422 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_NONE); | 425 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_NONE); |
| 423 details = view_event_dispatcher_->OnEventFromSource(&button_up); | 426 details = view_event_dispatcher_->OnEventFromSource(&button_up); |
| 424 CHECK(!details.dispatcher_destroyed); | 427 CHECK(!details.dispatcher_destroyed); |
| 425 } | 428 } |
| 426 | 429 |
| 427 ViewTarget* GetRootViewTarget() { | 430 ViewTarget* GetRootViewTarget() { |
| 428 return ViewTarget::TargetFromView(root_view()); | 431 return ViewTarget::TargetFromView(root_view()); |
| 429 } | 432 } |
| 430 | 433 |
| 431 View* root_view() { return root_view_; } | 434 View* root_view() { return root_view_; } |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 | 1188 |
| 1186 // See description above DontPassDestroyedView() for details. | 1189 // See description above DontPassDestroyedView() for details. |
| 1187 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDestroyedView); | 1190 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDestroyedView); |
| 1188 | 1191 |
| 1189 // TODO(erg): Add the TextInputClient tests here. | 1192 // TODO(erg): Add the TextInputClient tests here. |
| 1190 | 1193 |
| 1191 // If a mouse event was handled, it should not activate a view. | 1194 // If a mouse event was handled, it should not activate a view. |
| 1192 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, IgnoreHandledEvent); | 1195 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, IgnoreHandledEvent); |
| 1193 | 1196 |
| 1194 } // namespace window_manager | 1197 } // namespace window_manager |
| OLD | NEW |