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

Unified Diff: components/cast_channel/cast_test_util.h

Issue 2942993003: [cast_channel] Make CastMessageHandler a CastSocket::Observer instead of CastTransport::Delegate (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/cast_channel/cast_test_util.h
diff --git a/components/cast_channel/cast_test_util.h b/components/cast_channel/cast_test_util.h
index e75b888ca76c7ec0389f539bb18ec85ce065917b..f9d9bd2f5e8f7d61a4b6c9d1b62ee24920ba54a7 100644
--- a/components/cast_channel/cast_test_util.h
+++ b/components/cast_channel/cast_test_util.h
@@ -54,6 +54,16 @@ class MockCastTransportDelegate : public CastTransport::Delegate {
DISALLOW_COPY_AND_ASSIGN(MockCastTransportDelegate);
};
+class MockCastSocketObserver : public CastSocket::Observer {
+ public:
+ MockCastSocketObserver();
+ ~MockCastSocketObserver() override;
+
+ MOCK_METHOD2(OnError, void(const CastSocket& socket, ChannelError error));
+ MOCK_METHOD2(OnMessage,
+ void(const CastSocket& socket, const CastMessage& message));
+};
+
class MockCastSocket : public CastSocket {
public:
MockCastSocket();
@@ -61,18 +71,18 @@ class MockCastSocket : public CastSocket {
// Mockable version of Connect. Accepts a bare pointer to a mock object.
// (GMock won't compile with scoped_ptr method parameters.)
- MOCK_METHOD2(ConnectRawPtr,
- void(CastTransport::Delegate* delegate,
- base::Callback<void(ChannelError)> callback));
+ MOCK_METHOD2(AddObserverInternal,
+ void(const std::string& id, Observer* observer));
// Proxy for ConnectRawPtr. Unpacks scoped_ptr into a GMock-friendly bare
// ptr.
- void Connect(std::unique_ptr<CastTransport::Delegate> delegate,
- base::Callback<void(ChannelError)> callback) override {
- delegate_ = std::move(delegate);
- ConnectRawPtr(delegate_.get(), callback);
+ void AddObserver(const std::string& id,
+ std::unique_ptr<Observer> observer) override {
+ observer_ = std::move(observer);
+ AddObserverInternal(id, observer_.get());
}
+ MOCK_METHOD1(Connect, void(base::Callback<void(ChannelError)> callback));
MOCK_METHOD1(Close, void(const net::CompletionCallback& callback));
MOCK_CONST_METHOD0(ip_endpoint, const net::IPEndPoint&());
MOCK_CONST_METHOD0(id, int());
@@ -82,6 +92,7 @@ class MockCastSocket : public CastSocket {
MOCK_CONST_METHOD0(keep_alive, bool(void));
MOCK_CONST_METHOD0(audio_only, bool(void));
MOCK_METHOD1(SetErrorState, void(ChannelError error_state));
+ MOCK_METHOD1(HasObserver, bool(const std::string& id));
CastTransport* transport() const override { return mock_transport_.get(); }
@@ -89,7 +100,7 @@ class MockCastSocket : public CastSocket {
private:
std::unique_ptr<MockCastTransport> mock_transport_;
- std::unique_ptr<CastTransport::Delegate> delegate_;
+ std::unique_ptr<Observer> observer_;
DISALLOW_COPY_AND_ASSIGN(MockCastSocket);
};

Powered by Google App Engine
This is Rietveld 408576698