| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/test/mock_callback.h" | 6 #include "base/test/mock_callback.h" |
| 7 #include "chrome/browser/media/router/mock_media_router.h" | 7 #include "chrome/browser/media/router/mock_media_router.h" |
| 8 #include "chrome/browser/media/router/test_helper.h" | 8 #include "chrome/browser/media/router/test_helper.h" |
| 9 #include "content/public/common/presentation_session.h" | 9 #include "content/public/common/presentation_session.h" |
| 10 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 route_id, callback); | 32 route_id, callback); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void OnIncognitoProfileShutdown() override { | 35 void OnIncognitoProfileShutdown() override { |
| 36 MediaRouterBase::OnIncognitoProfileShutdown(); | 36 MediaRouterBase::OnIncognitoProfileShutdown(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 std::vector<MediaRoute> GetCurrentRoutes() const override { | 39 std::vector<MediaRoute> GetCurrentRoutes() const override { |
| 40 return MediaRouterBase::GetCurrentRoutes(); | 40 return MediaRouterBase::GetCurrentRoutes(); |
| 41 } | 41 } |
| 42 |
| 43 const MediaRoute* GetPresentationRoute( |
| 44 const std::string& presentation_id) const override { |
| 45 return MediaRouterBase::GetPresentationRoute(presentation_id); |
| 46 } |
| 42 }; | 47 }; |
| 43 | 48 |
| 44 class MediaRouterBaseTest : public testing::Test { | 49 class MediaRouterBaseTest : public testing::Test { |
| 45 public: | 50 public: |
| 46 void SetUp() override { | 51 void SetUp() override { |
| 47 EXPECT_CALL(router_, RegisterMediaRoutesObserver(_)) | 52 EXPECT_CALL(router_, RegisterMediaRoutesObserver(_)) |
| 48 .WillOnce(SaveArg<0>(&routes_observer_)); | 53 .WillOnce(SaveArg<0>(&routes_observer_)); |
| 49 router_.Initialize(); | 54 router_.Initialize(); |
| 50 } | 55 } |
| 51 | 56 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 std::vector<MediaRoute> current_routes = router_.GetCurrentRoutes(); | 134 std::vector<MediaRoute> current_routes = router_.GetCurrentRoutes(); |
| 130 ASSERT_EQ(current_routes.size(), 2u); | 135 ASSERT_EQ(current_routes.size(), 2u); |
| 131 EXPECT_TRUE(current_routes[0].Equals(route1)); | 136 EXPECT_TRUE(current_routes[0].Equals(route1)); |
| 132 EXPECT_TRUE(current_routes[1].Equals(route2)); | 137 EXPECT_TRUE(current_routes[1].Equals(route2)); |
| 133 | 138 |
| 134 routes_observer_->OnRoutesUpdated(std::vector<MediaRoute>(), | 139 routes_observer_->OnRoutesUpdated(std::vector<MediaRoute>(), |
| 135 std::vector<MediaRoute::Id>()); | 140 std::vector<MediaRoute::Id>()); |
| 136 EXPECT_TRUE(router_.GetCurrentRoutes().empty()); | 141 EXPECT_TRUE(router_.GetCurrentRoutes().empty()); |
| 137 } | 142 } |
| 138 | 143 |
| 144 TEST_F(MediaRouterBaseTest, GetPresentationRoute) { |
| 145 MediaSource source1("source_1"); |
| 146 MediaSource source2("source_1"); |
| 147 MediaRoute route1("route_1", source1, "sink_1", "", false, "", false); |
| 148 MediaRoute route2("route_2", source2, "sink_2", "", true, "", false); |
| 149 std::string presentation_id1("presentation_id1"); |
| 150 std::string presentation_id2("presentation_id2"); |
| 151 std::string presentation_id3("presentation_id3"); |
| 152 route1.set_presentation_id(presentation_id1); |
| 153 route2.set_presentation_id(presentation_id2); |
| 154 std::vector<MediaRoute> routes = {route1, route2}; |
| 155 std::vector<MediaRoute::Id> joinable_route_ids = {"route_1"}; |
| 156 |
| 157 EXPECT_FALSE(router_.GetPresentationRoute(presentation_id1)); |
| 158 |
| 159 routes_observer_->OnRoutesUpdated(routes, joinable_route_ids); |
| 160 auto* actual_route1 = router_.GetPresentationRoute(presentation_id1); |
| 161 auto* actual_route2 = router_.GetPresentationRoute(presentation_id2); |
| 162 |
| 163 EXPECT_TRUE(actual_route1 && actual_route1->Equals(route1)); |
| 164 EXPECT_TRUE(actual_route2 && actual_route2->Equals(route2)); |
| 165 EXPECT_FALSE(router_.GetPresentationRoute(presentation_id3)); |
| 166 |
| 167 routes.erase(routes.begin()); |
| 168 routes_observer_->OnRoutesUpdated(routes, joinable_route_ids); |
| 169 |
| 170 EXPECT_FALSE(router_.GetPresentationRoute(presentation_id1)); |
| 171 } |
| 172 |
| 139 } // namespace media_router | 173 } // namespace media_router |
| OLD | NEW |