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 "ui/aura/window_event_dispatcher.h" | 5 #include "ui/aura/window_event_dispatcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/stl_util.h" |
17 #include "base/test/histogram_tester.h" | 18 #include "base/test/histogram_tester.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/aura/client/capture_client.h" | 22 #include "ui/aura/client/capture_client.h" |
22 #include "ui/aura/client/event_client.h" | 23 #include "ui/aura/client/event_client.h" |
23 #include "ui/aura/client/focus_client.h" | 24 #include "ui/aura/client/focus_client.h" |
24 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
25 #include "ui/aura/mus/window_tree_client.h" | 26 #include "ui/aura/mus/window_tree_client.h" |
26 #include "ui/aura/test/aura_test_base.h" | 27 #include "ui/aura/test/aura_test_base.h" |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 void OnTouchEvent(ui::TouchEvent* event) override { | 542 void OnTouchEvent(ui::TouchEvent* event) override { |
542 touch_locations_.push_back(event->location()); | 543 touch_locations_.push_back(event->location()); |
543 last_touch_may_cause_scrolling_ = event->may_cause_scrolling(); | 544 last_touch_may_cause_scrolling_ = event->may_cause_scrolling(); |
544 } | 545 } |
545 | 546 |
546 void OnGestureEvent(ui::GestureEvent* event) override { | 547 void OnGestureEvent(ui::GestureEvent* event) override { |
547 gesture_locations_.push_back(event->location()); | 548 gesture_locations_.push_back(event->location()); |
548 } | 549 } |
549 | 550 |
550 bool HasReceivedEvent(ui::EventType type) { | 551 bool HasReceivedEvent(ui::EventType type) { |
551 return std::find(events_.begin(), events_.end(), type) != events_.end(); | 552 return base::ContainsValue(events_, type); |
552 } | 553 } |
553 | 554 |
554 bool LastTouchMayCauseScrolling() const { | 555 bool LastTouchMayCauseScrolling() const { |
555 return last_touch_may_cause_scrolling_; | 556 return last_touch_may_cause_scrolling_; |
556 } | 557 } |
557 | 558 |
558 private: | 559 private: |
559 std::unique_ptr<base::RunLoop> run_loop_; | 560 std::unique_ptr<base::RunLoop> run_loop_; |
560 ui::EventType wait_until_event_; | 561 ui::EventType wait_until_event_; |
561 | 562 |
(...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2948 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); | 2949 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); |
2949 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count()); | 2950 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count()); |
2950 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); | 2951 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); |
2951 | 2952 |
2952 // After dispatch the location should fallback to that of the | 2953 // After dispatch the location should fallback to that of the |
2953 // WindowTreeClient, which defaults to 0,0. | 2954 // WindowTreeClient, which defaults to 0,0. |
2954 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); | 2955 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); |
2955 } | 2956 } |
2956 | 2957 |
2957 } // namespace aura | 2958 } // namespace aura |
OLD | NEW |