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_ = rtc::Thread::Create(); | 98 signaling_thread_.reset(new rtc::Thread()); |
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_ = rtc::Thread::Create(); | 185 signaling_thread_.reset(new rtc::Thread()); |
186 worker_thread_ = rtc::Thread::Create(); | 186 worker_thread_.reset(new rtc::Thread()); |
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 : signaling_thread_(rtc::Thread::Create()), | 286 : foo_(new Foo()), |
287 worker_thread_(rtc::Thread::Create()), | 287 foo_proxy_(FooProxy::Create(&signaling_thread_, |
288 foo_(new Foo()), | 288 &worker_thread_, |
289 foo_proxy_(FooProxy::Create(signaling_thread_.get(), | |
290 worker_thread_.get(), | |
291 std::unique_ptr<FooInterface>(foo_))) { | 289 std::unique_ptr<FooInterface>(foo_))) { |
292 signaling_thread_->Start(); | 290 signaling_thread_.Start(); |
293 worker_thread_->Start(); | 291 worker_thread_.Start(); |
294 } | 292 } |
295 | 293 |
296 void CheckSignalingThread() { EXPECT_TRUE(signaling_thread_->IsCurrent()); } | 294 void CheckSignalingThread() { EXPECT_TRUE(signaling_thread_.IsCurrent()); } |
297 void CheckWorkerThread() { EXPECT_TRUE(worker_thread_->IsCurrent()); } | 295 void CheckWorkerThread() { EXPECT_TRUE(worker_thread_.IsCurrent()); } |
298 | 296 |
299 protected: | 297 protected: |
300 std::unique_ptr<rtc::Thread> signaling_thread_; | 298 rtc::Thread signaling_thread_; |
301 std::unique_ptr<rtc::Thread> worker_thread_; | 299 rtc::Thread worker_thread_; |
302 Foo* foo_; // Owned by foo_proxy_, not this class. | 300 Foo* foo_; // Owned by foo_proxy_, not this class. |
303 std::unique_ptr<FooInterface> foo_proxy_; | 301 std::unique_ptr<FooInterface> foo_proxy_; |
304 }; | 302 }; |
305 | 303 |
306 // Just tests that a method can be invoked using an "owned proxy" (as opposed | 304 // Just tests that a method can be invoked using an "owned proxy" (as opposed |
307 // to normal ref-counted version). | 305 // to normal ref-counted version). |
308 TEST_F(OwnedProxyTest, BasicTest) { | 306 TEST_F(OwnedProxyTest, BasicTest) { |
309 EXPECT_CALL(*foo_, Bar()) | 307 EXPECT_CALL(*foo_, Bar()) |
310 .Times(Exactly(1)) | 308 .Times(Exactly(1)) |
311 .WillOnce(InvokeWithoutArgs(this, &OwnedProxyTest::CheckSignalingThread)); | 309 .WillOnce(InvokeWithoutArgs(this, &OwnedProxyTest::CheckSignalingThread)); |
312 foo_proxy_->Bar(); | 310 foo_proxy_->Bar(); |
313 } | 311 } |
314 | 312 |
315 } // namespace webrtc | 313 } // namespace webrtc |
OLD | NEW |