| Index: chrome/browser/media/router/mojo/media_router_mojo_test.h
|
| diff --git a/chrome/browser/media/router/test_helper.h b/chrome/browser/media/router/mojo/media_router_mojo_test.h
|
| similarity index 54%
|
| copy from chrome/browser/media/router/test_helper.h
|
| copy to chrome/browser/media/router/mojo/media_router_mojo_test.h
|
| index c4e6bc99b5a7cb6da5b65f3579340e8cd6e87423..012a33f8a2969bb07f57eec6460041fbfdb21d02 100644
|
| --- a/chrome/browser/media/router/test_helper.h
|
| +++ b/chrome/browser/media/router/mojo/media_router_mojo_test.h
|
| @@ -2,95 +2,28 @@
|
| // 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 <stddef.h>
|
| -#include <stdint.h>
|
| +#ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_TEST_H_
|
| +#define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_TEST_H_
|
|
|
| #include <string>
|
| -#include <vector>
|
|
|
| #include "base/macros.h"
|
| -#include "chrome/browser/media/router/issues_observer.h"
|
| +#include "base/memory/ref_counted.h"
|
| #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 "chrome/browser/media/router/mock_media_router.h"
|
| +#include "chrome/browser/media/router/mojo/media_router_mojo_impl.h"
|
| +#include "chrome/browser/media/router/test_helper.h"
|
| +#include "chrome/test/base/testing_profile.h"
|
| +#include "content/public/test/test_browser_thread_bundle.h"
|
| #include "extensions/browser/event_page_tracker.h"
|
| +#include "extensions/common/extension.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| +#include "testing/gtest/include/gtest/gtest.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;
|
| -}
|
| -
|
| -// Matcher for checking all fields in Issue objects except the ID.
|
| -MATCHER_P(EqualsIssue, other, "") {
|
| - if (arg.title() != other.title())
|
| - return false;
|
| -
|
| - if (arg.message() != other.message())
|
| - return false;
|
| -
|
| - if (!arg.default_action().Equals(other.default_action()))
|
| - return false;
|
| -
|
| - if (arg.secondary_actions().size() != other.secondary_actions().size())
|
| - return false;
|
| -
|
| - for (size_t i = 0; i < arg.secondary_actions().size(); ++i) {
|
| - if (!arg.secondary_actions()[i].Equals(other.secondary_actions()[i]))
|
| - return false;
|
| - }
|
| -
|
| - if (arg.route_id() != other.route_id())
|
| - return false;
|
| -
|
| - if (arg.severity() != other.severity())
|
| - return false;
|
| -
|
| - if (arg.is_blocking() != other.is_blocking())
|
| - return false;
|
| -
|
| - if (arg.help_url() != other.help_url())
|
| - return false;
|
| -
|
| - return true;
|
| -}
|
| -
|
| -MATCHER_P(IssueTitleEquals, title, "") {
|
| - return arg.title() == title;
|
| -}
|
| -
|
| -MATCHER_P(StateChageInfoEquals, other, "") {
|
| - return arg.state == other.state && arg.close_reason == other.close_reason &&
|
| - arg.message == other.message;
|
| -}
|
| -
|
| -class MockIssuesObserver : public IssuesObserver {
|
| - public:
|
| - explicit MockIssuesObserver(MediaRouter* router);
|
| - ~MockIssuesObserver() override;
|
| -
|
| - MOCK_METHOD1(OnIssueUpdated, void(const Issue* issue));
|
| -};
|
| +class MediaRouterMojoImpl;
|
|
|
| class MockMediaRouteProvider : public interfaces::MediaRouteProvider {
|
| public:
|
| @@ -156,26 +89,6 @@ class MockMediaRouteProvider : public interfaces::MediaRouteProvider {
|
| DISALLOW_COPY_AND_ASSIGN(MockMediaRouteProvider);
|
| };
|
|
|
| -class MockMediaSinksObserver : public MediaSinksObserver {
|
| - public:
|
| - MockMediaSinksObserver(MediaRouter* router,
|
| - const MediaSource& source,
|
| - const GURL& origin);
|
| - ~MockMediaSinksObserver() override;
|
| -
|
| - MOCK_METHOD1(OnSinksReceived, void(const std::vector<MediaSink>& sinks));
|
| -};
|
| -
|
| -class MockMediaRoutesObserver : public MediaRoutesObserver {
|
| - public:
|
| - explicit MockMediaRoutesObserver(MediaRouter* router,
|
| - const MediaSource::Id source_id = std::string());
|
| - ~MockMediaRoutesObserver() override;
|
| -
|
| - MOCK_METHOD2(OnRoutesUpdated, void(const std::vector<MediaRoute>& routes,
|
| - const std::vector<MediaRoute::Id>& joinable_route_ids));
|
| -};
|
| -
|
| class MockEventPageTracker : public extensions::EventPageTracker {
|
| public:
|
| MockEventPageTracker();
|
| @@ -187,14 +100,40 @@ class MockEventPageTracker : public extensions::EventPageTracker {
|
| const base::Callback<void(bool)>& callback));
|
| };
|
|
|
| -class MockPresentationConnectionStateChangedCallback {
|
| +// Tests the API call flow between the MediaRouterMojoImpl and the Media Router
|
| +// Mojo service in both directions.
|
| +class MediaRouterMojoTest : public ::testing::Test {
|
| public:
|
| - MockPresentationConnectionStateChangedCallback();
|
| - ~MockPresentationConnectionStateChangedCallback();
|
| - MOCK_METHOD1(Run,
|
| - void(const content::PresentationConnectionStateChangeInfo&));
|
| + MediaRouterMojoTest();
|
| + ~MediaRouterMojoTest() override;
|
| +
|
| + protected:
|
| + void SetUp() override;
|
| +
|
| + void ProcessEventLoop();
|
| +
|
| + void ConnectProviderManagerService();
|
| +
|
| + const std::string& extension_id() const { return extension_->id(); }
|
| +
|
| + MediaRouterMojoImpl* router() const { return mock_media_router_.get(); }
|
| +
|
| + // Mock objects.
|
| + MockMediaRouteProvider mock_media_route_provider_;
|
| + testing::NiceMock<MockEventPageTracker> mock_event_page_tracker_;
|
| +
|
| + // Mojo proxy object for |mock_media_router_|
|
| + media_router::interfaces::MediaRouterPtr media_router_proxy_;
|
| +
|
| + private:
|
| + content::TestBrowserThreadBundle test_thread_bundle_;
|
| + scoped_refptr<extensions::Extension> extension_;
|
| + scoped_ptr<MediaRouterMojoImpl> mock_media_router_;
|
| + scoped_ptr<mojo::Binding<interfaces::MediaRouteProvider>> binding_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoTest);
|
| };
|
|
|
| } // namespace media_router
|
|
|
| -#endif // CHROME_BROWSER_MEDIA_ROUTER_TEST_HELPER_H_
|
| +#endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_TEST_H_
|
|
|