Chromium Code Reviews| 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 "media/base/user_input_monitor.h" | 5 #include "media/base/user_input_monitor.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "media/base/keyboard_event_counter.h" | 13 #include "media/base/keyboard_event_counter.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "third_party/skia/include/core/SkPoint.h" | 16 #include "third_party/skia/include/core/SkPoint.h" |
| 17 | 17 |
| 18 #if defined(OS_POSIX) | |
|
liberato (no reviews please)
2016/10/04 17:29:20
line 55 checks OS_LINUX. probably this should be
fdoray
2016/10/05 13:40:14
Done.
| |
| 19 #include "base/files/file_descriptor_watcher_posix.h" | |
| 20 #endif | |
| 21 | |
| 18 namespace media { | 22 namespace media { |
| 19 | 23 |
| 20 class MockMouseListener : public UserInputMonitor::MouseEventListener { | 24 class MockMouseListener : public UserInputMonitor::MouseEventListener { |
| 21 public: | 25 public: |
| 22 MOCK_METHOD1(OnMouseMoved, void(const SkIPoint& position)); | 26 MOCK_METHOD1(OnMouseMoved, void(const SkIPoint& position)); |
| 23 | 27 |
| 24 virtual ~MockMouseListener() {} | 28 virtual ~MockMouseListener() {} |
| 25 }; | 29 }; |
| 26 | 30 |
| 27 #if defined(OS_LINUX) || defined(OS_WIN) | 31 #if defined(OS_LINUX) || defined(OS_WIN) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 43 | 47 |
| 44 counter.OnKeyboardEvent(ui::ET_KEY_PRESSED, ui::VKEY_0); | 48 counter.OnKeyboardEvent(ui::ET_KEY_PRESSED, ui::VKEY_0); |
| 45 counter.OnKeyboardEvent(ui::ET_KEY_RELEASED, ui::VKEY_0); | 49 counter.OnKeyboardEvent(ui::ET_KEY_RELEASED, ui::VKEY_0); |
| 46 EXPECT_EQ(2u, counter.GetKeyPressCount()); | 50 EXPECT_EQ(2u, counter.GetKeyPressCount()); |
| 47 } | 51 } |
| 48 #endif // defined(OS_LINUX) || defined(OS_WIN) | 52 #endif // defined(OS_LINUX) || defined(OS_WIN) |
| 49 | 53 |
| 50 TEST(UserInputMonitorTest, CreatePlatformSpecific) { | 54 TEST(UserInputMonitorTest, CreatePlatformSpecific) { |
| 51 #if defined(OS_LINUX) | 55 #if defined(OS_LINUX) |
| 52 base::MessageLoopForIO message_loop; | 56 base::MessageLoopForIO message_loop; |
| 57 base::FileDescriptorWatcher file_descriptor_watcher(&message_loop); | |
| 53 #else | 58 #else |
| 54 base::MessageLoopForUI message_loop; | 59 base::MessageLoopForUI message_loop; |
| 55 #endif // defined(OS_LINUX) | 60 #endif // defined(OS_LINUX) |
| 56 | 61 |
| 57 base::RunLoop run_loop; | 62 base::RunLoop run_loop; |
| 58 std::unique_ptr<UserInputMonitor> monitor = UserInputMonitor::Create( | 63 std::unique_ptr<UserInputMonitor> monitor = UserInputMonitor::Create( |
| 59 message_loop.task_runner(), message_loop.task_runner()); | 64 message_loop.task_runner(), message_loop.task_runner()); |
| 60 | 65 |
| 61 if (!monitor) | 66 if (!monitor) |
| 62 return; | 67 return; |
| 63 | 68 |
| 64 MockMouseListener listener; | 69 MockMouseListener listener; |
| 65 // Ignore any callbacks. | 70 // Ignore any callbacks. |
| 66 EXPECT_CALL(listener, OnMouseMoved(testing::_)).Times(testing::AnyNumber()); | 71 EXPECT_CALL(listener, OnMouseMoved(testing::_)).Times(testing::AnyNumber()); |
| 67 | 72 |
| 68 #if !defined(OS_MACOSX) | 73 #if !defined(OS_MACOSX) |
| 69 monitor->AddMouseListener(&listener); | 74 monitor->AddMouseListener(&listener); |
| 70 monitor->RemoveMouseListener(&listener); | 75 monitor->RemoveMouseListener(&listener); |
| 71 #endif // !define(OS_MACOSX) | 76 #endif // !define(OS_MACOSX) |
| 72 | 77 |
| 73 monitor->EnableKeyPressMonitoring(); | 78 monitor->EnableKeyPressMonitoring(); |
| 74 monitor->DisableKeyPressMonitoring(); | 79 monitor->DisableKeyPressMonitoring(); |
| 75 | 80 |
| 76 monitor.reset(); | 81 monitor.reset(); |
| 77 run_loop.RunUntilIdle(); | 82 run_loop.RunUntilIdle(); |
| 78 } | 83 } |
| 79 | 84 |
| 80 } // namespace media | 85 } // namespace media |
| OLD | NEW |