OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/cast_channel/cast_socket_service.h" | 5 #include "components/cast_channel/cast_socket_service.h" |
6 #include "base/test/mock_callback.h" | 6 #include "base/test/mock_callback.h" |
7 #include "components/cast_channel/cast_test_util.h" | 7 #include "components/cast_channel/cast_test_util.h" |
8 #include "content/public/test/test_browser_thread_bundle.h" | 8 #include "content/public/test/test_browser_thread_bundle.h" |
9 | 9 |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 cast_socket_service_(new CastSocketService()) {} | 27 cast_socket_service_(new CastSocketService()) {} |
28 | 28 |
29 CastSocket* AddSocket(std::unique_ptr<CastSocket> socket) { | 29 CastSocket* AddSocket(std::unique_ptr<CastSocket> socket) { |
30 return cast_socket_service_->AddSocket(std::move(socket)); | 30 return cast_socket_service_->AddSocket(std::move(socket)); |
31 } | 31 } |
32 | 32 |
33 void TearDown() override { cast_socket_service_ = nullptr; } | 33 void TearDown() override { cast_socket_service_ = nullptr; } |
34 | 34 |
35 protected: | 35 protected: |
36 content::TestBrowserThreadBundle thread_bundle_; | 36 content::TestBrowserThreadBundle thread_bundle_; |
37 scoped_refptr<CastSocketService> cast_socket_service_; | 37 std::unique_ptr<CastSocketService> cast_socket_service_; |
38 base::MockCallback<CastSocket::OnOpenCallback> mock_on_open_callback_; | 38 base::MockCallback<CastSocket::OnOpenCallback> mock_on_open_callback_; |
39 MockCastSocketObserver mock_observer_; | 39 MockCastSocketObserver mock_observer_; |
40 }; | 40 }; |
41 | 41 |
42 TEST_F(CastSocketServiceTest, TestAddSocket) { | 42 TEST_F(CastSocketServiceTest, TestAddSocket) { |
43 auto socket1 = base::MakeUnique<MockCastSocket>(); | 43 auto socket1 = base::MakeUnique<MockCastSocket>(); |
44 auto* socket_ptr1 = AddSocket(std::move(socket1)); | 44 auto* socket_ptr1 = AddSocket(std::move(socket1)); |
45 EXPECT_NE(0, socket_ptr1->id()); | 45 EXPECT_NE(0, socket_ptr1->id()); |
46 | 46 |
47 auto socket2 = base::MakeUnique<MockCastSocket>(); | 47 auto socket2 = base::MakeUnique<MockCastSocket>(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 }))); | 87 }))); |
88 EXPECT_CALL(mock_on_open_callback_, Run(_, ChannelError::NONE)); | 88 EXPECT_CALL(mock_on_open_callback_, Run(_, ChannelError::NONE)); |
89 EXPECT_CALL(*mock_socket, AddObserver(_)); | 89 EXPECT_CALL(*mock_socket, AddObserver(_)); |
90 | 90 |
91 cast_socket_service_->OpenSocket(ip_endpoint, nullptr /* net_log */, | 91 cast_socket_service_->OpenSocket(ip_endpoint, nullptr /* net_log */, |
92 mock_on_open_callback_.Get(), | 92 mock_on_open_callback_.Get(), |
93 &mock_observer_); | 93 &mock_observer_); |
94 } | 94 } |
95 | 95 |
96 } // namespace cast_channel | 96 } // namespace cast_channel |
OLD | NEW |