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 10 matching lines...) Expand all Loading... |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 class CreatePresentationConnectionRequestTest : public ::testing::Test { | 23 class CreatePresentationConnectionRequestTest : public ::testing::Test { |
24 public: | 24 public: |
25 CreatePresentationConnectionRequestTest() | 25 CreatePresentationConnectionRequestTest() |
26 : cb_invoked_(false), render_frame_host_id_(1, 2) {} | 26 : cb_invoked_(false), render_frame_host_id_(1, 2) {} |
27 ~CreatePresentationConnectionRequestTest() override {} | 27 ~CreatePresentationConnectionRequestTest() override {} |
28 | 28 |
29 void OnSuccess(const content::PresentationSessionInfo& expected_info, | 29 void OnSuccess(const content::PresentationSessionInfo& expected_info, |
30 const content::PresentationSessionInfo& actual_info, | 30 const content::PresentationSessionInfo& actual_info, |
31 const MediaRoute::Id& route_id) { | 31 const MediaRoute& route) { |
32 cb_invoked_ = true; | 32 cb_invoked_ = true; |
33 EXPECT_EQ(expected_info.presentation_url, actual_info.presentation_url); | 33 EXPECT_EQ(expected_info.presentation_url, actual_info.presentation_url); |
34 EXPECT_EQ(expected_info.presentation_id, actual_info.presentation_id); | 34 EXPECT_EQ(expected_info.presentation_id, actual_info.presentation_id); |
35 } | 35 } |
36 | 36 |
37 void OnError(const content::PresentationError& expected_error, | 37 void OnError(const content::PresentationError& expected_error, |
38 const content::PresentationError& actual_error) { | 38 const content::PresentationError& actual_error) { |
39 cb_invoked_ = true; | 39 cb_invoked_ = true; |
40 EXPECT_EQ(expected_error.error_type, actual_error.error_type); | 40 EXPECT_EQ(expected_error.error_type, actual_error.error_type); |
41 EXPECT_EQ(expected_error.message, actual_error.message); | 41 EXPECT_EQ(expected_error.message, actual_error.message); |
42 } | 42 } |
43 | 43 |
44 void FailOnSuccess(const content::PresentationSessionInfo& info, | 44 void FailOnSuccess(const content::PresentationSessionInfo& info, |
45 const MediaRoute::Id& route_id) { | 45 const MediaRoute& route) { |
46 FAIL() << "Success callback should not have been called."; | 46 FAIL() << "Success callback should not have been called."; |
47 } | 47 } |
48 | 48 |
49 void FailOnError(const content::PresentationError& error) { | 49 void FailOnError(const content::PresentationError& error) { |
50 FAIL() << "Error should not have been called."; | 50 FAIL() << "Error should not have been called."; |
51 } | 51 } |
52 | 52 |
53 bool cb_invoked_; | 53 bool cb_invoked_; |
54 const RenderFrameHostId render_frame_host_id_; | 54 const RenderFrameHostId render_frame_host_id_; |
55 }; | 55 }; |
(...skipping 18 matching lines...) Expand all Loading... |
74 | 74 |
75 TEST_F(CreatePresentationConnectionRequestTest, SuccessCallback) { | 75 TEST_F(CreatePresentationConnectionRequestTest, SuccessCallback) { |
76 content::PresentationSessionInfo session_info(kPresentationUrl, | 76 content::PresentationSessionInfo session_info(kPresentationUrl, |
77 kPresentationId); | 77 kPresentationId); |
78 CreatePresentationConnectionRequest request( | 78 CreatePresentationConnectionRequest request( |
79 render_frame_host_id_, kPresentationUrl, GURL(kFrameUrl), | 79 render_frame_host_id_, kPresentationUrl, GURL(kFrameUrl), |
80 base::Bind(&CreatePresentationConnectionRequestTest::OnSuccess, | 80 base::Bind(&CreatePresentationConnectionRequestTest::OnSuccess, |
81 base::Unretained(this), session_info), | 81 base::Unretained(this), session_info), |
82 base::Bind(&CreatePresentationConnectionRequestTest::FailOnError, | 82 base::Bind(&CreatePresentationConnectionRequestTest::FailOnError, |
83 base::Unretained(this))); | 83 base::Unretained(this))); |
84 request.InvokeSuccessCallback(kPresentationId, kRouteId); | 84 MediaRoute route(kRouteId, MediaSourceForCastApp("DialApp"), "sinkId", |
| 85 "Description", false, "", false); |
| 86 request.InvokeSuccessCallback(kPresentationId, route); |
85 EXPECT_TRUE(cb_invoked_); | 87 EXPECT_TRUE(cb_invoked_); |
86 } | 88 } |
87 | 89 |
88 TEST_F(CreatePresentationConnectionRequestTest, ErrorCallback) { | 90 TEST_F(CreatePresentationConnectionRequestTest, ErrorCallback) { |
89 content::PresentationError error( | 91 content::PresentationError error( |
90 content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, | 92 content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED, |
91 "This is an error message"); | 93 "This is an error message"); |
92 CreatePresentationConnectionRequest request( | 94 CreatePresentationConnectionRequest request( |
93 render_frame_host_id_, kPresentationUrl, GURL(kFrameUrl), | 95 render_frame_host_id_, kPresentationUrl, GURL(kFrameUrl), |
94 base::Bind(&CreatePresentationConnectionRequestTest::FailOnSuccess, | 96 base::Bind(&CreatePresentationConnectionRequestTest::FailOnSuccess, |
95 base::Unretained(this)), | 97 base::Unretained(this)), |
96 base::Bind(&CreatePresentationConnectionRequestTest::OnError, | 98 base::Bind(&CreatePresentationConnectionRequestTest::OnError, |
97 base::Unretained(this), error)); | 99 base::Unretained(this), error)); |
98 request.InvokeErrorCallback(error); | 100 request.InvokeErrorCallback(error); |
99 EXPECT_TRUE(cb_invoked_); | 101 EXPECT_TRUE(cb_invoked_); |
100 } | 102 } |
101 | 103 |
102 } // namespace media_router | 104 } // namespace media_router |
OLD | NEW |