| 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 468 |
| 469 EXPECT_EQ("", MediaRouterUI::GetExtensionName(url, registry.get())); | 469 EXPECT_EQ("", MediaRouterUI::GetExtensionName(url, registry.get())); |
| 470 } | 470 } |
| 471 | 471 |
| 472 TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoSinks) { | 472 TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoSinks) { |
| 473 content::PresentationError expected_error( | 473 content::PresentationError expected_error( |
| 474 content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, | 474 content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, |
| 475 "No screens found."); | 475 "No screens found."); |
| 476 PresentationRequestCallbacks request_callbacks(expected_error); | 476 PresentationRequestCallbacks request_callbacks(expected_error); |
| 477 create_session_request_.reset(new CreatePresentationConnectionRequest( | 477 create_session_request_.reset(new CreatePresentationConnectionRequest( |
| 478 RenderFrameHostId(0, 0), GURL("http://google.com/presentation"), | 478 RenderFrameHostId(0, 0), {GURL("http://google.com/presentation"), |
| 479 GURL("http://google.com/presentation2")}, |
| 479 GURL("http://google.com"), | 480 GURL("http://google.com"), |
| 480 base::Bind(&PresentationRequestCallbacks::Success, | 481 base::Bind(&PresentationRequestCallbacks::Success, |
| 481 base::Unretained(&request_callbacks)), | 482 base::Unretained(&request_callbacks)), |
| 482 base::Bind(&PresentationRequestCallbacks::Error, | 483 base::Bind(&PresentationRequestCallbacks::Error, |
| 483 base::Unretained(&request_callbacks)))); | 484 base::Unretained(&request_callbacks)))); |
| 484 CreateMediaRouterUI(profile()); | 485 CreateMediaRouterUI(profile()); |
| 485 // Destroying the UI should return the expected error from above to the error | 486 // Destroying the UI should return the expected error from above to the error |
| 486 // callback. | 487 // callback. |
| 487 media_router_ui_.reset(); | 488 media_router_ui_.reset(); |
| 488 } | 489 } |
| 489 | 490 |
| 490 TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoCompatibleSinks) { | 491 TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoCompatibleSinks) { |
| 491 content::PresentationError expected_error( | 492 content::PresentationError expected_error( |
| 492 content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, | 493 content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, |
| 493 "No screens found."); | 494 "No screens found."); |
| 494 PresentationRequestCallbacks request_callbacks(expected_error); | 495 PresentationRequestCallbacks request_callbacks(expected_error); |
| 495 GURL presentation_url("http://google.com/presentation"); | 496 GURL presentation_url("http://google.com/presentation"); |
| 496 create_session_request_.reset(new CreatePresentationConnectionRequest( | 497 create_session_request_.reset(new CreatePresentationConnectionRequest( |
| 497 RenderFrameHostId(0, 0), presentation_url, GURL("http://google.com"), | 498 RenderFrameHostId(0, 0), {presentation_url}, GURL("http://google.com"), |
| 498 base::Bind(&PresentationRequestCallbacks::Success, | 499 base::Bind(&PresentationRequestCallbacks::Success, |
| 499 base::Unretained(&request_callbacks)), | 500 base::Unretained(&request_callbacks)), |
| 500 base::Bind(&PresentationRequestCallbacks::Error, | 501 base::Bind(&PresentationRequestCallbacks::Error, |
| 501 base::Unretained(&request_callbacks)))); | 502 base::Unretained(&request_callbacks)))); |
| 502 CreateMediaRouterUI(profile()); | 503 CreateMediaRouterUI(profile()); |
| 503 | 504 |
| 504 // Send a sink to the UI that is compatible with sources other than the | 505 // Send a sink to the UI that is compatible with sources other than the |
| 505 // presentation url to cause a NotFoundError. | 506 // presentation url to cause a NotFoundError. |
| 506 std::vector<MediaSink> sinks; | 507 std::vector<MediaSink> sinks; |
| 507 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC); | 508 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC); |
| 508 std::vector<GURL> origins; | 509 std::vector<GURL> origins; |
| 509 for (auto* observer : media_sinks_observers_) { | 510 for (auto* observer : media_sinks_observers_) { |
| 510 if (observer->source().id() != presentation_url.spec()) { | 511 if (observer->source().id() != presentation_url.spec()) { |
| 511 observer->OnSinksUpdated(sinks, origins); | 512 observer->OnSinksUpdated(sinks, origins); |
| 512 } | 513 } |
| 513 } | 514 } |
| 514 // Destroying the UI should return the expected error from above to the error | 515 // Destroying the UI should return the expected error from above to the error |
| 515 // callback. | 516 // callback. |
| 516 media_router_ui_.reset(); | 517 media_router_ui_.reset(); |
| 517 } | 518 } |
| 518 | 519 |
| 519 TEST_F(MediaRouterUITest, AbortErrorOnClose) { | 520 TEST_F(MediaRouterUITest, AbortErrorOnClose) { |
| 520 content::PresentationError expected_error( | 521 content::PresentationError expected_error( |
| 521 content::PresentationErrorType:: | 522 content::PresentationErrorType:: |
| 522 PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, | 523 PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, |
| 523 "Dialog closed."); | 524 "Dialog closed."); |
| 524 PresentationRequestCallbacks request_callbacks(expected_error); | 525 PresentationRequestCallbacks request_callbacks(expected_error); |
| 525 GURL presentation_url("http://google.com/presentation"); | 526 GURL presentation_url("http://google.com/presentation"); |
| 526 create_session_request_.reset(new CreatePresentationConnectionRequest( | 527 create_session_request_.reset(new CreatePresentationConnectionRequest( |
| 527 RenderFrameHostId(0, 0), presentation_url, GURL("http://google.com"), | 528 RenderFrameHostId(0, 0), {presentation_url}, GURL("http://google.com"), |
| 528 base::Bind(&PresentationRequestCallbacks::Success, | 529 base::Bind(&PresentationRequestCallbacks::Success, |
| 529 base::Unretained(&request_callbacks)), | 530 base::Unretained(&request_callbacks)), |
| 530 base::Bind(&PresentationRequestCallbacks::Error, | 531 base::Bind(&PresentationRequestCallbacks::Error, |
| 531 base::Unretained(&request_callbacks)))); | 532 base::Unretained(&request_callbacks)))); |
| 532 CreateMediaRouterUI(profile()); | 533 CreateMediaRouterUI(profile()); |
| 533 | 534 |
| 534 // Send a sink to the UI that is compatible with the presentation url to avoid | 535 // Send a sink to the UI that is compatible with the presentation url to avoid |
| 535 // a NotFoundError. | 536 // a NotFoundError. |
| 536 std::vector<MediaSink> sinks; | 537 std::vector<MediaSink> sinks; |
| 537 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC); | 538 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 // Selecting desktop mirroring should not change the recorded preferences. | 586 // Selecting desktop mirroring should not change the recorded preferences. |
| 586 EXPECT_FALSE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); | 587 EXPECT_FALSE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); |
| 587 | 588 |
| 588 media_router_ui_->RecordCastModeSelection(MediaCastMode::TAB_MIRROR); | 589 media_router_ui_->RecordCastModeSelection(MediaCastMode::TAB_MIRROR); |
| 589 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); | 590 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); |
| 590 media_router_ui_->RecordCastModeSelection(MediaCastMode::DESKTOP_MIRROR); | 591 media_router_ui_->RecordCastModeSelection(MediaCastMode::DESKTOP_MIRROR); |
| 591 // Selecting desktop mirroring should not change the recorded preferences. | 592 // Selecting desktop mirroring should not change the recorded preferences. |
| 592 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); | 593 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); |
| 593 } | 594 } |
| 594 } // namespace media_router | 595 } // namespace media_router |
| OLD | NEW |