| 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 27 matching lines...) Expand all Loading... |
| 38 using testing::SaveArg; | 38 using testing::SaveArg; |
| 39 | 39 |
| 40 namespace media_router { | 40 namespace media_router { |
| 41 | 41 |
| 42 class PresentationRequestCallbacks { | 42 class PresentationRequestCallbacks { |
| 43 public: | 43 public: |
| 44 explicit PresentationRequestCallbacks( | 44 explicit PresentationRequestCallbacks( |
| 45 const content::PresentationError& expected_error) | 45 const content::PresentationError& expected_error) |
| 46 : expected_error_(expected_error) {} | 46 : expected_error_(expected_error) {} |
| 47 | 47 |
| 48 void Success(const content::PresentationSessionInfo&, const MediaRoute&) {} | 48 void Success(const content::PresentationInfo&, const MediaRoute&) {} |
| 49 | 49 |
| 50 void Error(const content::PresentationError& error) { | 50 void Error(const content::PresentationError& error) { |
| 51 EXPECT_EQ(expected_error_.error_type, error.error_type); | 51 EXPECT_EQ(expected_error_.error_type, error.error_type); |
| 52 EXPECT_EQ(expected_error_.message, error.message); | 52 EXPECT_EQ(expected_error_.message, error.message); |
| 53 } | 53 } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 content::PresentationError expected_error_; | 56 content::PresentationError expected_error_; |
| 57 }; | 57 }; |
| 58 | 58 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 } | 505 } |
| 506 } | 506 } |
| 507 // Destroying the UI should return the expected error from above to the error | 507 // Destroying the UI should return the expected error from above to the error |
| 508 // callback. | 508 // callback. |
| 509 media_router_ui_.reset(); | 509 media_router_ui_.reset(); |
| 510 } | 510 } |
| 511 | 511 |
| 512 TEST_F(MediaRouterUITest, AbortErrorOnClose) { | 512 TEST_F(MediaRouterUITest, AbortErrorOnClose) { |
| 513 content::PresentationError expected_error( | 513 content::PresentationError expected_error( |
| 514 content::PresentationErrorType:: | 514 content::PresentationErrorType:: |
| 515 PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, | 515 PRESENTATION_ERROR_PRESENTATION_REQUEST_CANCELLED, |
| 516 "Dialog closed."); | 516 "Dialog closed."); |
| 517 PresentationRequestCallbacks request_callbacks(expected_error); | 517 PresentationRequestCallbacks request_callbacks(expected_error); |
| 518 GURL presentation_url("http://google.com/presentation"); | 518 GURL presentation_url("http://google.com/presentation"); |
| 519 create_session_request_.reset(new CreatePresentationConnectionRequest( | 519 create_session_request_.reset(new CreatePresentationConnectionRequest( |
| 520 RenderFrameHostId(0, 0), {presentation_url}, | 520 RenderFrameHostId(0, 0), {presentation_url}, |
| 521 url::Origin(GURL("http://google.com")), | 521 url::Origin(GURL("http://google.com")), |
| 522 base::Bind(&PresentationRequestCallbacks::Success, | 522 base::Bind(&PresentationRequestCallbacks::Success, |
| 523 base::Unretained(&request_callbacks)), | 523 base::Unretained(&request_callbacks)), |
| 524 base::Bind(&PresentationRequestCallbacks::Error, | 524 base::Bind(&PresentationRequestCallbacks::Error, |
| 525 base::Unretained(&request_callbacks)))); | 525 base::Unretained(&request_callbacks)))); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 EXPECT_FALSE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); | 594 EXPECT_FALSE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); |
| 595 | 595 |
| 596 media_router_ui_->RecordCastModeSelection(MediaCastMode::TAB_MIRROR); | 596 media_router_ui_->RecordCastModeSelection(MediaCastMode::TAB_MIRROR); |
| 597 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); | 597 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); |
| 598 media_router_ui_->RecordCastModeSelection(MediaCastMode::DESKTOP_MIRROR); | 598 media_router_ui_->RecordCastModeSelection(MediaCastMode::DESKTOP_MIRROR); |
| 599 // Selecting desktop mirroring should not change the recorded preferences. | 599 // Selecting desktop mirroring should not change the recorded preferences. |
| 600 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); | 600 EXPECT_TRUE(media_router_ui_->UserSelectedTabMirroringForCurrentOrigin()); |
| 601 } | 601 } |
| 602 | 602 |
| 603 } // namespace media_router | 603 } // namespace media_router |
| OLD | NEW |