OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/aura/desktop.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/aura/event.h" |
| 9 #include "ui/aura/test/aura_test_base.h" |
| 10 #include "ui/aura/test/event_generator.h" |
| 11 |
| 12 namespace aura { |
| 13 namespace test { |
| 14 |
| 15 typedef AuraTestBase DesktopTest; |
| 16 |
| 17 // Check that we correctly track the state of the mouse buttons in response to |
| 18 // button press and release events. |
| 19 TEST_F(DesktopTest, MouseButtonState) { |
| 20 Desktop* desktop = Desktop::GetInstance(); |
| 21 EXPECT_FALSE(desktop->IsMouseButtonDown()); |
| 22 |
| 23 gfx::Point location; |
| 24 scoped_ptr<MouseEvent> event; |
| 25 |
| 26 // Press the left button. |
| 27 event.reset(new MouseEvent( |
| 28 ui::ET_MOUSE_PRESSED, |
| 29 location, |
| 30 ui::EF_LEFT_BUTTON_DOWN)); |
| 31 desktop->DispatchMouseEvent(event.get()); |
| 32 EXPECT_TRUE(desktop->IsMouseButtonDown()); |
| 33 |
| 34 // Additionally press the right. |
| 35 event.reset(new MouseEvent( |
| 36 ui::ET_MOUSE_PRESSED, |
| 37 location, |
| 38 ui::EF_LEFT_BUTTON_DOWN | ui::EF_RIGHT_BUTTON_DOWN)); |
| 39 desktop->DispatchMouseEvent(event.get()); |
| 40 EXPECT_TRUE(desktop->IsMouseButtonDown()); |
| 41 |
| 42 // Release the left button. |
| 43 event.reset(new MouseEvent( |
| 44 ui::ET_MOUSE_RELEASED, |
| 45 location, |
| 46 ui::EF_RIGHT_BUTTON_DOWN)); |
| 47 desktop->DispatchMouseEvent(event.get()); |
| 48 EXPECT_TRUE(desktop->IsMouseButtonDown()); |
| 49 |
| 50 // Release the right button. We should ignore the Shift-is-down flag. |
| 51 event.reset(new MouseEvent( |
| 52 ui::ET_MOUSE_RELEASED, |
| 53 location, |
| 54 ui::EF_SHIFT_DOWN)); |
| 55 desktop->DispatchMouseEvent(event.get()); |
| 56 EXPECT_FALSE(desktop->IsMouseButtonDown()); |
| 57 |
| 58 // Press the middle button. |
| 59 event.reset(new MouseEvent( |
| 60 ui::ET_MOUSE_PRESSED, |
| 61 location, |
| 62 ui::EF_MIDDLE_BUTTON_DOWN)); |
| 63 desktop->DispatchMouseEvent(event.get()); |
| 64 EXPECT_TRUE(desktop->IsMouseButtonDown()); |
| 65 } |
| 66 |
| 67 } // namespace test |
| 68 } // namespace aura |
OLD | NEW |