| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "chrome/browser/media/router/create_presentation_session_request.h" | 6 #include "chrome/browser/media/router/create_presentation_session_request.h" |
| 7 #include "chrome/browser/media/router/media_source_helper.h" | 7 #include "chrome/browser/media/router/media_source_helper.h" |
| 8 #include "content/public/browser/presentation_service_delegate.h" | 8 #include "content/public/browser/presentation_service_delegate.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 TEST_F(CreatePresentationSessionRequestTest, SuccessCallback) { | 79 TEST_F(CreatePresentationSessionRequestTest, SuccessCallback) { |
| 80 GURL frame_url("http://frameUrl"); | 80 GURL frame_url("http://frameUrl"); |
| 81 content::PresentationSessionInfo session_info(kPresentationUrl, | 81 content::PresentationSessionInfo session_info(kPresentationUrl, |
| 82 kPresentationId); | 82 kPresentationId); |
| 83 CreatePresentationSessionRequest context( | 83 CreatePresentationSessionRequest context( |
| 84 kPresentationUrl, kPresentationId, frame_url, | 84 kPresentationUrl, kPresentationId, frame_url, |
| 85 base::Bind(&CreatePresentationSessionRequestTest::OnSuccess, | 85 base::Bind(&CreatePresentationSessionRequestTest::OnSuccess, |
| 86 base::Unretained(this), session_info), | 86 base::Unretained(this), session_info), |
| 87 base::Bind(&CreatePresentationSessionRequestTest::FailOnError, | 87 base::Bind(&CreatePresentationSessionRequestTest::FailOnError, |
| 88 base::Unretained(this))); | 88 base::Unretained(this))); |
| 89 context.MaybeInvokeSuccessCallback(kRouteId); | 89 context.MaybeInvokeSuccessCallback(kPresentationId, kRouteId); |
| 90 // No-op since success callback is already invoked. | 90 // No-op since success callback is already invoked. |
| 91 context.MaybeInvokeErrorCallback(content::PresentationError( | 91 context.MaybeInvokeErrorCallback(content::PresentationError( |
| 92 content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, "Error message")); | 92 content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, "Error message")); |
| 93 EXPECT_TRUE(cb_invoked_); | 93 EXPECT_TRUE(cb_invoked_); |
| 94 } | 94 } |
| 95 | 95 |
| 96 TEST_F(CreatePresentationSessionRequestTest, ErrorCallback) { | 96 TEST_F(CreatePresentationSessionRequestTest, ErrorCallback) { |
| 97 GURL frame_url("http://frameUrl"); | 97 GURL frame_url("http://frameUrl"); |
| 98 content::PresentationSessionInfo session_info(kPresentationUrl, | 98 content::PresentationSessionInfo session_info(kPresentationUrl, |
| 99 kPresentationId); | 99 kPresentationId); |
| 100 content::PresentationError error( | 100 content::PresentationError error( |
| 101 content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, | 101 content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, |
| 102 "This is an error message"); | 102 "This is an error message"); |
| 103 CreatePresentationSessionRequest context( | 103 CreatePresentationSessionRequest context( |
| 104 kPresentationUrl, kPresentationId, frame_url, | 104 kPresentationUrl, kPresentationId, frame_url, |
| 105 base::Bind(&CreatePresentationSessionRequestTest::FailOnSuccess, | 105 base::Bind(&CreatePresentationSessionRequestTest::FailOnSuccess, |
| 106 base::Unretained(this)), | 106 base::Unretained(this)), |
| 107 base::Bind(&CreatePresentationSessionRequestTest::OnError, | 107 base::Bind(&CreatePresentationSessionRequestTest::OnError, |
| 108 base::Unretained(this), error)); | 108 base::Unretained(this), error)); |
| 109 context.MaybeInvokeErrorCallback(error); | 109 context.MaybeInvokeErrorCallback(error); |
| 110 // No-op since error callback is already invoked. | 110 // No-op since error callback is already invoked. |
| 111 context.MaybeInvokeSuccessCallback(kRouteId); | 111 context.MaybeInvokeSuccessCallback(kPresentationId, kRouteId); |
| 112 EXPECT_TRUE(cb_invoked_); | 112 EXPECT_TRUE(cb_invoked_); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace media_router | 115 } // namespace media_router |
| OLD | NEW |