| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ash/autoclick/autoclick_controller.h" | 5 #include "ash/autoclick/autoclick_controller.h" |
| 6 #include "ash/shell.h" | 6 #include "ash/shell.h" |
| 7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
| 8 #include "ui/aura/test/event_generator.h" | |
| 9 #include "ui/aura/test/test_window_delegate.h" | 8 #include "ui/aura/test/test_window_delegate.h" |
| 10 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 11 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
| 12 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
| 13 #include "ui/events/event_constants.h" | 12 #include "ui/events/event_constants.h" |
| 14 #include "ui/events/event_handler.h" | 13 #include "ui/events/event_handler.h" |
| 15 #include "ui/events/keycodes/keyboard_codes.h" | 14 #include "ui/events/keycodes/keyboard_codes.h" |
| 15 #include "ui/events/test/event_generator.h" |
| 16 | 16 |
| 17 namespace ash { | 17 namespace ash { |
| 18 | 18 |
| 19 class MouseEventCapturer : public ui::EventHandler { | 19 class MouseEventCapturer : public ui::EventHandler { |
| 20 public: | 20 public: |
| 21 MouseEventCapturer() { Reset(); } | 21 MouseEventCapturer() { Reset(); } |
| 22 virtual ~MouseEventCapturer() {} | 22 virtual ~MouseEventCapturer() {} |
| 23 | 23 |
| 24 void Reset() { | 24 void Reset() { |
| 25 events_.clear(); | 25 events_.clear(); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 TEST_F(AutoclickTest, ExtendedDisplay) { | 220 TEST_F(AutoclickTest, ExtendedDisplay) { |
| 221 UpdateDisplay("1280x1024,800x600"); | 221 UpdateDisplay("1280x1024,800x600"); |
| 222 RunAllPendingInMessageLoop(); | 222 RunAllPendingInMessageLoop(); |
| 223 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 223 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 224 EXPECT_EQ(2u, root_windows.size()); | 224 EXPECT_EQ(2u, root_windows.size()); |
| 225 | 225 |
| 226 GetAutoclickController()->SetEnabled(true); | 226 GetAutoclickController()->SetEnabled(true); |
| 227 std::vector<ui::MouseEvent> events; | 227 std::vector<ui::MouseEvent> events; |
| 228 | 228 |
| 229 // Test first root window. | 229 // Test first root window. |
| 230 aura::test::EventGenerator generator1(root_windows[0]); | 230 ui::test::EventGenerator generator1(root_windows[0]); |
| 231 generator1.MoveMouseTo(100, 200); | 231 generator1.MoveMouseTo(100, 200); |
| 232 events = WaitForMouseEvents(); | 232 events = WaitForMouseEvents(); |
| 233 EXPECT_EQ(2u, events.size()); | 233 EXPECT_EQ(2u, events.size()); |
| 234 EXPECT_EQ(100, events[0].root_location().x()); | 234 EXPECT_EQ(100, events[0].root_location().x()); |
| 235 EXPECT_EQ(200, events[0].root_location().y()); | 235 EXPECT_EQ(200, events[0].root_location().y()); |
| 236 | 236 |
| 237 // Test second root window. | 237 // Test second root window. |
| 238 aura::test::EventGenerator generator2(root_windows[1]); | 238 ui::test::EventGenerator generator2(root_windows[1]); |
| 239 generator2.MoveMouseTo(300, 400); | 239 generator2.MoveMouseTo(300, 400); |
| 240 events = WaitForMouseEvents(); | 240 events = WaitForMouseEvents(); |
| 241 EXPECT_EQ(2u, events.size()); | 241 EXPECT_EQ(2u, events.size()); |
| 242 EXPECT_EQ(300, events[0].root_location().x()); | 242 EXPECT_EQ(300, events[0].root_location().x()); |
| 243 EXPECT_EQ(400, events[0].root_location().y()); | 243 EXPECT_EQ(400, events[0].root_location().y()); |
| 244 | 244 |
| 245 // Test movement threshold between displays. | 245 // Test movement threshold between displays. |
| 246 } | 246 } |
| 247 | 247 |
| 248 TEST_F(AutoclickTest, UserInputCancelsAutoclick) { | 248 TEST_F(AutoclickTest, UserInputCancelsAutoclick) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 aura::test::EventCountDelegate delegate; | 301 aura::test::EventCountDelegate delegate; |
| 302 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( | 302 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( |
| 303 &delegate, 123, gfx::Rect(50, 50, 100, 100))); | 303 &delegate, 123, gfx::Rect(50, 50, 100, 100))); |
| 304 window->Show(); | 304 window->Show(); |
| 305 events = WaitForMouseEvents(); | 305 events = WaitForMouseEvents(); |
| 306 EXPECT_EQ(0u, events.size()); | 306 EXPECT_EQ(0u, events.size()); |
| 307 EXPECT_EQ("1 1 0", delegate.GetMouseMotionCountsAndReset()); | 307 EXPECT_EQ("1 1 0", delegate.GetMouseMotionCountsAndReset()); |
| 308 } | 308 } |
| 309 | 309 |
| 310 } // namespace ash | 310 } // namespace ash |
| OLD | NEW |