OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "media/mojo/services/strong_binding_set.h" | 5 #include "media/mojo/services/strong_binding_set.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/test/test_message_loop.h" | 9 #include "base/test/test_message_loop.h" |
10 #include "mojo/public/cpp/bindings/interface_request.h" | 10 #include "mojo/public/cpp/bindings/interface_request.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 class StrongBindingSetTest : public testing::Test { | 42 class StrongBindingSetTest : public testing::Test { |
43 public: | 43 public: |
44 StrongBindingSetTest() | 44 StrongBindingSetTest() |
45 : bindings_(base::MakeUnique<StrongBindingSet<TestService>>()) {} | 45 : bindings_(base::MakeUnique<StrongBindingSet<TestService>>()) {} |
46 ~StrongBindingSetTest() override {} | 46 ~StrongBindingSetTest() override {} |
47 | 47 |
48 protected: | 48 protected: |
49 void AddBindings() { | 49 void AddBindings() { |
50 binding_id_1_ = bindings_->AddBinding(base::MakeUnique<TestServiceImpl>(), | 50 binding_id_1_ = |
51 mojo::GetProxy(&test_service_ptr_1_)); | 51 bindings_->AddBinding(base::MakeUnique<TestServiceImpl>(), |
| 52 mojo::MakeRequest(&test_service_ptr_1_)); |
52 EXPECT_EQ(1, TestServiceImpl::instance_count); | 53 EXPECT_EQ(1, TestServiceImpl::instance_count); |
53 | 54 |
54 binding_id_2_ = bindings_->AddBinding(base::MakeUnique<TestServiceImpl>(), | 55 binding_id_2_ = |
55 mojo::GetProxy(&test_service_ptr_2_)); | 56 bindings_->AddBinding(base::MakeUnique<TestServiceImpl>(), |
| 57 mojo::MakeRequest(&test_service_ptr_2_)); |
56 EXPECT_EQ(2, TestServiceImpl::instance_count); | 58 EXPECT_EQ(2, TestServiceImpl::instance_count); |
57 } | 59 } |
58 | 60 |
59 TestServicePtr test_service_ptr_1_; | 61 TestServicePtr test_service_ptr_1_; |
60 TestServicePtr test_service_ptr_2_; | 62 TestServicePtr test_service_ptr_2_; |
61 StrongBindingSet<TestService>::BindingId binding_id_1_ = 0; | 63 StrongBindingSet<TestService>::BindingId binding_id_1_ = 0; |
62 StrongBindingSet<TestService>::BindingId binding_id_2_ = 0; | 64 StrongBindingSet<TestService>::BindingId binding_id_2_ = 0; |
63 std::unique_ptr<StrongBindingSet<TestService>> bindings_; | 65 std::unique_ptr<StrongBindingSet<TestService>> bindings_; |
64 | 66 |
65 private: | 67 private: |
(...skipping 28 matching lines...) Expand all Loading... |
94 EXPECT_EQ(1, TestServiceImpl::instance_count); | 96 EXPECT_EQ(1, TestServiceImpl::instance_count); |
95 | 97 |
96 EXPECT_FALSE(bindings_->RemoveBinding(kInvalidBindingId)); | 98 EXPECT_FALSE(bindings_->RemoveBinding(kInvalidBindingId)); |
97 EXPECT_EQ(1, TestServiceImpl::instance_count); | 99 EXPECT_EQ(1, TestServiceImpl::instance_count); |
98 | 100 |
99 EXPECT_TRUE(bindings_->RemoveBinding(binding_id_2_)); | 101 EXPECT_TRUE(bindings_->RemoveBinding(binding_id_2_)); |
100 EXPECT_EQ(0, TestServiceImpl::instance_count); | 102 EXPECT_EQ(0, TestServiceImpl::instance_count); |
101 } | 103 } |
102 | 104 |
103 } // namespace media | 105 } // namespace media |
OLD | NEW |