Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc

Issue 2627463003: Convert MediaRouter mojom apis to intake url::Origin objects instead of strings (Closed)
Patch Set: Fix chromeos browser tests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 .Times(AnyNumber()); 107 .Times(AnyNumber());
108 media_router_ui_->InitForTest(&mock_router_, web_contents(), 108 media_router_ui_->InitForTest(&mock_router_, web_contents(),
109 message_handler_.get(), 109 message_handler_.get(),
110 std::move(create_session_request_)); 110 std::move(create_session_request_));
111 message_handler_->SetWebUIForTest(&web_ui_); 111 message_handler_->SetWebUIForTest(&web_ui_);
112 } 112 }
113 113
114 MediaSink CreateSinkCompatibleWithAllSources() { 114 MediaSink CreateSinkCompatibleWithAllSources() {
115 MediaSink sink("sinkId", "sinkName", MediaSink::GENERIC); 115 MediaSink sink("sinkId", "sinkName", MediaSink::GENERIC);
116 for (auto* observer : media_sinks_observers_) 116 for (auto* observer : media_sinks_observers_)
117 observer->OnSinksUpdated({sink}, std::vector<GURL>()); 117 observer->OnSinksUpdated({sink}, std::vector<url::Origin>());
118 return sink; 118 return sink;
119 } 119 }
120 120
121 protected: 121 protected:
122 MockMediaRouter mock_router_; 122 MockMediaRouter mock_router_;
123 content::TestWebUI web_ui_; 123 content::TestWebUI web_ui_;
124 std::unique_ptr<WebContents> web_ui_contents_; 124 std::unique_ptr<WebContents> web_ui_contents_;
125 std::unique_ptr<CreatePresentationConnectionRequest> create_session_request_; 125 std::unique_ptr<CreatePresentationConnectionRequest> create_session_request_;
126 std::unique_ptr<MediaRouterUI> media_router_ui_; 126 std::unique_ptr<MediaRouterUI> media_router_ui_;
127 std::unique_ptr<MediaRouterWebUIMessageHandler> message_handler_; 127 std::unique_ptr<MediaRouterWebUIMessageHandler> message_handler_;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 base::Bind(&PresentationRequestCallbacks::Success, 499 base::Bind(&PresentationRequestCallbacks::Success,
500 base::Unretained(&request_callbacks)), 500 base::Unretained(&request_callbacks)),
501 base::Bind(&PresentationRequestCallbacks::Error, 501 base::Bind(&PresentationRequestCallbacks::Error,
502 base::Unretained(&request_callbacks)))); 502 base::Unretained(&request_callbacks))));
503 CreateMediaRouterUI(profile()); 503 CreateMediaRouterUI(profile());
504 504
505 // 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
506 // presentation url to cause a NotFoundError. 506 // presentation url to cause a NotFoundError.
507 std::vector<MediaSink> sinks; 507 std::vector<MediaSink> sinks;
508 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC); 508 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC);
509 std::vector<GURL> origins; 509 std::vector<url::Origin> origins;
510 for (auto* observer : media_sinks_observers_) { 510 for (auto* observer : media_sinks_observers_) {
511 if (observer->source().id() != presentation_url.spec()) { 511 if (observer->source().id() != presentation_url.spec()) {
512 observer->OnSinksUpdated(sinks, origins); 512 observer->OnSinksUpdated(sinks, origins);
513 } 513 }
514 } 514 }
515 // 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
516 // callback. 516 // callback.
517 media_router_ui_.reset(); 517 media_router_ui_.reset();
518 } 518 }
519 519
520 TEST_F(MediaRouterUITest, AbortErrorOnClose) { 520 TEST_F(MediaRouterUITest, AbortErrorOnClose) {
521 content::PresentationError expected_error( 521 content::PresentationError expected_error(
522 content::PresentationErrorType:: 522 content::PresentationErrorType::
523 PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, 523 PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED,
524 "Dialog closed."); 524 "Dialog closed.");
525 PresentationRequestCallbacks request_callbacks(expected_error); 525 PresentationRequestCallbacks request_callbacks(expected_error);
526 GURL presentation_url("http://google.com/presentation"); 526 GURL presentation_url("http://google.com/presentation");
527 create_session_request_.reset(new CreatePresentationConnectionRequest( 527 create_session_request_.reset(new CreatePresentationConnectionRequest(
528 RenderFrameHostId(0, 0), {presentation_url}, GURL("http://google.com"), 528 RenderFrameHostId(0, 0), {presentation_url}, GURL("http://google.com"),
529 base::Bind(&PresentationRequestCallbacks::Success, 529 base::Bind(&PresentationRequestCallbacks::Success,
530 base::Unretained(&request_callbacks)), 530 base::Unretained(&request_callbacks)),
531 base::Bind(&PresentationRequestCallbacks::Error, 531 base::Bind(&PresentationRequestCallbacks::Error,
532 base::Unretained(&request_callbacks)))); 532 base::Unretained(&request_callbacks))));
533 CreateMediaRouterUI(profile()); 533 CreateMediaRouterUI(profile());
534 534
535 // 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
536 // a NotFoundError. 536 // a NotFoundError.
537 std::vector<MediaSink> sinks; 537 std::vector<MediaSink> sinks;
538 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC); 538 sinks.emplace_back("sink id", "sink name", MediaSink::GENERIC);
539 std::vector<GURL> origins; 539 std::vector<url::Origin> origins;
540 MediaSource::Id presentation_source_id = 540 MediaSource::Id presentation_source_id =
541 MediaSourceForPresentationUrl(presentation_url).id(); 541 MediaSourceForPresentationUrl(presentation_url).id();
542 for (auto* observer : media_sinks_observers_) { 542 for (auto* observer : media_sinks_observers_) {
543 if (observer->source().id() == presentation_source_id) { 543 if (observer->source().id() == presentation_source_id) {
544 observer->OnSinksUpdated(sinks, origins); 544 observer->OnSinksUpdated(sinks, origins);
545 } 545 }
546 } 546 }
547 // Destroying the UI should return the expected error from above to the error 547 // Destroying the UI should return the expected error from above to the error
548 // callback. 548 // callback.
549 media_router_ui_.reset(); 549 media_router_ui_.reset();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 EXPECT_FALSE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); 601 EXPECT_FALSE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin());
602 602
603 media_router_ui_->RecordCastModeSelection(MediaCastMode::TAB_MIRROR); 603 media_router_ui_->RecordCastModeSelection(MediaCastMode::TAB_MIRROR);
604 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); 604 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin());
605 media_router_ui_->RecordCastModeSelection(MediaCastMode::DESKTOP_MIRROR); 605 media_router_ui_->RecordCastModeSelection(MediaCastMode::DESKTOP_MIRROR);
606 // Selecting desktop mirroring should not change the recorded preferences. 606 // Selecting desktop mirroring should not change the recorded preferences.
607 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); 607 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin());
608 } 608 }
609 609
610 } // namespace media_router 610 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698