OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "remoting/jingle_glue/iq_request.h" | 6 #include "remoting/jingle_glue/iq_sender.h" |
7 #include "remoting/jingle_glue/signal_strategy.h" | 7 #include "remoting/jingle_glue/signal_strategy.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 | 9 |
10 namespace remoting { | 10 namespace remoting { |
11 | 11 |
12 class MockSignalStrategy : public SignalStrategy { | 12 class MockSignalStrategy : public SignalStrategy { |
13 public: | 13 public: |
14 MockSignalStrategy(); | 14 MockSignalStrategy(); |
15 virtual ~MockSignalStrategy(); | 15 virtual ~MockSignalStrategy(); |
16 | 16 |
17 MOCK_METHOD1(Init, void(StatusObserver*)); | 17 MOCK_METHOD1(Init, void(StatusObserver*)); |
18 MOCK_METHOD0(Close, void()); | 18 MOCK_METHOD0(Close, void()); |
19 MOCK_METHOD1(SetListener, void(Listener* listener)); | 19 MOCK_METHOD1(AddListener, void(Listener* listener)); |
20 MOCK_METHOD1(SendStanza, void(buzz::XmlElement* stanza)); | 20 MOCK_METHOD1(RemoveListener, void(Listener* listener)); |
| 21 MOCK_METHOD1(SendStanza, bool(buzz::XmlElement* stanza)); |
21 MOCK_METHOD0(GetNextId, std::string()); | 22 MOCK_METHOD0(GetNextId, std::string()); |
22 MOCK_METHOD0(CreateIqRequest, IqRequest*()); | 23 MOCK_METHOD0(CreateIqRequest, IqRequest*()); |
23 }; | 24 }; |
24 | 25 |
25 class MockIqRequest : public IqRequest { | |
26 public: | |
27 MockIqRequest(); | |
28 virtual ~MockIqRequest(); | |
29 | |
30 MOCK_METHOD1(SendIq, void(buzz::XmlElement* stanza)); | |
31 MOCK_METHOD1(set_callback, void(const IqRequest::ReplyCallback&)); | |
32 | |
33 // Ensure this takes ownership of the pointer, as the real IqRequest object | |
34 // would, to avoid memory-leak. | |
35 void set_callback_hook(const IqRequest::ReplyCallback& callback) { | |
36 callback_ = callback; | |
37 } | |
38 | |
39 void Init() { | |
40 ON_CALL(*this, set_callback(testing::_)) | |
41 .WillByDefault(testing::Invoke( | |
42 this, &MockIqRequest::set_callback_hook)); | |
43 } | |
44 | |
45 ReplyCallback& callback() { return callback_; } | |
46 | |
47 private: | |
48 ReplyCallback callback_; | |
49 }; | |
50 | |
51 } // namespace remoting | 26 } // namespace remoting |
OLD | NEW |