Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: remoting/jingle_glue/mock_objects.h

Issue 8432009: Refactor IqRequest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698