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

Side by Side Diff: extensions/browser/api/cast_channel/cast_test_util.h

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TEST_UTIL_H_ 5 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TEST_UTIL_H_
6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TEST_UTIL_H_ 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TEST_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "extensions/browser/api/cast_channel/cast_socket.h" 13 #include "extensions/browser/api/cast_channel/cast_socket.h"
14 #include "extensions/browser/api/cast_channel/cast_transport.h" 14 #include "extensions/browser/api/cast_channel/cast_transport.h"
15 #include "extensions/common/api/cast_channel/cast_channel.pb.h" 15 #include "extensions/common/api/cast_channel/cast_channel.pb.h"
16 #include "net/base/ip_endpoint.h" 16 #include "net/base/ip_endpoint.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 18
19 namespace extensions { 19 namespace extensions {
20 namespace api { 20 namespace api {
21 namespace cast_channel { 21 namespace cast_channel {
22 22
23 extern const char kTestExtensionId[]; 23 extern const char kTestExtensionId[];
24 24
25 class MockCastTransport : public extensions::api::cast_channel::CastTransport { 25 class MockCastTransport : public extensions::api::cast_channel::CastTransport {
26 public: 26 public:
27 MockCastTransport(); 27 MockCastTransport();
28 ~MockCastTransport() override; 28 ~MockCastTransport() override;
29 29
30 void SetReadDelegate(scoped_ptr<CastTransport::Delegate> delegate) override; 30 void SetReadDelegate(
31 std::unique_ptr<CastTransport::Delegate> delegate) override;
31 32
32 MOCK_METHOD2(SendMessage, 33 MOCK_METHOD2(SendMessage,
33 void(const extensions::api::cast_channel::CastMessage& message, 34 void(const extensions::api::cast_channel::CastMessage& message,
34 const net::CompletionCallback& callback)); 35 const net::CompletionCallback& callback));
35 36
36 MOCK_METHOD0(Start, void(void)); 37 MOCK_METHOD0(Start, void(void));
37 38
38 // Gets the read delegate that is currently active for this transport. 39 // Gets the read delegate that is currently active for this transport.
39 CastTransport::Delegate* current_delegate() const; 40 CastTransport::Delegate* current_delegate() const;
40 41
41 private: 42 private:
42 scoped_ptr<CastTransport::Delegate> delegate_; 43 std::unique_ptr<CastTransport::Delegate> delegate_;
43 44
44 DISALLOW_COPY_AND_ASSIGN(MockCastTransport); 45 DISALLOW_COPY_AND_ASSIGN(MockCastTransport);
45 }; 46 };
46 47
47 class MockCastTransportDelegate : public CastTransport::Delegate { 48 class MockCastTransportDelegate : public CastTransport::Delegate {
48 public: 49 public:
49 MockCastTransportDelegate(); 50 MockCastTransportDelegate();
50 ~MockCastTransportDelegate() override; 51 ~MockCastTransportDelegate() override;
51 52
52 MOCK_METHOD1(OnError, void(ChannelError error)); 53 MOCK_METHOD1(OnError, void(ChannelError error));
(...skipping 10 matching lines...) Expand all
63 ~MockCastSocket() override; 64 ~MockCastSocket() override;
64 65
65 // Mockable version of Connect. Accepts a bare pointer to a mock object. 66 // Mockable version of Connect. Accepts a bare pointer to a mock object.
66 // (GMock won't compile with scoped_ptr method parameters.) 67 // (GMock won't compile with scoped_ptr method parameters.)
67 MOCK_METHOD2(ConnectRawPtr, 68 MOCK_METHOD2(ConnectRawPtr,
68 void(CastTransport::Delegate* delegate, 69 void(CastTransport::Delegate* delegate,
69 base::Callback<void(ChannelError)> callback)); 70 base::Callback<void(ChannelError)> callback));
70 71
71 // Proxy for ConnectRawPtr. Unpacks scoped_ptr into a GMock-friendly bare 72 // Proxy for ConnectRawPtr. Unpacks scoped_ptr into a GMock-friendly bare
72 // ptr. 73 // ptr.
73 void Connect(scoped_ptr<CastTransport::Delegate> delegate, 74 void Connect(std::unique_ptr<CastTransport::Delegate> delegate,
74 base::Callback<void(ChannelError)> callback) override { 75 base::Callback<void(ChannelError)> callback) override {
75 delegate_ = std::move(delegate); 76 delegate_ = std::move(delegate);
76 ConnectRawPtr(delegate_.get(), callback); 77 ConnectRawPtr(delegate_.get(), callback);
77 } 78 }
78 79
79 MOCK_METHOD1(Close, void(const net::CompletionCallback& callback)); 80 MOCK_METHOD1(Close, void(const net::CompletionCallback& callback));
80 MOCK_CONST_METHOD0(ip_endpoint, const net::IPEndPoint&()); 81 MOCK_CONST_METHOD0(ip_endpoint, const net::IPEndPoint&());
81 MOCK_CONST_METHOD0(id, int()); 82 MOCK_CONST_METHOD0(id, int());
82 MOCK_METHOD1(set_id, void(int id)); 83 MOCK_METHOD1(set_id, void(int id));
83 MOCK_CONST_METHOD0(channel_auth, ChannelAuthType()); 84 MOCK_CONST_METHOD0(channel_auth, ChannelAuthType());
84 MOCK_CONST_METHOD0(ready_state, ReadyState()); 85 MOCK_CONST_METHOD0(ready_state, ReadyState());
85 MOCK_CONST_METHOD0(error_state, ChannelError()); 86 MOCK_CONST_METHOD0(error_state, ChannelError());
86 MOCK_CONST_METHOD0(keep_alive, bool(void)); 87 MOCK_CONST_METHOD0(keep_alive, bool(void));
87 MOCK_CONST_METHOD0(audio_only, bool(void)); 88 MOCK_CONST_METHOD0(audio_only, bool(void));
88 MOCK_METHOD1(SetErrorState, void(ChannelError error_state)); 89 MOCK_METHOD1(SetErrorState, void(ChannelError error_state));
89 90
90 CastTransport* transport() const override { return mock_transport_.get(); } 91 CastTransport* transport() const override { return mock_transport_.get(); }
91 92
92 MockCastTransport* mock_transport() const { return mock_transport_.get(); } 93 MockCastTransport* mock_transport() const { return mock_transport_.get(); }
93 94
94 private: 95 private:
95 scoped_ptr<MockCastTransport> mock_transport_; 96 std::unique_ptr<MockCastTransport> mock_transport_;
96 scoped_ptr<CastTransport::Delegate> delegate_; 97 std::unique_ptr<CastTransport::Delegate> delegate_;
97 98
98 DISALLOW_COPY_AND_ASSIGN(MockCastSocket); 99 DISALLOW_COPY_AND_ASSIGN(MockCastSocket);
99 }; 100 };
100 101
101 // Creates the IPEndpoint 192.168.1.1. 102 // Creates the IPEndpoint 192.168.1.1.
102 net::IPEndPoint CreateIPEndPointForTest(); 103 net::IPEndPoint CreateIPEndPointForTest();
103 104
104 // Checks if two proto messages are the same. 105 // Checks if two proto messages are the same.
105 // From 106 // From
106 // third_party/cacheinvalidation/overrides/google/cacheinvalidation/deps/gmock.h 107 // third_party/cacheinvalidation/overrides/google/cacheinvalidation/deps/gmock.h
(...skipping 10 matching lines...) Expand all
117 AND_1_VALUE_PARAMS(rv)) { 118 AND_1_VALUE_PARAMS(rv)) {
118 base::MessageLoop::current()->PostTask( 119 base::MessageLoop::current()->PostTask(
119 FROM_HERE, base::Bind(testing::get<cb_idx>(args), rv)); 120 FROM_HERE, base::Bind(testing::get<cb_idx>(args), rv));
120 } 121 }
121 122
122 } // namespace cast_channel 123 } // namespace cast_channel
123 } // namespace api 124 } // namespace api
124 } // namespace extensions 125 } // namespace extensions
125 126
126 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TEST_UTIL_H_ 127 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_socket_unittest.cc ('k') | extensions/browser/api/cast_channel/cast_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698