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_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 Loading... |
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 |
OLD | NEW |