Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(640)

Side by Side Diff: components/cast_channel/cast_socket_service_unittest.cc

Issue 2974523002: [cast_channel] Make CastSocketService a global leaky singleton (Closed)
Patch Set: merge with master Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/cast_channel/cast_socket_service_factory.cc ('k') | components/cast_channel/cast_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698