OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/host/mouse_shape_pump.h" | 5 #include "remoting/host/mouse_shape_pump.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
13 #include "remoting/host/host_mock_objects.h" | 14 #include "remoting/host/host_mock_objects.h" |
14 #include "remoting/proto/video.pb.h" | 15 #include "remoting/proto/video.pb.h" |
15 #include "remoting/protocol/protocol_mock_objects.h" | 16 #include "remoting/protocol/protocol_mock_objects.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 19 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
19 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h" | 20 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h" |
(...skipping 19 matching lines...) Expand all Loading... |
39 void Init(Callback* callback, Mode mode) override { | 40 void Init(Callback* callback, Mode mode) override { |
40 EXPECT_FALSE(callback_); | 41 EXPECT_FALSE(callback_); |
41 EXPECT_TRUE(callback); | 42 EXPECT_TRUE(callback); |
42 | 43 |
43 callback_ = callback; | 44 callback_ = callback; |
44 } | 45 } |
45 | 46 |
46 void Capture() override { | 47 void Capture() override { |
47 ASSERT_TRUE(callback_); | 48 ASSERT_TRUE(callback_); |
48 | 49 |
49 scoped_ptr<webrtc::MouseCursor> mouse_cursor(new webrtc::MouseCursor( | 50 std::unique_ptr<webrtc::MouseCursor> mouse_cursor(new webrtc::MouseCursor( |
50 new webrtc::BasicDesktopFrame( | 51 new webrtc::BasicDesktopFrame( |
51 webrtc::DesktopSize(kCursorWidth, kCursorHeight)), | 52 webrtc::DesktopSize(kCursorWidth, kCursorHeight)), |
52 webrtc::DesktopVector(kHotspotX, kHotspotY))); | 53 webrtc::DesktopVector(kHotspotX, kHotspotY))); |
53 | 54 |
54 callback_->OnMouseCursor(mouse_cursor.release()); | 55 callback_->OnMouseCursor(mouse_cursor.release()); |
55 } | 56 } |
56 | 57 |
57 private: | 58 private: |
58 Callback* callback_; | 59 Callback* callback_; |
59 | 60 |
60 DISALLOW_COPY_AND_ASSIGN(TestMouseCursorMonitor); | 61 DISALLOW_COPY_AND_ASSIGN(TestMouseCursorMonitor); |
61 }; | 62 }; |
62 | 63 |
63 class MouseShapePumpTest : public testing::Test { | 64 class MouseShapePumpTest : public testing::Test { |
64 public: | 65 public: |
65 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape); | 66 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape); |
66 | 67 |
67 protected: | 68 protected: |
68 base::MessageLoop message_loop_; | 69 base::MessageLoop message_loop_; |
69 base::RunLoop run_loop_; | 70 base::RunLoop run_loop_; |
70 scoped_ptr<MouseShapePump> pump_; | 71 std::unique_ptr<MouseShapePump> pump_; |
71 | 72 |
72 MockClientStub client_stub_; | 73 MockClientStub client_stub_; |
73 }; | 74 }; |
74 | 75 |
75 void MouseShapePumpTest::SetCursorShape( | 76 void MouseShapePumpTest::SetCursorShape( |
76 const protocol::CursorShapeInfo& cursor_shape) { | 77 const protocol::CursorShapeInfo& cursor_shape) { |
77 EXPECT_TRUE(cursor_shape.has_width()); | 78 EXPECT_TRUE(cursor_shape.has_width()); |
78 EXPECT_EQ(kCursorWidth, cursor_shape.width()); | 79 EXPECT_EQ(kCursorWidth, cursor_shape.width()); |
79 EXPECT_TRUE(cursor_shape.has_height()); | 80 EXPECT_TRUE(cursor_shape.has_height()); |
80 EXPECT_EQ(kCursorHeight, cursor_shape.height()); | 81 EXPECT_EQ(kCursorHeight, cursor_shape.height()); |
(...skipping 10 matching lines...) Expand all Loading... |
91 // MouseShapePump sends the cursor successfully. | 92 // MouseShapePump sends the cursor successfully. |
92 TEST_F(MouseShapePumpTest, FirstCursor) { | 93 TEST_F(MouseShapePumpTest, FirstCursor) { |
93 // Stop the |run_loop_| once it has captured the cursor. | 94 // Stop the |run_loop_| once it has captured the cursor. |
94 EXPECT_CALL(client_stub_, SetCursorShape(_)) | 95 EXPECT_CALL(client_stub_, SetCursorShape(_)) |
95 .WillOnce(DoAll( | 96 .WillOnce(DoAll( |
96 Invoke(this, &MouseShapePumpTest::SetCursorShape), | 97 Invoke(this, &MouseShapePumpTest::SetCursorShape), |
97 InvokeWithoutArgs(&run_loop_, &base::RunLoop::Quit))) | 98 InvokeWithoutArgs(&run_loop_, &base::RunLoop::Quit))) |
98 .RetiresOnSaturation(); | 99 .RetiresOnSaturation(); |
99 | 100 |
100 // Start the pump. | 101 // Start the pump. |
101 pump_.reset(new MouseShapePump(make_scoped_ptr(new TestMouseCursorMonitor()), | 102 pump_.reset(new MouseShapePump(base::WrapUnique(new TestMouseCursorMonitor()), |
102 &client_stub_)); | 103 &client_stub_)); |
103 | 104 |
104 run_loop_.Run(); | 105 run_loop_.Run(); |
105 } | 106 } |
106 | 107 |
107 } // namespace remoting | 108 } // namespace remoting |
OLD | NEW |