| 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 23 matching lines...) Expand all Loading... |
| 34 virtual std::string ConstMethod0() const = 0; | 34 virtual std::string ConstMethod0() const = 0; |
| 35 virtual std::string Method1(std::string s) = 0; | 35 virtual std::string Method1(std::string s) = 0; |
| 36 virtual std::string ConstMethod1(std::string s) const = 0; | 36 virtual std::string ConstMethod1(std::string s) const = 0; |
| 37 virtual std::string Method2(std::string s1, std::string s2) = 0; | 37 virtual std::string Method2(std::string s1, std::string s2) = 0; |
| 38 | 38 |
| 39 protected: | 39 protected: |
| 40 ~FakeInterface() {} | 40 ~FakeInterface() {} |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 // Proxy for the test interface. | 43 // Proxy for the test interface. |
| 44 BEGIN_PROXY_MAP(Fake) | 44 BEGIN_SIGNALLING_PROXY_MAP(Fake) |
| 45 PROXY_METHOD0(void, VoidMethod0) | 45 PROXY_METHOD0(void, VoidMethod0) |
| 46 PROXY_METHOD0(std::string, Method0) | 46 PROXY_METHOD0(std::string, Method0) |
| 47 PROXY_CONSTMETHOD0(std::string, ConstMethod0) | 47 PROXY_CONSTMETHOD0(std::string, ConstMethod0) |
| 48 PROXY_METHOD1(std::string, Method1, std::string) | 48 PROXY_METHOD1(std::string, Method1, std::string) |
| 49 PROXY_CONSTMETHOD1(std::string, ConstMethod1, std::string) | 49 PROXY_CONSTMETHOD1(std::string, ConstMethod1, std::string) |
| 50 PROXY_METHOD2(std::string, Method2, std::string, std::string) | 50 PROXY_METHOD2(std::string, Method2, std::string, std::string) |
| 51 END_PROXY() | 51 END_SIGNALLING_PROXY() |
| 52 | 52 |
| 53 // Implementation of the test interface. | 53 // Implementation of the test interface. |
| 54 class Fake : public FakeInterface { | 54 class Fake : public FakeInterface { |
| 55 public: | 55 public: |
| 56 static rtc::scoped_refptr<Fake> Create() { | 56 static rtc::scoped_refptr<Fake> Create() { |
| 57 return new rtc::RefCountedObject<Fake>(); | 57 return new rtc::RefCountedObject<Fake>(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 MOCK_METHOD0(VoidMethod0, void()); | 60 MOCK_METHOD0(VoidMethod0, void()); |
| 61 MOCK_METHOD0(Method0, std::string()); | 61 MOCK_METHOD0(Method0, std::string()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 76 // Checks that the functions is called on the |signaling_thread_|. | 76 // Checks that the functions is called on the |signaling_thread_|. |
| 77 void CheckThread() { | 77 void CheckThread() { |
| 78 EXPECT_EQ(rtc::Thread::Current(), signaling_thread_.get()); | 78 EXPECT_EQ(rtc::Thread::Current(), signaling_thread_.get()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 protected: | 81 protected: |
| 82 virtual void SetUp() { | 82 virtual void SetUp() { |
| 83 signaling_thread_.reset(new rtc::Thread()); | 83 signaling_thread_.reset(new rtc::Thread()); |
| 84 ASSERT_TRUE(signaling_thread_->Start()); | 84 ASSERT_TRUE(signaling_thread_->Start()); |
| 85 fake_ = Fake::Create(); | 85 fake_ = Fake::Create(); |
| 86 fake_proxy_ = FakeProxy::Create(signaling_thread_.get(), fake_.get()); | 86 fake_proxy_ = |
| 87 FakeSignallingProxy::Create(signaling_thread_.get(), fake_.get()); |
| 87 } | 88 } |
| 88 | 89 |
| 89 protected: | 90 protected: |
| 90 rtc::scoped_ptr<rtc::Thread> signaling_thread_; | 91 rtc::scoped_ptr<rtc::Thread> signaling_thread_; |
| 91 rtc::scoped_refptr<FakeInterface> fake_proxy_; | 92 rtc::scoped_refptr<FakeInterface> fake_proxy_; |
| 92 rtc::scoped_refptr<Fake> fake_; | 93 rtc::scoped_refptr<Fake> fake_; |
| 93 }; | 94 }; |
| 94 | 95 |
| 95 TEST_F(ProxyTest, VoidMethod0) { | 96 TEST_F(ProxyTest, VoidMethod0) { |
| 96 EXPECT_CALL(*fake_, VoidMethod0()) | 97 EXPECT_CALL(*fake_, VoidMethod0()) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 const std::string arg2 = "arg2"; | 145 const std::string arg2 = "arg2"; |
| 145 EXPECT_CALL(*fake_, Method2(arg1, arg2)) | 146 EXPECT_CALL(*fake_, Method2(arg1, arg2)) |
| 146 .Times(Exactly(1)) | 147 .Times(Exactly(1)) |
| 147 .WillOnce( | 148 .WillOnce( |
| 148 DoAll(InvokeWithoutArgs(this, &ProxyTest::CheckThread), | 149 DoAll(InvokeWithoutArgs(this, &ProxyTest::CheckThread), |
| 149 Return("Method2"))); | 150 Return("Method2"))); |
| 150 EXPECT_EQ("Method2", fake_proxy_->Method2(arg1, arg2)); | 151 EXPECT_EQ("Method2", fake_proxy_->Method2(arg1, arg2)); |
| 151 } | 152 } |
| 152 | 153 |
| 153 } // namespace webrtc | 154 } // namespace webrtc |
| OLD | NEW |