| 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 <vector> | 7 #include <vector> |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 void MediaRouterE2EBrowserTest::OnRouteResponseReceived( | 74 void MediaRouterE2EBrowserTest::OnRouteResponseReceived( |
| 75 const RouteRequestResult& result) { | 75 const RouteRequestResult& result) { |
| 76 ASSERT_TRUE(result.route()); | 76 ASSERT_TRUE(result.route()); |
| 77 route_id_ = result.route()->media_route_id(); | 77 route_id_ = result.route()->media_route_id(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void MediaRouterE2EBrowserTest::CreateMediaRoute( | 80 void MediaRouterE2EBrowserTest::CreateMediaRoute( |
| 81 const MediaSource& source, | 81 const MediaSource& source, |
| 82 const GURL& origin, | |
| 83 content::WebContents* web_contents) { | 82 content::WebContents* web_contents) { |
| 84 DCHECK(media_router_); | 83 DCHECK(media_router_); |
| 85 observer_.reset(new TestMediaSinksObserver(media_router_, source)); | 84 observer_.reset(new TestMediaSinksObserver(media_router_, source)); |
| 86 observer_->Init(); | 85 observer_->Init(); |
| 87 | 86 |
| 88 DVLOG(1) << "Receiver name: " << receiver(); | 87 DVLOG(1) << "Receiver name: " << receiver(); |
| 89 // Wait for MediaSinks compatible with |source| to be discovered. | 88 // Wait for MediaSinks compatible with |source| to be discovered. |
| 90 ASSERT_TRUE(ConditionalWait( | 89 ASSERT_TRUE(ConditionalWait( |
| 91 base::TimeDelta::FromSeconds(30), base::TimeDelta::FromSeconds(1), | 90 base::TimeDelta::FromSeconds(30), base::TimeDelta::FromSeconds(1), |
| 92 base::Bind(&MediaRouterE2EBrowserTest::IsSinkDiscovered, | 91 base::Bind(&MediaRouterE2EBrowserTest::IsSinkDiscovered, |
| 93 base::Unretained(this)))); | 92 base::Unretained(this)))); |
| 94 | 93 |
| 95 const auto& sink_map = observer_->sink_map; | 94 const auto& sink_map = observer_->sink_map; |
| 96 const auto it = sink_map.find(receiver()); | 95 const auto it = sink_map.find(receiver()); |
| 97 const MediaSink& sink = it->second; | 96 const MediaSink& sink = it->second; |
| 98 | 97 |
| 99 // The callback will set route_id_ when invoked. | 98 // The callback will set route_id_ when invoked. |
| 100 std::vector<MediaRouteResponseCallback> route_response_callbacks; | 99 std::vector<MediaRouteResponseCallback> route_response_callbacks; |
| 101 route_response_callbacks.push_back( | 100 route_response_callbacks.push_back( |
| 102 base::Bind(&MediaRouterE2EBrowserTest::OnRouteResponseReceived, | 101 base::Bind(&MediaRouterE2EBrowserTest::OnRouteResponseReceived, |
| 103 base::Unretained(this))); | 102 base::Unretained(this))); |
| 104 media_router_->CreateRoute(source.id(), sink.id(), origin, web_contents, | 103 media_router_->CreateRoute(source.id(), sink.id(), GURL(source.origin()), |
| 105 route_response_callbacks, base::TimeDelta(), | 104 web_contents, route_response_callbacks, |
| 106 is_off_the_record()); | 105 base::TimeDelta(), is_off_the_record()); |
| 107 | 106 |
| 108 // Wait for the route request to be fulfilled (and route to be started). | 107 // Wait for the route request to be fulfilled (and route to be started). |
| 109 ASSERT_TRUE(ConditionalWait( | 108 ASSERT_TRUE(ConditionalWait( |
| 110 base::TimeDelta::FromSeconds(30), base::TimeDelta::FromSeconds(1), | 109 base::TimeDelta::FromSeconds(30), base::TimeDelta::FromSeconds(1), |
| 111 base::Bind(&MediaRouterE2EBrowserTest::IsRouteCreated, | 110 base::Bind(&MediaRouterE2EBrowserTest::IsRouteCreated, |
| 112 base::Unretained(this)))); | 111 base::Unretained(this)))); |
| 113 } | 112 } |
| 114 | 113 |
| 115 void MediaRouterE2EBrowserTest::StopMediaRoute() { | 114 void MediaRouterE2EBrowserTest::StopMediaRoute() { |
| 116 ASSERT_FALSE(route_id_.empty()); | 115 ASSERT_FALSE(route_id_.empty()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 142 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 141 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 143 | 142 |
| 144 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | 143 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
| 145 browser(), GURL("about:blank"), 1); | 144 browser(), GURL("about:blank"), 1); |
| 146 content::WebContents* web_contents = | 145 content::WebContents* web_contents = |
| 147 browser()->tab_strip_model()->GetActiveWebContents(); | 146 browser()->tab_strip_model()->GetActiveWebContents(); |
| 148 int tab_id = SessionTabHelper::IdForTab(web_contents); | 147 int tab_id = SessionTabHelper::IdForTab(web_contents); |
| 149 | 148 |
| 150 // Wait for 30 seconds to make sure the route is stable. | 149 // Wait for 30 seconds to make sure the route is stable. |
| 151 CreateMediaRoute( | 150 CreateMediaRoute( |
| 152 MediaSourceForTab(tab_id), GURL(kOriginUrl), web_contents); | 151 MediaSourceForTab(tab_id), web_contents); |
| 153 Wait(base::TimeDelta::FromSeconds(30)); | 152 Wait(base::TimeDelta::FromSeconds(30)); |
| 154 | 153 |
| 155 // Wait for 10 seconds to make sure route has been stopped. | 154 // Wait for 10 seconds to make sure route has been stopped. |
| 156 StopMediaRoute(); | 155 StopMediaRoute(); |
| 157 Wait(base::TimeDelta::FromSeconds(10)); | 156 Wait(base::TimeDelta::FromSeconds(10)); |
| 158 } | 157 } |
| 159 | 158 |
| 160 IN_PROC_BROWSER_TEST_F(MediaRouterE2EBrowserTest, MANUAL_CastApp) { | 159 IN_PROC_BROWSER_TEST_F(MediaRouterE2EBrowserTest, MANUAL_CastApp) { |
| 161 // Wait for 30 seconds to make sure the route is stable. | 160 // Wait for 30 seconds to make sure the route is stable. |
| 162 CreateMediaRoute(MediaSourceForPresentationUrl(kCastAppPresentationUrl), | 161 CreateMediaRoute(MediaSourceForPresentationUrl(kCastAppPresentationUrl, |
| 163 GURL(kOriginUrl), nullptr); | 162 kOriginUrl), |
| 163 nullptr); |
| 164 Wait(base::TimeDelta::FromSeconds(30)); | 164 Wait(base::TimeDelta::FromSeconds(30)); |
| 165 | 165 |
| 166 // Wait for 10 seconds to make sure route has been stopped. | 166 // Wait for 10 seconds to make sure route has been stopped. |
| 167 StopMediaRoute(); | 167 StopMediaRoute(); |
| 168 Wait(base::TimeDelta::FromSeconds(10)); | 168 Wait(base::TimeDelta::FromSeconds(10)); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace media_router | 171 } // namespace media_router |
| OLD | NEW |