Rename GetIconID to GetIconId
[chromium-blink-merge.git] / chrome / browser / media / router / test_helper.h
blob1c5bf8d05e08db47e1727301b76b237270522a5e
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_
8 #include <string>
9 #include <vector>
11 #include "chrome/browser/media/router/issues_observer.h"
12 #include "chrome/browser/media/router/media_router.mojom.h"
13 #include "chrome/browser/media/router/media_router_mojo_impl.h"
14 #include "chrome/browser/media/router/media_routes_observer.h"
15 #include "chrome/browser/media/router/media_sinks_observer.h"
16 #include "extensions/browser/event_page_tracker.h"
17 #include "testing/gmock/include/gmock/gmock.h"
19 namespace media_router {
21 // Matcher for objects that uses Equals() member function for equality check.
22 MATCHER_P(Equals, other, "") {
23 return arg.Equals(other);
26 // Matcher for a sequence of objects that uses Equals() member function for
27 // equality check.
28 MATCHER_P(SequenceEquals, other, "") {
29 if (arg.size() != other.size()) {
30 return false;
32 for (size_t i = 0; i < arg.size(); ++i) {
33 if (!arg[i].Equals(other[i])) {
34 return false;
37 return true;
40 // Matcher for checking all fields in Issue objects except the ID.
41 MATCHER_P(EqualsIssue, other, "") {
42 if (arg.title() != other.title())
43 return false;
45 if (arg.message() != other.message())
46 return false;
48 if (!arg.default_action().Equals(other.default_action()))
49 return false;
51 if (arg.secondary_actions().size() != other.secondary_actions().size())
52 return false;
54 for (size_t i = 0; i < arg.secondary_actions().size(); ++i) {
55 if (!arg.secondary_actions()[i].Equals(other.secondary_actions()[i]))
56 return false;
59 if (arg.route_id() != other.route_id())
60 return false;
62 if (arg.severity() != other.severity())
63 return false;
65 if (arg.is_blocking() != other.is_blocking())
66 return false;
68 if (arg.help_url() != other.help_url())
69 return false;
71 return true;
74 class MockIssuesObserver : public IssuesObserver {
75 public:
76 explicit MockIssuesObserver(MediaRouter* router);
77 ~MockIssuesObserver() override;
79 MOCK_METHOD1(OnIssueUpdated, void(const Issue* issue));
82 class MockMediaRouteProvider : public interfaces::MediaRouteProvider {
83 public:
84 MockMediaRouteProvider();
85 ~MockMediaRouteProvider() override;
87 MOCK_METHOD6(CreateRoute,
88 void(const mojo::String& source_urn,
89 const mojo::String& sink_id,
90 const mojo::String& presentation_id,
91 const mojo::String& origin,
92 int tab_id,
93 const CreateRouteCallback& callback));
94 MOCK_METHOD5(JoinRoute,
95 void(const mojo::String& source_urn,
96 const mojo::String& presentation_id,
97 const mojo::String& origin,
98 int tab_id,
99 const JoinRouteCallback& callback));
100 MOCK_METHOD1(CloseRoute, void(const mojo::String& route_id));
101 MOCK_METHOD1(StartObservingMediaSinks, void(const mojo::String& source));
102 MOCK_METHOD1(StopObservingMediaSinks, void(const mojo::String& source));
103 MOCK_METHOD3(SendRouteMessage,
104 void(const mojo::String& media_route_id,
105 const mojo::String& message,
106 const SendRouteMessageCallback& callback));
107 void SendRouteBinaryMessage(
108 const mojo::String& media_route_id,
109 mojo::Array<uint8> data,
110 const SendRouteMessageCallback& callback) override {
111 SendRouteBinaryMessageInternal(media_route_id, data.storage(), callback);
113 MOCK_METHOD3(SendRouteBinaryMessageInternal,
114 void(const mojo::String& media_route_id,
115 const std::vector<uint8>& data,
116 const SendRouteMessageCallback& callback));
117 MOCK_METHOD2(ListenForRouteMessages,
118 void(const mojo::String& route_id,
119 const ListenForRouteMessagesCallback& callback));
120 MOCK_METHOD1(StopListeningForRouteMessages,
121 void(const mojo::String& route_id));
122 MOCK_METHOD1(OnPresentationSessionDetached,
123 void(const mojo::String& route_id));
124 MOCK_METHOD0(StartObservingMediaRoutes, void());
125 MOCK_METHOD0(StopObservingMediaRoutes, void());
127 private:
128 DISALLOW_COPY_AND_ASSIGN(MockMediaRouteProvider);
131 class MockMediaSinksObserver : public MediaSinksObserver {
132 public:
133 MockMediaSinksObserver(MediaRouter* router, const MediaSource& source);
134 ~MockMediaSinksObserver() override;
136 MOCK_METHOD1(OnSinksReceived, void(const std::vector<MediaSink>& sinks));
139 class MockMediaRoutesObserver : public MediaRoutesObserver {
140 public:
141 explicit MockMediaRoutesObserver(MediaRouter* router);
142 ~MockMediaRoutesObserver();
144 MOCK_METHOD1(OnRoutesUpdated, void(const std::vector<MediaRoute>& sinks));
147 class MockEventPageTracker : public extensions::EventPageTracker {
148 public:
149 MockEventPageTracker();
150 ~MockEventPageTracker();
152 MOCK_METHOD1(IsEventPageSuspended, bool(const std::string& extension_id));
153 MOCK_METHOD2(WakeEventPage,
154 bool(const std::string& extension_id,
155 const base::Callback<void(bool)>& callback));
158 } // namespace media_router
160 #endif // CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_