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 // Matcher for objects that uses Equals() member function for equality check. |
| 21 MATCHER_P(Equals, other, "") { |
| 22 return arg.Equals(other); |
| 23 } |
| 24 |
| 25 // Matcher for a sequence of objects that uses Equals() member function for |
| 26 // equality check. |
| 27 MATCHER_P(SequenceEquals, other, "") { |
| 28 if (arg.size() != other.size()) { |
| 29 return false; |
| 30 } |
| 31 for (size_t i = 0; i < arg.size(); ++i) { |
| 32 if (!arg[i].Equals(other[i])) { |
| 33 return false; |
| 34 } |
| 35 } |
| 36 return true; |
| 37 } |
| 38 |
| 39 class MockMojoMediaRouterService : public interfaces::MediaRouter { |
| 40 public: |
| 41 MockMojoMediaRouterService(); |
| 42 ~MockMojoMediaRouterService() override; |
| 43 |
| 44 MOCK_METHOD3(CreateRoute, |
| 45 void(const mojo::String& source, |
| 46 const mojo::String& sink_id, |
| 47 const CreateRouteCallback& callback)); |
| 48 MOCK_METHOD1(CloseRoute, void(const mojo::String& route_id)); |
| 49 MOCK_METHOD1(StartObservingMediaSinks, void(const mojo::String& source)); |
| 50 MOCK_METHOD1(StopObservingMediaSinks, void(const mojo::String& source)); |
| 51 MOCK_METHOD2(PostMessage, |
| 52 void(const mojo::String& media_route_id, |
| 53 const mojo::String& message)); |
| 54 MOCK_METHOD1(ClearIssue, void(const mojo::String& issue_id)); |
| 55 MOCK_METHOD0(StartObservingMediaRoutes, void()); |
| 56 MOCK_METHOD0(StopObservingMediaRoutes, void()); |
| 57 |
| 58 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(MockMojoMediaRouterService); |
| 60 }; |
| 61 |
| 62 class MockMediaSinksObserver : public MediaSinksObserver { |
| 63 public: |
| 64 MockMediaSinksObserver(MediaRouter* router, const MediaSource& source); |
| 65 ~MockMediaSinksObserver() override; |
| 66 |
| 67 MOCK_METHOD1(OnSinksReceived, void(const std::vector<MediaSink>& sinks)); |
| 68 }; |
| 69 |
| 70 class MockMediaRoutesObserver : public MediaRoutesObserver { |
| 71 public: |
| 72 explicit MockMediaRoutesObserver(MediaRouter* router); |
| 73 ~MockMediaRoutesObserver(); |
| 74 |
| 75 MOCK_METHOD1(OnRoutesUpdated, void(const std::vector<MediaRoute>& sinks)); |
| 76 }; |
| 77 |
| 78 class MockEventPageTracker : public extensions::EventPageTracker { |
| 79 public: |
| 80 MockEventPageTracker(); |
| 81 ~MockEventPageTracker(); |
| 82 |
| 83 MOCK_METHOD1(IsEventPageSuspended, bool(const std::string& extension_id)); |
| 84 MOCK_METHOD2(WakeEventPage, |
| 85 bool(const std::string& extension_id, |
| 86 const base::Callback<void(bool)>& callback)); |
| 87 }; |
| 88 |
| 89 } // namespace media_router |
| 90 |
| 91 #endif // CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_ |
OLD | NEW |