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_connection_request.h" | 6 #include "chrome/browser/media/router/create_presentation_connection_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 14 matching lines...) Expand all Loading... |
25 CreatePresentationConnectionRequestTest() | 25 CreatePresentationConnectionRequestTest() |
26 : cb_invoked_(false), | 26 : cb_invoked_(false), |
27 render_frame_host_id_(1, 2), | 27 render_frame_host_id_(1, 2), |
28 presentation_url_(kPresentationUrl), | 28 presentation_url_(kPresentationUrl), |
29 presentation_urls_({presentation_url_}) {} | 29 presentation_urls_({presentation_url_}) {} |
30 | 30 |
31 ~CreatePresentationConnectionRequestTest() override {} | 31 ~CreatePresentationConnectionRequestTest() override {} |
32 | 32 |
33 void OnSuccess(const content::PresentationSessionInfo& expected_info, | 33 void OnSuccess(const content::PresentationSessionInfo& expected_info, |
34 const content::PresentationSessionInfo& actual_info, | 34 const content::PresentationSessionInfo& actual_info, |
35 const MediaRoute::Id& route_id) { | 35 const MediaRoute& route) { |
36 cb_invoked_ = true; | 36 cb_invoked_ = true; |
37 EXPECT_EQ(expected_info.presentation_url, actual_info.presentation_url); | 37 EXPECT_EQ(expected_info.presentation_url, actual_info.presentation_url); |
38 EXPECT_EQ(expected_info.presentation_id, actual_info.presentation_id); | 38 EXPECT_EQ(expected_info.presentation_id, actual_info.presentation_id); |
39 } | 39 } |
40 | 40 |
41 void OnError(const content::PresentationError& expected_error, | 41 void OnError(const content::PresentationError& expected_error, |
42 const content::PresentationError& actual_error) { | 42 const content::PresentationError& actual_error) { |
43 cb_invoked_ = true; | 43 cb_invoked_ = true; |
44 EXPECT_EQ(expected_error.error_type, actual_error.error_type); | 44 EXPECT_EQ(expected_error.error_type, actual_error.error_type); |
45 EXPECT_EQ(expected_error.message, actual_error.message); | 45 EXPECT_EQ(expected_error.message, actual_error.message); |
46 } | 46 } |
47 | 47 |
48 void FailOnSuccess(const content::PresentationSessionInfo& info, | 48 void FailOnSuccess(const content::PresentationSessionInfo& info, |
49 const MediaRoute::Id& route_id) { | 49 const MediaRoute& route) { |
50 FAIL() << "Success callback should not have been called."; | 50 FAIL() << "Success callback should not have been called."; |
51 } | 51 } |
52 | 52 |
53 void FailOnError(const content::PresentationError& error) { | 53 void FailOnError(const content::PresentationError& error) { |
54 FAIL() << "Error should not have been called."; | 54 FAIL() << "Error should not have been called."; |
55 } | 55 } |
56 | 56 |
57 bool cb_invoked_; | 57 bool cb_invoked_; |
58 const RenderFrameHostId render_frame_host_id_; | 58 const RenderFrameHostId render_frame_host_id_; |
59 GURL presentation_url_; | 59 GURL presentation_url_; |
(...skipping 20 matching lines...) Expand all Loading... |
80 | 80 |
81 TEST_F(CreatePresentationConnectionRequestTest, SuccessCallback) { | 81 TEST_F(CreatePresentationConnectionRequestTest, SuccessCallback) { |
82 content::PresentationSessionInfo session_info(presentation_url_, | 82 content::PresentationSessionInfo session_info(presentation_url_, |
83 kPresentationId); | 83 kPresentationId); |
84 CreatePresentationConnectionRequest request( | 84 CreatePresentationConnectionRequest request( |
85 render_frame_host_id_, presentation_url_, GURL(kFrameUrl), | 85 render_frame_host_id_, presentation_url_, GURL(kFrameUrl), |
86 base::Bind(&CreatePresentationConnectionRequestTest::OnSuccess, | 86 base::Bind(&CreatePresentationConnectionRequestTest::OnSuccess, |
87 base::Unretained(this), session_info), | 87 base::Unretained(this), session_info), |
88 base::Bind(&CreatePresentationConnectionRequestTest::FailOnError, | 88 base::Bind(&CreatePresentationConnectionRequestTest::FailOnError, |
89 base::Unretained(this))); | 89 base::Unretained(this))); |
90 request.InvokeSuccessCallback(kPresentationId, kRouteId); | 90 MediaRoute route(kRouteId, MediaSourceForTab(1), "sinkId", "Description", |
| 91 false, "", false); |
| 92 request.InvokeSuccessCallback(kPresentationId, route); |
91 EXPECT_TRUE(cb_invoked_); | 93 EXPECT_TRUE(cb_invoked_); |
92 } | 94 } |
93 | 95 |
94 TEST_F(CreatePresentationConnectionRequestTest, ErrorCallback) { | 96 TEST_F(CreatePresentationConnectionRequestTest, ErrorCallback) { |
95 content::PresentationError error( | 97 content::PresentationError error( |
96 content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, | 98 content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, |
97 "This is an error message"); | 99 "This is an error message"); |
98 CreatePresentationConnectionRequest request( | 100 CreatePresentationConnectionRequest request( |
99 render_frame_host_id_, presentation_url_, GURL(kFrameUrl), | 101 render_frame_host_id_, presentation_url_, GURL(kFrameUrl), |
100 base::Bind(&CreatePresentationConnectionRequestTest::FailOnSuccess, | 102 base::Bind(&CreatePresentationConnectionRequestTest::FailOnSuccess, |
101 base::Unretained(this)), | 103 base::Unretained(this)), |
102 base::Bind(&CreatePresentationConnectionRequestTest::OnError, | 104 base::Bind(&CreatePresentationConnectionRequestTest::OnError, |
103 base::Unretained(this), error)); | 105 base::Unretained(this), error)); |
104 request.InvokeErrorCallback(error); | 106 request.InvokeErrorCallback(error); |
105 EXPECT_TRUE(cb_invoked_); | 107 EXPECT_TRUE(cb_invoked_); |
106 } | 108 } |
107 | 109 |
108 } // namespace media_router | 110 } // namespace media_router |
OLD | NEW |