| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "chrome/browser/media/router/issues_observer.h" | 15 #include "chrome/browser/media/router/issues_observer.h" |
| 16 #include "chrome/browser/media/router/media_router.mojom.h" | |
| 17 #include "chrome/browser/media/router/media_router_mojo_impl.h" | |
| 18 #include "chrome/browser/media/router/media_routes_observer.h" | 16 #include "chrome/browser/media/router/media_routes_observer.h" |
| 19 #include "chrome/browser/media/router/media_sinks_observer.h" | 17 #include "chrome/browser/media/router/media_sinks_observer.h" |
| 20 #include "extensions/browser/event_page_tracker.h" | 18 #include "content/public/browser/presentation_service_delegate.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 22 | 20 |
| 23 namespace media_router { | 21 namespace media_router { |
| 24 | 22 |
| 25 // Matcher for objects that uses Equals() member function for equality check. | 23 // Matcher for objects that uses Equals() member function for equality check. |
| 26 MATCHER_P(Equals, other, "") { | 24 MATCHER_P(Equals, other, "") { |
| 27 return arg.Equals(other); | 25 return arg.Equals(other); |
| 28 } | 26 } |
| 29 | 27 |
| 30 // Matcher for a sequence of objects that uses Equals() member function for | 28 // Matcher for a sequence of objects that uses Equals() member function for |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 83 } |
| 86 | 84 |
| 87 class MockIssuesObserver : public IssuesObserver { | 85 class MockIssuesObserver : public IssuesObserver { |
| 88 public: | 86 public: |
| 89 explicit MockIssuesObserver(MediaRouter* router); | 87 explicit MockIssuesObserver(MediaRouter* router); |
| 90 ~MockIssuesObserver() override; | 88 ~MockIssuesObserver() override; |
| 91 | 89 |
| 92 MOCK_METHOD1(OnIssueUpdated, void(const Issue* issue)); | 90 MOCK_METHOD1(OnIssueUpdated, void(const Issue* issue)); |
| 93 }; | 91 }; |
| 94 | 92 |
| 95 class MockMediaRouteProvider : public interfaces::MediaRouteProvider { | |
| 96 public: | |
| 97 MockMediaRouteProvider(); | |
| 98 ~MockMediaRouteProvider() override; | |
| 99 | |
| 100 MOCK_METHOD8(CreateRoute, | |
| 101 void(const mojo::String& source_urn, | |
| 102 const mojo::String& sink_id, | |
| 103 const mojo::String& presentation_id, | |
| 104 const mojo::String& origin, | |
| 105 int tab_id, | |
| 106 int64_t timeout_secs, | |
| 107 bool off_the_record, | |
| 108 const CreateRouteCallback& callback)); | |
| 109 MOCK_METHOD7(JoinRoute, | |
| 110 void(const mojo::String& source_urn, | |
| 111 const mojo::String& presentation_id, | |
| 112 const mojo::String& origin, | |
| 113 int tab_id, | |
| 114 int64_t timeout_secs, | |
| 115 bool off_the_record, | |
| 116 const JoinRouteCallback& callback)); | |
| 117 MOCK_METHOD8(ConnectRouteByRouteId, | |
| 118 void(const mojo::String& source_urn, | |
| 119 const mojo::String& route_id, | |
| 120 const mojo::String& presentation_id, | |
| 121 const mojo::String& origin, | |
| 122 int tab_id, | |
| 123 int64_t timeout_secs, | |
| 124 bool off_the_record, | |
| 125 const JoinRouteCallback& callback)); | |
| 126 MOCK_METHOD1(DetachRoute, void(const mojo::String& route_id)); | |
| 127 MOCK_METHOD1(TerminateRoute, void(const mojo::String& route_id)); | |
| 128 MOCK_METHOD1(StartObservingMediaSinks, void(const mojo::String& source)); | |
| 129 MOCK_METHOD1(StopObservingMediaSinks, void(const mojo::String& source)); | |
| 130 MOCK_METHOD3(SendRouteMessage, | |
| 131 void(const mojo::String& media_route_id, | |
| 132 const mojo::String& message, | |
| 133 const SendRouteMessageCallback& callback)); | |
| 134 void SendRouteBinaryMessage( | |
| 135 const mojo::String& media_route_id, | |
| 136 mojo::Array<uint8_t> data, | |
| 137 const SendRouteMessageCallback& callback) override { | |
| 138 SendRouteBinaryMessageInternal(media_route_id, data.storage(), callback); | |
| 139 } | |
| 140 MOCK_METHOD3(SendRouteBinaryMessageInternal, | |
| 141 void(const mojo::String& media_route_id, | |
| 142 const std::vector<uint8_t>& data, | |
| 143 const SendRouteMessageCallback& callback)); | |
| 144 MOCK_METHOD2(ListenForRouteMessages, | |
| 145 void(const mojo::String& route_id, | |
| 146 const ListenForRouteMessagesCallback& callback)); | |
| 147 MOCK_METHOD1(StopListeningForRouteMessages, | |
| 148 void(const mojo::String& route_id)); | |
| 149 MOCK_METHOD1(OnPresentationSessionDetached, | |
| 150 void(const mojo::String& route_id)); | |
| 151 MOCK_METHOD1(StartObservingMediaRoutes, void(const mojo::String& source)); | |
| 152 MOCK_METHOD1(StopObservingMediaRoutes, void(const mojo::String& source)); | |
| 153 MOCK_METHOD0(EnableMdnsDiscovery, void()); | |
| 154 | |
| 155 private: | |
| 156 DISALLOW_COPY_AND_ASSIGN(MockMediaRouteProvider); | |
| 157 }; | |
| 158 | |
| 159 class MockMediaSinksObserver : public MediaSinksObserver { | 93 class MockMediaSinksObserver : public MediaSinksObserver { |
| 160 public: | 94 public: |
| 161 MockMediaSinksObserver(MediaRouter* router, | 95 MockMediaSinksObserver(MediaRouter* router, |
| 162 const MediaSource& source, | 96 const MediaSource& source, |
| 163 const GURL& origin); | 97 const GURL& origin); |
| 164 ~MockMediaSinksObserver() override; | 98 ~MockMediaSinksObserver() override; |
| 165 | 99 |
| 166 MOCK_METHOD1(OnSinksReceived, void(const std::vector<MediaSink>& sinks)); | 100 MOCK_METHOD1(OnSinksReceived, void(const std::vector<MediaSink>& sinks)); |
| 167 }; | 101 }; |
| 168 | 102 |
| 169 class MockMediaRoutesObserver : public MediaRoutesObserver { | 103 class MockMediaRoutesObserver : public MediaRoutesObserver { |
| 170 public: | 104 public: |
| 171 explicit MockMediaRoutesObserver(MediaRouter* router, | 105 explicit MockMediaRoutesObserver(MediaRouter* router, |
| 172 const MediaSource::Id source_id = std::string()); | 106 const MediaSource::Id source_id = std::string()); |
| 173 ~MockMediaRoutesObserver() override; | 107 ~MockMediaRoutesObserver() override; |
| 174 | 108 |
| 175 MOCK_METHOD2(OnRoutesUpdated, void(const std::vector<MediaRoute>& routes, | 109 MOCK_METHOD2(OnRoutesUpdated, void(const std::vector<MediaRoute>& routes, |
| 176 const std::vector<MediaRoute::Id>& joinable_route_ids)); | 110 const std::vector<MediaRoute::Id>& joinable_route_ids)); |
| 177 }; | 111 }; |
| 178 | 112 |
| 179 class MockEventPageTracker : public extensions::EventPageTracker { | |
| 180 public: | |
| 181 MockEventPageTracker(); | |
| 182 ~MockEventPageTracker(); | |
| 183 | |
| 184 MOCK_METHOD1(IsEventPageSuspended, bool(const std::string& extension_id)); | |
| 185 MOCK_METHOD2(WakeEventPage, | |
| 186 bool(const std::string& extension_id, | |
| 187 const base::Callback<void(bool)>& callback)); | |
| 188 }; | |
| 189 | |
| 190 class MockPresentationConnectionStateChangedCallback { | 113 class MockPresentationConnectionStateChangedCallback { |
| 191 public: | 114 public: |
| 192 MockPresentationConnectionStateChangedCallback(); | 115 MockPresentationConnectionStateChangedCallback(); |
| 193 ~MockPresentationConnectionStateChangedCallback(); | 116 ~MockPresentationConnectionStateChangedCallback(); |
| 194 MOCK_METHOD1(Run, | 117 MOCK_METHOD1(Run, |
| 195 void(const content::PresentationConnectionStateChangeInfo&)); | 118 void(const content::PresentationConnectionStateChangeInfo&)); |
| 196 }; | 119 }; |
| 197 | 120 |
| 198 } // namespace media_router | 121 } // namespace media_router |
| 199 | 122 |
| 200 #endif // CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ | 123 #endif // CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ |
| OLD | NEW |