OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/test/media_router/media_router_e2e_browsertest.h" | 5 #include "chrome/test/media_router/media_router_e2e_browsertest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "chrome/browser/media/router/media_router.h" | 9 #include "chrome/browser/media/router/media_router.h" |
10 #include "chrome/browser/media/router/media_router_mojo_impl.h" | 10 #include "chrome/browser/media/router/media_router_mojo_impl.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 MediaRouterMojoImplFactory::GetApiForBrowserContext(browser()->profile()); | 54 MediaRouterMojoImplFactory::GetApiForBrowserContext(browser()->profile()); |
55 DCHECK(media_router_); | 55 DCHECK(media_router_); |
56 } | 56 } |
57 | 57 |
58 void MediaRouterE2EBrowserTest::TearDownOnMainThread() { | 58 void MediaRouterE2EBrowserTest::TearDownOnMainThread() { |
59 MediaRouterBaseBrowserTest::TearDownOnMainThread(); | 59 MediaRouterBaseBrowserTest::TearDownOnMainThread(); |
60 media_router_ = nullptr; | 60 media_router_ = nullptr; |
61 } | 61 } |
62 | 62 |
63 void MediaRouterE2EBrowserTest::OnRouteResponseReceived( | 63 void MediaRouterE2EBrowserTest::OnRouteResponseReceived( |
64 scoped_ptr<MediaRoute> route, | 64 const MediaRoute* route, |
65 const std::string& error) { | 65 const std::string& error) { |
66 ASSERT_TRUE(route.get()); | 66 ASSERT_TRUE(route); |
67 route_id_ = route->media_route_id(); | 67 route_id_ = route->media_route_id(); |
68 } | 68 } |
69 | 69 |
70 void MediaRouterE2EBrowserTest::CreateMediaRoute(const MediaSource& source, | 70 void MediaRouterE2EBrowserTest::CreateMediaRoute(const MediaSource& source, |
71 const GURL& origin, | 71 const GURL& origin, |
72 int tab_id) { | 72 int tab_id) { |
73 DCHECK(media_router_); | 73 DCHECK(media_router_); |
74 observer_.reset(new TestMediaSinksObserver(media_router_, source)); | 74 observer_.reset(new TestMediaSinksObserver(media_router_, source)); |
75 | 75 |
76 DVLOG(1) << "Receiver name: " << receiver_; | 76 DVLOG(1) << "Receiver name: " << receiver_; |
77 // Wait for MediaSinks compatible with |source| to be discovered. | 77 // Wait for MediaSinks compatible with |source| to be discovered. |
78 ConditionalWait(base::TimeDelta::FromSeconds(30), | 78 ConditionalWait(base::TimeDelta::FromSeconds(30), |
79 base::TimeDelta::FromSeconds(1), | 79 base::TimeDelta::FromSeconds(1), |
80 base::Bind(&MediaRouterE2EBrowserTest::IsSinkDiscovered, | 80 base::Bind(&MediaRouterE2EBrowserTest::IsSinkDiscovered, |
81 base::Unretained(this))); | 81 base::Unretained(this))); |
82 | 82 |
83 const auto& sink_map = observer_->sink_map; | 83 const auto& sink_map = observer_->sink_map; |
84 const auto it = sink_map.find(receiver_); | 84 const auto it = sink_map.find(receiver_); |
85 const MediaSink& sink = it->second; | 85 const MediaSink& sink = it->second; |
86 | 86 |
87 // The callback will set route_id_ when invoked. | 87 // The callback will set route_id_ when invoked. |
88 media_router_->CreateRoute( | 88 std::vector<MediaRouteResponseCallback> route_response_callbacks; |
89 source.id(), sink.id(), origin, tab_id, | 89 route_response_callbacks.push_back( |
90 base::Bind(&MediaRouterE2EBrowserTest::OnRouteResponseReceived, | 90 base::Bind(&MediaRouterE2EBrowserTest::OnRouteResponseReceived, |
91 base::Unretained(this))); | 91 base::Unretained(this))); |
| 92 media_router_->CreateRoute(source.id(), sink.id(), origin, tab_id, |
| 93 route_response_callbacks); |
92 | 94 |
93 // Wait for the route request to be fulfilled (and route to be started). | 95 // Wait for the route request to be fulfilled (and route to be started). |
94 ConditionalWait(base::TimeDelta::FromSeconds(30), | 96 ConditionalWait(base::TimeDelta::FromSeconds(30), |
95 base::TimeDelta::FromSeconds(1), | 97 base::TimeDelta::FromSeconds(1), |
96 base::Bind(&MediaRouterE2EBrowserTest::IsRouteCreated, | 98 base::Bind(&MediaRouterE2EBrowserTest::IsRouteCreated, |
97 base::Unretained(this))); | 99 base::Unretained(this))); |
98 } | 100 } |
99 | 101 |
100 void MediaRouterE2EBrowserTest::StopMediaRoute() { | 102 void MediaRouterE2EBrowserTest::StopMediaRoute() { |
101 ASSERT_FALSE(route_id_.empty()); | 103 ASSERT_FALSE(route_id_.empty()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 CreateMediaRoute(MediaSourceForPresentationUrl(kCastAppPresentationUrl), | 149 CreateMediaRoute(MediaSourceForPresentationUrl(kCastAppPresentationUrl), |
148 GURL("http://origin/"), kInvalidTabId); | 150 GURL("http://origin/"), kInvalidTabId); |
149 Wait(base::TimeDelta::FromSeconds(30)); | 151 Wait(base::TimeDelta::FromSeconds(30)); |
150 | 152 |
151 // Wait for 10 seconds to make sure route has been stopped. | 153 // Wait for 10 seconds to make sure route has been stopped. |
152 StopMediaRoute(); | 154 StopMediaRoute(); |
153 Wait(base::TimeDelta::FromSeconds(10)); | 155 Wait(base::TimeDelta::FromSeconds(10)); |
154 } | 156 } |
155 | 157 |
156 } // namespace media_router | 158 } // namespace media_router |
OLD | NEW |