Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4769)

Unified Diff: chrome/browser/media/router/test_helper.h

Issue 1055403006: Upstreaming review for Media Router Mojo interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate latest changes to MR API. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/media/router/mock_media_router.cc ('k') | chrome/browser/media/router/test_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..08d7b4f12ba3f1149f5d39d6b7d9c2cff79c7be5
--- /dev/null
+++ b/chrome/browser/media/router/test_helper.h
@@ -0,0 +1,110 @@
+// 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
+
+// Checks if the two objects are the same, using the objects'
+// .Equals() operator.
+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 MockApiDelegate : public MediaRouterMojoImpl::Delegate {
+ public:
+ MockApiDelegate();
+ ~MockApiDelegate();
+
+ MOCK_METHOD0(OnProviderManagerReady, void(void));
+ MOCK_METHOD0(OnConnectionError, void(void));
+ MOCK_CONST_METHOD0(GetInstanceId, const std::string&(void));
+ MOCK_METHOD2(OnMessage,
+ void(const MediaRouteId& route_id, const std::string& message));
+ MOCK_METHOD1(OnIssue, void(const Issue& issue));
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockApiDelegate);
+};
+
+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_
« no previous file with comments | « chrome/browser/media/router/mock_media_router.cc ('k') | chrome/browser/media/router/test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698