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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "media/base/keyboard_event_counter.h" | 10 #include "media/base/keyboard_event_counter.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 EXPECT_EQ(1u, counter.GetKeyPressCount()); | 40 EXPECT_EQ(1u, counter.GetKeyPressCount()); |
41 | 41 |
42 counter.OnKeyboardEvent(ui::ET_KEY_PRESSED, ui::VKEY_0); | 42 counter.OnKeyboardEvent(ui::ET_KEY_PRESSED, ui::VKEY_0); |
43 counter.OnKeyboardEvent(ui::ET_KEY_RELEASED, ui::VKEY_0); | 43 counter.OnKeyboardEvent(ui::ET_KEY_RELEASED, ui::VKEY_0); |
44 EXPECT_EQ(2u, counter.GetKeyPressCount()); | 44 EXPECT_EQ(2u, counter.GetKeyPressCount()); |
45 } | 45 } |
46 #endif // defined(OS_LINUX) || defined(OS_WIN) | 46 #endif // defined(OS_LINUX) || defined(OS_WIN) |
47 | 47 |
48 TEST(UserInputMonitorTest, CreatePlatformSpecific) { | 48 TEST(UserInputMonitorTest, CreatePlatformSpecific) { |
49 #if defined(OS_LINUX) | 49 #if defined(OS_LINUX) |
50 base::MessageLoop message_loop(base::MessageLoop::TYPE_IO); | 50 base::MessageLoopForIO message_loop; |
51 #else | 51 #else |
52 base::MessageLoopForUI message_loop; | 52 base::MessageLoopForUI message_loop; |
53 #endif // defined(OS_LINUX) | 53 #endif // defined(OS_LINUX) |
54 | 54 |
55 base::RunLoop run_loop; | 55 base::RunLoop run_loop; |
56 scoped_ptr<UserInputMonitor> monitor = UserInputMonitor::Create( | 56 scoped_ptr<UserInputMonitor> monitor = UserInputMonitor::Create( |
57 message_loop.message_loop_proxy(), message_loop.message_loop_proxy()); | 57 message_loop.message_loop_proxy(), message_loop.message_loop_proxy()); |
58 | 58 |
59 if (!monitor) | 59 if (!monitor) |
60 return; | 60 return; |
61 | 61 |
62 MockMouseListener listener; | 62 MockMouseListener listener; |
63 // Ignore any callbacks. | 63 // Ignore any callbacks. |
64 EXPECT_CALL(listener, OnMouseMoved(testing::_)).Times(testing::AnyNumber()); | 64 EXPECT_CALL(listener, OnMouseMoved(testing::_)).Times(testing::AnyNumber()); |
65 | 65 |
66 #if !defined(OS_MACOSX) | 66 #if !defined(OS_MACOSX) |
67 monitor->AddMouseListener(&listener); | 67 monitor->AddMouseListener(&listener); |
68 monitor->RemoveMouseListener(&listener); | 68 monitor->RemoveMouseListener(&listener); |
69 #endif // !define(OS_MACOSX) | 69 #endif // !define(OS_MACOSX) |
70 | 70 |
71 monitor->EnableKeyPressMonitoring(); | 71 monitor->EnableKeyPressMonitoring(); |
72 monitor->DisableKeyPressMonitoring(); | 72 monitor->DisableKeyPressMonitoring(); |
73 | 73 |
74 monitor.reset(); | 74 monitor.reset(); |
75 run_loop.RunUntilIdle(); | 75 run_loop.RunUntilIdle(); |
76 } | 76 } |
77 | 77 |
78 } // namespace media | 78 } // namespace media |
OLD | NEW |