OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/api/proxy.h" | 11 #include "webrtc/api/proxy.h" |
12 | 12 |
| 13 #include <memory> |
13 #include <string> | 14 #include <string> |
14 | 15 |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "webrtc/base/gunit.h" | 17 #include "webrtc/base/gunit.h" |
17 #include "webrtc/base/refcount.h" | 18 #include "webrtc/base/refcount.h" |
18 #include "webrtc/base/scoped_ptr.h" | |
19 #include "webrtc/base/thread.h" | 19 #include "webrtc/base/thread.h" |
20 | 20 |
21 using ::testing::_; | 21 using ::testing::_; |
22 using ::testing::DoAll; | 22 using ::testing::DoAll; |
23 using ::testing::Exactly; | 23 using ::testing::Exactly; |
24 using ::testing::InvokeWithoutArgs; | 24 using ::testing::InvokeWithoutArgs; |
25 using ::testing::Return; | 25 using ::testing::Return; |
26 | 26 |
27 namespace webrtc { | 27 namespace webrtc { |
28 | 28 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 protected: | 91 protected: |
92 void SetUp() override { | 92 void SetUp() override { |
93 signaling_thread_.reset(new rtc::Thread()); | 93 signaling_thread_.reset(new rtc::Thread()); |
94 ASSERT_TRUE(signaling_thread_->Start()); | 94 ASSERT_TRUE(signaling_thread_->Start()); |
95 fake_ = Fake::Create(); | 95 fake_ = Fake::Create(); |
96 fake_signaling_proxy_ = | 96 fake_signaling_proxy_ = |
97 FakeSignalingProxy::Create(signaling_thread_.get(), fake_.get()); | 97 FakeSignalingProxy::Create(signaling_thread_.get(), fake_.get()); |
98 } | 98 } |
99 | 99 |
100 protected: | 100 protected: |
101 rtc::scoped_ptr<rtc::Thread> signaling_thread_; | 101 std::unique_ptr<rtc::Thread> signaling_thread_; |
102 rtc::scoped_refptr<FakeInterface> fake_signaling_proxy_; | 102 rtc::scoped_refptr<FakeInterface> fake_signaling_proxy_; |
103 rtc::scoped_refptr<Fake> fake_; | 103 rtc::scoped_refptr<Fake> fake_; |
104 }; | 104 }; |
105 | 105 |
106 TEST_F(SignalingProxyTest, VoidMethod0) { | 106 TEST_F(SignalingProxyTest, VoidMethod0) { |
107 EXPECT_CALL(*fake_, VoidMethod0()) | 107 EXPECT_CALL(*fake_, VoidMethod0()) |
108 .Times(Exactly(1)) | 108 .Times(Exactly(1)) |
109 .WillOnce( | 109 .WillOnce( |
110 InvokeWithoutArgs(this, &SignalingProxyTest::CheckSignalingThread)); | 110 InvokeWithoutArgs(this, &SignalingProxyTest::CheckSignalingThread)); |
111 fake_signaling_proxy_->VoidMethod0(); | 111 fake_signaling_proxy_->VoidMethod0(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 protected: | 168 protected: |
169 void SetUp() override { | 169 void SetUp() override { |
170 SignalingProxyTest::SetUp(); | 170 SignalingProxyTest::SetUp(); |
171 worker_thread_.reset(new rtc::Thread()); | 171 worker_thread_.reset(new rtc::Thread()); |
172 ASSERT_TRUE(worker_thread_->Start()); | 172 ASSERT_TRUE(worker_thread_->Start()); |
173 fake_proxy_ = FakeProxy::Create(signaling_thread_.get(), | 173 fake_proxy_ = FakeProxy::Create(signaling_thread_.get(), |
174 worker_thread_.get(), fake_.get()); | 174 worker_thread_.get(), fake_.get()); |
175 } | 175 } |
176 | 176 |
177 protected: | 177 protected: |
178 rtc::scoped_ptr<rtc::Thread> worker_thread_; | 178 std::unique_ptr<rtc::Thread> worker_thread_; |
179 rtc::scoped_refptr<FakeInterface> fake_proxy_; | 179 rtc::scoped_refptr<FakeInterface> fake_proxy_; |
180 }; | 180 }; |
181 | 181 |
182 TEST_F(ProxyTest, VoidMethod0) { | 182 TEST_F(ProxyTest, VoidMethod0) { |
183 EXPECT_CALL(*fake_, VoidMethod0()) | 183 EXPECT_CALL(*fake_, VoidMethod0()) |
184 .Times(Exactly(1)) | 184 .Times(Exactly(1)) |
185 .WillOnce(InvokeWithoutArgs(this, &ProxyTest::CheckSignalingThread)); | 185 .WillOnce(InvokeWithoutArgs(this, &ProxyTest::CheckSignalingThread)); |
186 fake_proxy_->VoidMethod0(); | 186 fake_proxy_->VoidMethod0(); |
187 } | 187 } |
188 | 188 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 const std::string arg1 = "arg1"; | 229 const std::string arg1 = "arg1"; |
230 const std::string arg2 = "arg2"; | 230 const std::string arg2 = "arg2"; |
231 EXPECT_CALL(*fake_, Method2(arg1, arg2)) | 231 EXPECT_CALL(*fake_, Method2(arg1, arg2)) |
232 .Times(Exactly(1)) | 232 .Times(Exactly(1)) |
233 .WillOnce(DoAll(InvokeWithoutArgs(this, &ProxyTest::CheckWorkerThread), | 233 .WillOnce(DoAll(InvokeWithoutArgs(this, &ProxyTest::CheckWorkerThread), |
234 Return("Method2"))); | 234 Return("Method2"))); |
235 EXPECT_EQ("Method2", fake_proxy_->Method2(arg1, arg2)); | 235 EXPECT_EQ("Method2", fake_proxy_->Method2(arg1, arg2)); |
236 } | 236 } |
237 | 237 |
238 } // namespace webrtc | 238 } // namespace webrtc |
OLD | NEW |