OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
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" | |
17 | |
18 namespace media_router { | |
19 | |
20 // Custom GMock matchers | |
Wez
2015/05/20 23:37:50
nit: This comment doesn't seem to add anything? If
imcheng (use chromium acct)
2015/05/21 19:28:53
Removed.
| |
21 | |
22 // Checks if the two objects are the same, using the objects' | |
23 // .Equals() operator. | |
Wez
2015/05/20 23:37:50
nit: Neither this nor the comment on SequenceEqual
imcheng (use chromium acct)
2015/05/21 19:28:53
Ok, I replaced the comment with description of obj
| |
24 MATCHER_P(Equals, other, "") { | |
25 return arg.Equals(other); | |
26 } | |
27 | |
28 // Checks that the elements of two sequence collections are Equal() | |
29 // to each other. Collections must be of equal size. | |
30 MATCHER_P(SequenceEquals, other, "") { | |
31 if (arg.size() != other.size()) { | |
32 return false; | |
33 } | |
34 for (size_t i = 0; i < arg.size(); ++i) { | |
35 if (!arg[i].Equals(other[i])) { | |
36 return false; | |
37 } | |
38 } | |
39 return true; | |
40 } | |
41 | |
42 class MockMojoMediaRouterService : public interfaces::MediaRouter { | |
43 public: | |
44 MockMojoMediaRouterService(); | |
45 ~MockMojoMediaRouterService() override; | |
46 | |
47 MOCK_METHOD3(CreateRoute, | |
48 void(const mojo::String& source, | |
49 const mojo::String& sink_id, | |
50 const CreateRouteCallback& callback)); | |
51 MOCK_METHOD1(CloseRoute, void(const mojo::String& route_id)); | |
52 MOCK_METHOD1(StartObservingMediaSinks, void(const mojo::String& source)); | |
53 MOCK_METHOD1(StopObservingMediaSinks, void(const mojo::String& source)); | |
54 MOCK_METHOD2(PostMessage, | |
55 void(const mojo::String& media_route_id, | |
56 const mojo::String& message)); | |
57 MOCK_METHOD1(ClearIssue, void(const mojo::String& issue_id)); | |
58 MOCK_METHOD0(StartObservingMediaRoutes, void()); | |
59 MOCK_METHOD0(StopObservingMediaRoutes, void()); | |
60 | |
61 private: | |
62 DISALLOW_COPY_AND_ASSIGN(MockMojoMediaRouterService); | |
63 }; | |
64 | |
65 class MockMediaSinksObserver : public MediaSinksObserver { | |
66 public: | |
67 MockMediaSinksObserver(MediaRouter* router, const MediaSource& source); | |
68 ~MockMediaSinksObserver() override; | |
69 | |
70 MOCK_METHOD1(OnSinksReceived, void(const std::vector<MediaSink>& sinks)); | |
71 }; | |
72 | |
73 class MockMediaRoutesObserver : public MediaRoutesObserver { | |
74 public: | |
75 explicit MockMediaRoutesObserver(MediaRouter* router); | |
76 ~MockMediaRoutesObserver(); | |
77 | |
78 MOCK_METHOD1(OnRoutesUpdated, void(const std::vector<MediaRoute>& sinks)); | |
79 }; | |
80 | |
81 class MockEventPageTracker : public extensions::EventPageTracker { | |
82 public: | |
83 MockEventPageTracker(); | |
84 ~MockEventPageTracker(); | |
85 | |
86 MOCK_METHOD1(IsEventPageSuspended, bool(const std::string& extension_id)); | |
87 MOCK_METHOD2(WakeEventPage, | |
88 bool(const std::string& extension_id, | |
89 const base::Callback<void(bool)>& callback)); | |
90 }; | |
91 | |
92 } // namespace media_router | |
93 | |
94 #endif // CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ | |
OLD | NEW |