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

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

Issue 7744041: Use new callbacks in the IqRequest interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months 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
« no previous file with comments | « remoting/jingle_glue/jingle_info_request.cc ('k') | remoting/jingle_glue/xmpp_iq_request.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_request.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 {
(...skipping 12 matching lines...) Expand all
23 }; 23 };
24 24
25 class MockIqRequest : public IqRequest { 25 class MockIqRequest : public IqRequest {
26 public: 26 public:
27 MockIqRequest(); 27 MockIqRequest();
28 virtual ~MockIqRequest(); 28 virtual ~MockIqRequest();
29 29
30 MOCK_METHOD3(SendIq, void(const std::string& type, 30 MOCK_METHOD3(SendIq, void(const std::string& type,
31 const std::string& addressee, 31 const std::string& addressee,
32 buzz::XmlElement* iq_body)); 32 buzz::XmlElement* iq_body));
33 MOCK_METHOD1(set_callback, void(IqRequest::ReplyCallback*)); 33 MOCK_METHOD1(set_callback, void(const IqRequest::ReplyCallback&));
34 34
35 // Ensure this takes ownership of the pointer, as the real IqRequest object 35 // Ensure this takes ownership of the pointer, as the real IqRequest object
36 // would, to avoid memory-leak. 36 // would, to avoid memory-leak.
37 void set_callback_hook(IqRequest::ReplyCallback* callback) { 37 void set_callback_hook(const IqRequest::ReplyCallback& callback) {
38 callback_.reset(callback); 38 callback_ = callback;
39 } 39 }
40 40
41 void Init() { 41 void Init() {
42 ON_CALL(*this, set_callback(testing::_)) 42 ON_CALL(*this, set_callback(testing::_))
43 .WillByDefault(testing::Invoke( 43 .WillByDefault(testing::Invoke(
44 this, &MockIqRequest::set_callback_hook)); 44 this, &MockIqRequest::set_callback_hook));
45 } 45 }
46 46
47 IqRequest::ReplyCallback* callback() { return callback_.get(); } 47 ReplyCallback& callback() { return callback_; }
48 48
49 private: 49 private:
50 scoped_ptr<IqRequest::ReplyCallback> callback_; 50 ReplyCallback callback_;
51 }; 51 };
52 52
53 } // namespace remoting 53 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/jingle_glue/jingle_info_request.cc ('k') | remoting/jingle_glue/xmpp_iq_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698