1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_
#define CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_
#include <string>
#include <vector>
#include "chrome/browser/media/router/media_router.mojom.h"
#include "chrome/browser/media/router/media_router_mojo_impl.h"
#include "chrome/browser/media/router/media_routes_observer.h"
#include "chrome/browser/media/router/media_sinks_observer.h"
#include "extensions/browser/event_page_tracker.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace media_router {
// Matcher for objects that uses Equals() member function for equality check.
MATCHER_P(Equals, other, "") {
return arg.Equals(other);
}
// Matcher for a sequence of objects that uses Equals() member function for
// equality check.
MATCHER_P(SequenceEquals, other, "") {
if (arg.size() != other.size()) {
return false;
}
for (size_t i = 0; i < arg.size(); ++i) {
if (!arg[i].Equals(other[i])) {
return false;
}
}
return true;
}
class MockMediaRouteProvider : public interfaces::MediaRouteProvider {
public:
MockMediaRouteProvider();
~MockMediaRouteProvider() override;
MOCK_METHOD6(CreateRoute,
void(const mojo::String& source_urn,
const mojo::String& sink_id,
const mojo::String& presentation_id,
const mojo::String& origin,
int tab_id,
const CreateRouteCallback& callback));
MOCK_METHOD5(JoinRoute,
void(const mojo::String& source_urn,
const mojo::String& presentation_id,
const mojo::String& origin,
int tab_id,
const JoinRouteCallback& callback));
MOCK_METHOD1(CloseRoute, void(const mojo::String& route_id));
MOCK_METHOD1(StartObservingMediaSinks, void(const mojo::String& source));
MOCK_METHOD1(StopObservingMediaSinks, void(const mojo::String& source));
MOCK_METHOD3(SendRouteMessage,
void(const mojo::String& media_route_id,
const mojo::String& message,
const SendRouteMessageCallback& callback));
void ListenForRouteMessages(mojo::Array<mojo::String> route_ids,
const ListenForRouteMessagesCallback& callback) {
ListenForRouteMessagesInteral(route_ids.storage(), callback);
}
MOCK_METHOD2(ListenForRouteMessagesInteral,
void(const std::vector<mojo::String>& route_ids,
const ListenForRouteMessagesCallback& callback));
MOCK_METHOD1(ClearIssue, void(const mojo::String& issue_id));
MOCK_METHOD0(StartObservingMediaRoutes, void());
MOCK_METHOD0(StopObservingMediaRoutes, void());
private:
DISALLOW_COPY_AND_ASSIGN(MockMediaRouteProvider);
};
class MockMediaSinksObserver : public MediaSinksObserver {
public:
MockMediaSinksObserver(MediaRouter* router, const MediaSource& source);
~MockMediaSinksObserver() override;
MOCK_METHOD1(OnSinksReceived, void(const std::vector<MediaSink>& sinks));
};
class MockMediaRoutesObserver : public MediaRoutesObserver {
public:
explicit MockMediaRoutesObserver(MediaRouter* router);
~MockMediaRoutesObserver();
MOCK_METHOD1(OnRoutesUpdated, void(const std::vector<MediaRoute>& sinks));
};
class MockEventPageTracker : public extensions::EventPageTracker {
public:
MockEventPageTracker();
~MockEventPageTracker();
MOCK_METHOD1(IsEventPageSuspended, bool(const std::string& extension_id));
MOCK_METHOD2(WakeEventPage,
bool(const std::string& extension_id,
const base::Callback<void(bool)>& callback));
};
} // namespace media_router
#endif // CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_
|