Chromium Code Reviews| 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/browser/ui/webui/media_router/media_router_ui.h" | 5 #include "chrome/browser/ui/webui/media_router/media_router_ui.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 | 480 |
| 481 EXPECT_EQ("", MediaRouterUI::GetExtensionName(url, registry.get())); | 481 EXPECT_EQ("", MediaRouterUI::GetExtensionName(url, registry.get())); |
| 482 } | 482 } |
| 483 | 483 |
| 484 TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoSinks) { | 484 TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoSinks) { |
| 485 content::PresentationError expected_error( | 485 content::PresentationError expected_error( |
| 486 content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, | 486 content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, |
| 487 "No screens found."); | 487 "No screens found."); |
| 488 PresentationRequestCallbacks request_callbacks(expected_error); | 488 PresentationRequestCallbacks request_callbacks(expected_error); |
| 489 create_session_request_.reset(new CreatePresentationConnectionRequest( | 489 create_session_request_.reset(new CreatePresentationConnectionRequest( |
| 490 RenderFrameHostId(0, 0), GURL("http://google.com/presentation"), | 490 RenderFrameHostId(0, 0), {GURL("http://google.com/presentation")}, |
|
mark a. foltz
2016/12/02 20:59:09
It would be good to update test cases to take mult
zhaobin
2016/12/02 22:50:57
Done.
| |
| 491 GURL("http://google.com"), | 491 GURL("http://google.com"), |
| 492 base::Bind(&PresentationRequestCallbacks::Success, | 492 base::Bind(&PresentationRequestCallbacks::Success, |
| 493 base::Unretained(&request_callbacks)), | 493 base::Unretained(&request_callbacks)), |
| 494 base::Bind(&PresentationRequestCallbacks::Error, | 494 base::Bind(&PresentationRequestCallbacks::Error, |
| 495 base::Unretained(&request_callbacks)))); | 495 base::Unretained(&request_callbacks)))); |
| 496 CreateMediaRouterUI(&profile_); | 496 CreateMediaRouterUI(&profile_); |
| 497 // Destroying the UI should return the expected error from above to the error | 497 // Destroying the UI should return the expected error from above to the error |
| 498 // callback. | 498 // callback. |
| 499 media_router_ui_.reset(); | 499 media_router_ui_.reset(); |
| 500 } | 500 } |
| 501 | 501 |
| 502 TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoCompatibleSinks) { | 502 TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoCompatibleSinks) { |
| 503 content::PresentationError expected_error( | 503 content::PresentationError expected_error( |
| 504 content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, | 504 content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, |
| 505 "No screens found."); | 505 "No screens found."); |
| 506 PresentationRequestCallbacks request_callbacks(expected_error); | 506 PresentationRequestCallbacks request_callbacks(expected_error); |
| 507 GURL presentation_url("http://google.com/presentation"); | 507 GURL presentation_url("http://google.com/presentation"); |
| 508 create_session_request_.reset(new CreatePresentationConnectionRequest( | 508 create_session_request_.reset(new CreatePresentationConnectionRequest( |
| 509 RenderFrameHostId(0, 0), presentation_url, GURL("http://google.com"), | 509 RenderFrameHostId(0, 0), {presentation_url}, GURL("http://google.com"), |
| 510 base::Bind(&PresentationRequestCallbacks::Success, | 510 base::Bind(&PresentationRequestCallbacks::Success, |
| 511 base::Unretained(&request_callbacks)), | 511 base::Unretained(&request_callbacks)), |
| 512 base::Bind(&PresentationRequestCallbacks::Error, | 512 base::Bind(&PresentationRequestCallbacks::Error, |
| 513 base::Unretained(&request_callbacks)))); | 513 base::Unretained(&request_callbacks)))); |
| 514 CreateMediaRouterUI(&profile_); | 514 CreateMediaRouterUI(&profile_); |
| 515 | 515 |
| 516 // Send a sink to the UI that is compatible with sources other than the | 516 // Send a sink to the UI that is compatible with sources other than the |
| 517 // presentation url to cause a NotFoundError. | 517 // presentation url to cause a NotFoundError. |
| 518 std::vector<MediaSink> sinks; | 518 std::vector<MediaSink> sinks; |
| 519 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC); | 519 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC); |
| 520 std::vector<GURL> origins; | 520 std::vector<GURL> origins; |
| 521 for (auto* observer : media_sinks_observers_) { | 521 for (auto* observer : media_sinks_observers_) { |
| 522 if (observer->source().id() != presentation_url.spec()) { | 522 if (observer->source().id() != presentation_url.spec()) { |
| 523 observer->OnSinksUpdated(sinks, origins); | 523 observer->OnSinksUpdated(sinks, origins); |
| 524 } | 524 } |
| 525 } | 525 } |
| 526 // Destroying the UI should return the expected error from above to the error | 526 // Destroying the UI should return the expected error from above to the error |
| 527 // callback. | 527 // callback. |
| 528 media_router_ui_.reset(); | 528 media_router_ui_.reset(); |
| 529 } | 529 } |
| 530 | 530 |
| 531 TEST_F(MediaRouterUITest, AbortErrorOnClose) { | 531 TEST_F(MediaRouterUITest, AbortErrorOnClose) { |
| 532 content::PresentationError expected_error( | 532 content::PresentationError expected_error( |
| 533 content::PresentationErrorType:: | 533 content::PresentationErrorType:: |
| 534 PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, | 534 PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, |
| 535 "Dialog closed."); | 535 "Dialog closed."); |
| 536 PresentationRequestCallbacks request_callbacks(expected_error); | 536 PresentationRequestCallbacks request_callbacks(expected_error); |
| 537 GURL presentation_url("http://google.com/presentation"); | 537 GURL presentation_url("http://google.com/presentation"); |
| 538 create_session_request_.reset(new CreatePresentationConnectionRequest( | 538 create_session_request_.reset(new CreatePresentationConnectionRequest( |
| 539 RenderFrameHostId(0, 0), presentation_url, GURL("http://google.com"), | 539 RenderFrameHostId(0, 0), {presentation_url}, GURL("http://google.com"), |
| 540 base::Bind(&PresentationRequestCallbacks::Success, | 540 base::Bind(&PresentationRequestCallbacks::Success, |
| 541 base::Unretained(&request_callbacks)), | 541 base::Unretained(&request_callbacks)), |
| 542 base::Bind(&PresentationRequestCallbacks::Error, | 542 base::Bind(&PresentationRequestCallbacks::Error, |
| 543 base::Unretained(&request_callbacks)))); | 543 base::Unretained(&request_callbacks)))); |
| 544 CreateMediaRouterUI(&profile_); | 544 CreateMediaRouterUI(&profile_); |
| 545 | 545 |
| 546 // Send a sink to the UI that is compatible with the presentation url to avoid | 546 // Send a sink to the UI that is compatible with the presentation url to avoid |
| 547 // a NotFoundError. | 547 // a NotFoundError. |
| 548 std::vector<MediaSink> sinks; | 548 std::vector<MediaSink> sinks; |
| 549 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC); | 549 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC); |
| 550 std::vector<GURL> origins; | 550 std::vector<GURL> origins; |
| 551 MediaSource::Id presentation_source_id = | 551 MediaSource::Id presentation_source_id = |
| 552 MediaSourceForPresentationUrl(presentation_url).id(); | 552 MediaSourceForPresentationUrl(presentation_url).id(); |
| 553 for (auto* observer : media_sinks_observers_) { | 553 for (auto* observer : media_sinks_observers_) { |
| 554 if (observer->source().id() == presentation_source_id) { | 554 if (observer->source().id() == presentation_source_id) { |
| 555 observer->OnSinksUpdated(sinks, origins); | 555 observer->OnSinksUpdated(sinks, origins); |
| 556 } | 556 } |
| 557 } | 557 } |
| 558 // Destroying the UI should return the expected error from above to the error | 558 // Destroying the UI should return the expected error from above to the error |
| 559 // callback. | 559 // callback. |
| 560 media_router_ui_.reset(); | 560 media_router_ui_.reset(); |
| 561 } | 561 } |
| 562 } // namespace media_router | 562 } // namespace media_router |
| OLD | NEW |