| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/media/router/create_presentation_connection_request.h" | 10 #include "chrome/browser/media/router/create_presentation_connection_request.h" |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 EXPECT_EQ(MediaCastMode::DESKTOP_MIRROR, cast_mode_entry->second); | 395 EXPECT_EQ(MediaCastMode::DESKTOP_MIRROR, cast_mode_entry->second); |
| 396 | 396 |
| 397 EXPECT_CALL(mock_router_, UnregisterMediaRoutesObserver(_)).Times(1); | 397 EXPECT_CALL(mock_router_, UnregisterMediaRoutesObserver(_)).Times(1); |
| 398 observer.reset(); | 398 observer.reset(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 TEST_F(MediaRouterUITest, GetExtensionNameExtensionPresent) { | 401 TEST_F(MediaRouterUITest, GetExtensionNameExtensionPresent) { |
| 402 std::string id = "extensionid"; | 402 std::string id = "extensionid"; |
| 403 GURL url = GURL("chrome-extension://" + id); | 403 GURL url = GURL("chrome-extension://" + id); |
| 404 std::unique_ptr<extensions::ExtensionRegistry> registry = | 404 std::unique_ptr<extensions::ExtensionRegistry> registry = |
| 405 base::WrapUnique(new extensions::ExtensionRegistry(nullptr)); | 405 base::MakeUnique<extensions::ExtensionRegistry>(nullptr); |
| 406 scoped_refptr<extensions::Extension> app = | 406 scoped_refptr<extensions::Extension> app = |
| 407 extensions::test_util::BuildApp(extensions::ExtensionBuilder()) | 407 extensions::test_util::BuildApp(extensions::ExtensionBuilder()) |
| 408 .MergeManifest(extensions::DictionaryBuilder() | 408 .MergeManifest(extensions::DictionaryBuilder() |
| 409 .Set("name", "test app name") | 409 .Set("name", "test app name") |
| 410 .Build()) | 410 .Build()) |
| 411 .SetID(id) | 411 .SetID(id) |
| 412 .Build(); | 412 .Build(); |
| 413 | 413 |
| 414 ASSERT_TRUE(registry->AddEnabled(app)); | 414 ASSERT_TRUE(registry->AddEnabled(app)); |
| 415 EXPECT_EQ("test app name", | 415 EXPECT_EQ("test app name", |
| 416 MediaRouterUI::GetExtensionName(url, registry.get())); | 416 MediaRouterUI::GetExtensionName(url, registry.get())); |
| 417 } | 417 } |
| 418 | 418 |
| 419 TEST_F(MediaRouterUITest, GetExtensionNameEmptyWhenNotInstalled) { | 419 TEST_F(MediaRouterUITest, GetExtensionNameEmptyWhenNotInstalled) { |
| 420 std::string id = "extensionid"; | 420 std::string id = "extensionid"; |
| 421 GURL url = GURL("chrome-extension://" + id); | 421 GURL url = GURL("chrome-extension://" + id); |
| 422 std::unique_ptr<extensions::ExtensionRegistry> registry = | 422 std::unique_ptr<extensions::ExtensionRegistry> registry = |
| 423 base::WrapUnique(new extensions::ExtensionRegistry(nullptr)); | 423 base::MakeUnique<extensions::ExtensionRegistry>(nullptr); |
| 424 | 424 |
| 425 EXPECT_EQ("", MediaRouterUI::GetExtensionName(url, registry.get())); | 425 EXPECT_EQ("", MediaRouterUI::GetExtensionName(url, registry.get())); |
| 426 } | 426 } |
| 427 | 427 |
| 428 TEST_F(MediaRouterUITest, GetExtensionNameEmptyWhenNotExtensionURL) { | 428 TEST_F(MediaRouterUITest, GetExtensionNameEmptyWhenNotExtensionURL) { |
| 429 GURL url = GURL("https://www.google.com"); | 429 GURL url = GURL("https://www.google.com"); |
| 430 std::unique_ptr<extensions::ExtensionRegistry> registry = | 430 std::unique_ptr<extensions::ExtensionRegistry> registry = |
| 431 base::WrapUnique(new extensions::ExtensionRegistry(nullptr)); | 431 base::MakeUnique<extensions::ExtensionRegistry>(nullptr); |
| 432 | 432 |
| 433 EXPECT_EQ("", MediaRouterUI::GetExtensionName(url, registry.get())); | 433 EXPECT_EQ("", MediaRouterUI::GetExtensionName(url, registry.get())); |
| 434 } | 434 } |
| 435 | 435 |
| 436 TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoSinks) { | 436 TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoSinks) { |
| 437 content::PresentationError expected_error( | 437 content::PresentationError expected_error( |
| 438 content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, | 438 content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, |
| 439 "No screens found."); | 439 "No screens found."); |
| 440 PresentationRequestCallbacks request_callbacks(expected_error); | 440 PresentationRequestCallbacks request_callbacks(expected_error); |
| 441 create_session_request_.reset(new CreatePresentationConnectionRequest( | 441 create_session_request_.reset(new CreatePresentationConnectionRequest( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 for (auto* observer : media_sinks_observers_) { | 503 for (auto* observer : media_sinks_observers_) { |
| 504 if (observer->source().id() == presentation_url) { | 504 if (observer->source().id() == presentation_url) { |
| 505 observer->OnSinksUpdated(sinks, origins); | 505 observer->OnSinksUpdated(sinks, origins); |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 // Destroying the UI should return the expected error from above to the error | 508 // Destroying the UI should return the expected error from above to the error |
| 509 // callback. | 509 // callback. |
| 510 media_router_ui_.reset(); | 510 media_router_ui_.reset(); |
| 511 } | 511 } |
| 512 } // namespace media_router | 512 } // namespace media_router |
| OLD | NEW |