OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_cursor_monitor_proxy.h" | 5 #include "remoting/host/mouse_cursor_monitor_proxy.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 EXPECT_FALSE(callback_); | 49 EXPECT_FALSE(callback_); |
50 EXPECT_TRUE(callback); | 50 EXPECT_TRUE(callback); |
51 | 51 |
52 callback_ = callback; | 52 callback_ = callback; |
53 } | 53 } |
54 | 54 |
55 void Capture() override { | 55 void Capture() override { |
56 EXPECT_TRUE(task_runner_->BelongsToCurrentThread()); | 56 EXPECT_TRUE(task_runner_->BelongsToCurrentThread()); |
57 ASSERT_TRUE(callback_); | 57 ASSERT_TRUE(callback_); |
58 | 58 |
59 scoped_ptr<webrtc::MouseCursor> mouse_cursor(new webrtc::MouseCursor( | 59 std::unique_ptr<webrtc::MouseCursor> mouse_cursor(new webrtc::MouseCursor( |
60 new webrtc::BasicDesktopFrame( | 60 new webrtc::BasicDesktopFrame( |
61 webrtc::DesktopSize(kCursorWidth, kCursorHeight)), | 61 webrtc::DesktopSize(kCursorWidth, kCursorHeight)), |
62 webrtc::DesktopVector(kHotspotX, kHotspotY))); | 62 webrtc::DesktopVector(kHotspotX, kHotspotY))); |
63 | 63 |
64 callback_->OnMouseCursor(mouse_cursor.release()); | 64 callback_->OnMouseCursor(mouse_cursor.release()); |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 68 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
69 | 69 |
(...skipping 17 matching lines...) Expand all Loading... |
87 | 87 |
88 // webrtc::MouseCursorMonitor::Callback implementation. | 88 // webrtc::MouseCursorMonitor::Callback implementation. |
89 void OnMouseCursor(webrtc::MouseCursor* mouse_cursor) override; | 89 void OnMouseCursor(webrtc::MouseCursor* mouse_cursor) override; |
90 void OnMouseCursorPosition(webrtc::MouseCursorMonitor::CursorState state, | 90 void OnMouseCursorPosition(webrtc::MouseCursorMonitor::CursorState state, |
91 const webrtc::DesktopVector& position) override; | 91 const webrtc::DesktopVector& position) override; |
92 | 92 |
93 protected: | 93 protected: |
94 base::MessageLoop message_loop_; | 94 base::MessageLoop message_loop_; |
95 base::RunLoop run_loop_; | 95 base::RunLoop run_loop_; |
96 base::Thread capture_thread_; | 96 base::Thread capture_thread_; |
97 scoped_ptr<MouseCursorMonitorProxy> proxy_; | 97 std::unique_ptr<MouseCursorMonitorProxy> proxy_; |
98 | 98 |
99 MockClientStub client_stub_; | 99 MockClientStub client_stub_; |
100 }; | 100 }; |
101 | 101 |
102 void MouseCursorMonitorProxyTest::OnMouseCursor( | 102 void MouseCursorMonitorProxyTest::OnMouseCursor( |
103 webrtc::MouseCursor* mouse_cursor) { | 103 webrtc::MouseCursor* mouse_cursor) { |
104 DCHECK(message_loop_.task_runner()->BelongsToCurrentThread()); | 104 DCHECK(message_loop_.task_runner()->BelongsToCurrentThread()); |
105 | 105 |
106 EXPECT_EQ(kCursorWidth, mouse_cursor->image()->size().width()); | 106 EXPECT_EQ(kCursorWidth, mouse_cursor->image()->size().width()); |
107 EXPECT_EQ(kCursorHeight, mouse_cursor->image()->size().height()); | 107 EXPECT_EQ(kCursorHeight, mouse_cursor->image()->size().height()); |
108 EXPECT_EQ(kHotspotX, mouse_cursor->hotspot().x()); | 108 EXPECT_EQ(kHotspotX, mouse_cursor->hotspot().x()); |
109 EXPECT_EQ(kHotspotY, mouse_cursor->hotspot().y()); | 109 EXPECT_EQ(kHotspotY, mouse_cursor->hotspot().y()); |
110 delete mouse_cursor; | 110 delete mouse_cursor; |
111 | 111 |
112 run_loop_.Quit(); | 112 run_loop_.Quit(); |
113 } | 113 } |
114 | 114 |
115 void MouseCursorMonitorProxyTest::OnMouseCursorPosition( | 115 void MouseCursorMonitorProxyTest::OnMouseCursorPosition( |
116 webrtc::MouseCursorMonitor::CursorState state, | 116 webrtc::MouseCursorMonitor::CursorState state, |
117 const webrtc::DesktopVector& position) { | 117 const webrtc::DesktopVector& position) { |
118 NOTREACHED(); | 118 NOTREACHED(); |
119 } | 119 } |
120 | 120 |
121 TEST_F(MouseCursorMonitorProxyTest, CursorShape) { | 121 TEST_F(MouseCursorMonitorProxyTest, CursorShape) { |
122 scoped_ptr<ThreadCheckMouseCursorMonitor> cursor_monitor( | 122 std::unique_ptr<ThreadCheckMouseCursorMonitor> cursor_monitor( |
123 new ThreadCheckMouseCursorMonitor(capture_thread_.task_runner())); | 123 new ThreadCheckMouseCursorMonitor(capture_thread_.task_runner())); |
124 | 124 |
125 // Initialize the proxy. | 125 // Initialize the proxy. |
126 proxy_.reset(new MouseCursorMonitorProxy(capture_thread_.task_runner(), | 126 proxy_.reset(new MouseCursorMonitorProxy(capture_thread_.task_runner(), |
127 std::move(cursor_monitor))); | 127 std::move(cursor_monitor))); |
128 proxy_->Init(this, webrtc::MouseCursorMonitor::SHAPE_ONLY); | 128 proxy_->Init(this, webrtc::MouseCursorMonitor::SHAPE_ONLY); |
129 proxy_->Capture(); | 129 proxy_->Capture(); |
130 | 130 |
131 // |run_loop_| will be stopped when the first cursor is received. | 131 // |run_loop_| will be stopped when the first cursor is received. |
132 run_loop_.Run(); | 132 run_loop_.Run(); |
133 } | 133 } |
134 | 134 |
135 } // namespace remoting | 135 } // namespace remoting |
OLD | NEW |