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_
11 #include "chrome/browser/media/router/media_router.mojom.h"
12 #include "chrome/browser/media/router/media_router_mojo_impl.h"
13 #include "chrome/browser/media/router/media_routes_observer.h"
14 #include "chrome/browser/media/router/media_sinks_observer.h"
15 #include "extensions/browser/event_page_tracker.h"
16 #include "testing/gmock/include/gmock/gmock.h"
18 namespace media_router
{
20 // Matcher for objects that uses Equals() member function for equality check.
21 MATCHER_P(Equals
, other
, "") {
22 return arg
.Equals(other
);
25 // Matcher for a sequence of objects that uses Equals() member function for
27 MATCHER_P(SequenceEquals
, other
, "") {
28 if (arg
.size() != other
.size()) {
31 for (size_t i
= 0; i
< arg
.size(); ++i
) {
32 if (!arg
[i
].Equals(other
[i
])) {
39 class MockMojoMediaRouterService
: public interfaces::MediaRouter
{
41 MockMojoMediaRouterService();
42 ~MockMojoMediaRouterService() override
;
44 MOCK_METHOD6(CreateRoute
,
45 void(const mojo::String
& source_urn
,
46 const mojo::String
& sink_id
,
47 const mojo::String
& presentation_id
,
48 const mojo::String
& origin
,
50 const CreateRouteCallback
& callback
));
51 MOCK_METHOD5(JoinRoute
,
52 void(const mojo::String
& source_urn
,
53 const mojo::String
& presentation_id
,
54 const mojo::String
& origin
,
56 const JoinRouteCallback
& callback
));
57 MOCK_METHOD1(CloseRoute
, void(const mojo::String
& route_id
));
58 MOCK_METHOD1(StartObservingMediaSinks
, void(const mojo::String
& source
));
59 MOCK_METHOD1(StopObservingMediaSinks
, void(const mojo::String
& source
));
60 MOCK_METHOD3(SendRouteMessage
,
61 void(const mojo::String
& media_route_id
,
62 const mojo::String
& message
,
63 const SendRouteMessageCallback
& callback
));
64 void ListenForRouteMessages(mojo::Array
<mojo::String
> route_ids
,
65 const ListenForRouteMessagesCallback
& callback
) {
66 ListenForRouteMessagesInteral(route_ids
.storage(), callback
);
68 MOCK_METHOD2(ListenForRouteMessagesInteral
,
69 void(const std::vector
<mojo::String
>& route_ids
,
70 const ListenForRouteMessagesCallback
& callback
));
71 MOCK_METHOD1(ClearIssue
, void(const mojo::String
& issue_id
));
72 MOCK_METHOD0(StartObservingMediaRoutes
, void());
73 MOCK_METHOD0(StopObservingMediaRoutes
, void());
76 DISALLOW_COPY_AND_ASSIGN(MockMojoMediaRouterService
);
79 class MockMediaSinksObserver
: public MediaSinksObserver
{
81 MockMediaSinksObserver(MediaRouter
* router
, const MediaSource
& source
);
82 ~MockMediaSinksObserver() override
;
84 MOCK_METHOD1(OnSinksReceived
, void(const std::vector
<MediaSink
>& sinks
));
87 class MockMediaRoutesObserver
: public MediaRoutesObserver
{
89 explicit MockMediaRoutesObserver(MediaRouter
* router
);
90 ~MockMediaRoutesObserver();
92 MOCK_METHOD1(OnRoutesUpdated
, void(const std::vector
<MediaRoute
>& sinks
));
95 class MockEventPageTracker
: public extensions::EventPageTracker
{
97 MockEventPageTracker();
98 ~MockEventPageTracker();
100 MOCK_METHOD1(IsEventPageSuspended
, bool(const std::string
& extension_id
));
101 MOCK_METHOD2(WakeEventPage
,
102 bool(const std::string
& extension_id
,
103 const base::Callback
<void(bool)>& callback
));
106 } // namespace media_router
108 #endif // CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_