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 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 END_PROXY_MAP() | 88 END_PROXY_MAP() |
89 #undef FakeProxy | 89 #undef FakeProxy |
90 | 90 |
91 class SignalingProxyTest : public testing::Test { | 91 class SignalingProxyTest : public testing::Test { |
92 public: | 92 public: |
93 // Checks that the functions are called on the right thread. | 93 // Checks that the functions are called on the right thread. |
94 void CheckSignalingThread() { EXPECT_TRUE(signaling_thread_->IsCurrent()); } | 94 void CheckSignalingThread() { EXPECT_TRUE(signaling_thread_->IsCurrent()); } |
95 | 95 |
96 protected: | 96 protected: |
97 void SetUp() override { | 97 void SetUp() override { |
98 signaling_thread_.reset(new rtc::Thread()); | 98 signaling_thread_ = rtc::Thread::Create(); |
99 ASSERT_TRUE(signaling_thread_->Start()); | 99 ASSERT_TRUE(signaling_thread_->Start()); |
100 fake_ = Fake::Create(); | 100 fake_ = Fake::Create(); |
101 fake_signaling_proxy_ = | 101 fake_signaling_proxy_ = |
102 FakeSignalingProxy::Create(signaling_thread_.get(), fake_.get()); | 102 FakeSignalingProxy::Create(signaling_thread_.get(), fake_.get()); |
103 } | 103 } |
104 | 104 |
105 protected: | 105 protected: |
106 std::unique_ptr<rtc::Thread> signaling_thread_; | 106 std::unique_ptr<rtc::Thread> signaling_thread_; |
107 rtc::scoped_refptr<FakeInterface> fake_signaling_proxy_; | 107 rtc::scoped_refptr<FakeInterface> fake_signaling_proxy_; |
108 rtc::scoped_refptr<Fake> fake_; | 108 rtc::scoped_refptr<Fake> fake_; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 175 } |
176 | 176 |
177 class ProxyTest : public testing::Test { | 177 class ProxyTest : public testing::Test { |
178 public: | 178 public: |
179 // Checks that the functions are called on the right thread. | 179 // Checks that the functions are called on the right thread. |
180 void CheckSignalingThread() { EXPECT_TRUE(signaling_thread_->IsCurrent()); } | 180 void CheckSignalingThread() { EXPECT_TRUE(signaling_thread_->IsCurrent()); } |
181 void CheckWorkerThread() { EXPECT_TRUE(worker_thread_->IsCurrent()); } | 181 void CheckWorkerThread() { EXPECT_TRUE(worker_thread_->IsCurrent()); } |
182 | 182 |
183 protected: | 183 protected: |
184 void SetUp() override { | 184 void SetUp() override { |
185 signaling_thread_.reset(new rtc::Thread()); | 185 signaling_thread_ = rtc::Thread::Create(); |
186 worker_thread_.reset(new rtc::Thread()); | 186 worker_thread_ = rtc::Thread::Create(); |
187 ASSERT_TRUE(signaling_thread_->Start()); | 187 ASSERT_TRUE(signaling_thread_->Start()); |
188 ASSERT_TRUE(worker_thread_->Start()); | 188 ASSERT_TRUE(worker_thread_->Start()); |
189 fake_ = Fake::Create(); | 189 fake_ = Fake::Create(); |
190 fake_proxy_ = FakeProxy::Create(signaling_thread_.get(), | 190 fake_proxy_ = FakeProxy::Create(signaling_thread_.get(), |
191 worker_thread_.get(), fake_.get()); | 191 worker_thread_.get(), fake_.get()); |
192 } | 192 } |
193 | 193 |
194 protected: | 194 protected: |
195 std::unique_ptr<rtc::Thread> signaling_thread_; | 195 std::unique_ptr<rtc::Thread> signaling_thread_; |
196 std::unique_ptr<rtc::Thread> worker_thread_; | 196 std::unique_ptr<rtc::Thread> worker_thread_; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 }; | 276 }; |
277 | 277 |
278 BEGIN_OWNED_PROXY_MAP(Foo) | 278 BEGIN_OWNED_PROXY_MAP(Foo) |
279 PROXY_SIGNALING_THREAD_DESTRUCTOR() | 279 PROXY_SIGNALING_THREAD_DESTRUCTOR() |
280 PROXY_METHOD0(void, Bar) | 280 PROXY_METHOD0(void, Bar) |
281 END_PROXY_MAP() | 281 END_PROXY_MAP() |
282 | 282 |
283 class OwnedProxyTest : public testing::Test { | 283 class OwnedProxyTest : public testing::Test { |
284 public: | 284 public: |
285 OwnedProxyTest() | 285 OwnedProxyTest() |
286 : foo_(new Foo()), | 286 : signaling_thread_(rtc::Thread::Create()), |
287 foo_proxy_(FooProxy::Create(&signaling_thread_, | 287 worker_thread_(rtc::Thread::Create()), |
288 &worker_thread_, | 288 foo_(new Foo()), |
| 289 foo_proxy_(FooProxy::Create(signaling_thread_.get(), |
| 290 worker_thread_.get(), |
289 std::unique_ptr<FooInterface>(foo_))) { | 291 std::unique_ptr<FooInterface>(foo_))) { |
290 signaling_thread_.Start(); | 292 signaling_thread_->Start(); |
291 worker_thread_.Start(); | 293 worker_thread_->Start(); |
292 } | 294 } |
293 | 295 |
294 void CheckSignalingThread() { EXPECT_TRUE(signaling_thread_.IsCurrent()); } | 296 void CheckSignalingThread() { EXPECT_TRUE(signaling_thread_->IsCurrent()); } |
295 void CheckWorkerThread() { EXPECT_TRUE(worker_thread_.IsCurrent()); } | 297 void CheckWorkerThread() { EXPECT_TRUE(worker_thread_->IsCurrent()); } |
296 | 298 |
297 protected: | 299 protected: |
298 rtc::Thread signaling_thread_; | 300 std::unique_ptr<rtc::Thread> signaling_thread_; |
299 rtc::Thread worker_thread_; | 301 std::unique_ptr<rtc::Thread> worker_thread_; |
300 Foo* foo_; // Owned by foo_proxy_, not this class. | 302 Foo* foo_; // Owned by foo_proxy_, not this class. |
301 std::unique_ptr<FooInterface> foo_proxy_; | 303 std::unique_ptr<FooInterface> foo_proxy_; |
302 }; | 304 }; |
303 | 305 |
304 // Just tests that a method can be invoked using an "owned proxy" (as opposed | 306 // Just tests that a method can be invoked using an "owned proxy" (as opposed |
305 // to normal ref-counted version). | 307 // to normal ref-counted version). |
306 TEST_F(OwnedProxyTest, BasicTest) { | 308 TEST_F(OwnedProxyTest, BasicTest) { |
307 EXPECT_CALL(*foo_, Bar()) | 309 EXPECT_CALL(*foo_, Bar()) |
308 .Times(Exactly(1)) | 310 .Times(Exactly(1)) |
309 .WillOnce(InvokeWithoutArgs(this, &OwnedProxyTest::CheckSignalingThread)); | 311 .WillOnce(InvokeWithoutArgs(this, &OwnedProxyTest::CheckSignalingThread)); |
310 foo_proxy_->Bar(); | 312 foo_proxy_->Bar(); |
311 } | 313 } |
312 | 314 |
313 } // namespace webrtc | 315 } // namespace webrtc |
OLD | NEW |