Chromium Code Reviews| Index: chrome/browser/media/router/test_helper.h |
| diff --git a/chrome/browser/media/router/test_helper.h b/chrome/browser/media/router/test_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d0e11c387179b3c0bdaf02f39de5dd30292b5fff |
| --- /dev/null |
| +++ b/chrome/browser/media/router/test_helper.h |
| @@ -0,0 +1,94 @@ |
| +// 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 { |
| + |
| +// 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.
|
| + |
| +// Checks if the two objects are the same, using the objects' |
| +// .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
|
| +MATCHER_P(Equals, other, "") { |
| + return arg.Equals(other); |
| +} |
| + |
| +// Checks that the elements of two sequence collections are Equal() |
| +// to each other. Collections must be of equal size. |
| +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 MockMojoMediaRouterService : public interfaces::MediaRouter { |
| + public: |
| + MockMojoMediaRouterService(); |
| + ~MockMojoMediaRouterService() override; |
| + |
| + MOCK_METHOD3(CreateRoute, |
| + void(const mojo::String& source, |
| + const mojo::String& sink_id, |
| + const CreateRouteCallback& 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_METHOD2(PostMessage, |
| + void(const mojo::String& media_route_id, |
| + const mojo::String& message)); |
| + MOCK_METHOD1(ClearIssue, void(const mojo::String& issue_id)); |
| + MOCK_METHOD0(StartObservingMediaRoutes, void()); |
| + MOCK_METHOD0(StopObservingMediaRoutes, void()); |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(MockMojoMediaRouterService); |
| +}; |
| + |
| +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_ |