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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/child/child_process.h" | 10 #include "content/child/child_process.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 }; | 130 }; |
131 | 131 |
132 // Multiple clients with the same session id. There is only one | 132 // Multiple clients with the same session id. There is only one |
133 // media::VideoCapture object. | 133 // media::VideoCapture object. |
134 TEST_F(VideoCaptureImplManagerTest, MultipleClients) { | 134 TEST_F(VideoCaptureImplManagerTest, MultipleClients) { |
135 base::Closure release_cb1 = manager_->UseDevice(0); | 135 base::Closure release_cb1 = manager_->UseDevice(0); |
136 base::Closure release_cb2 = manager_->UseDevice(0); | 136 base::Closure release_cb2 = manager_->UseDevice(0); |
137 base::Closure stop_cb1, stop_cb2; | 137 base::Closure stop_cb1, stop_cb2; |
138 { | 138 { |
139 base::RunLoop run_loop; | 139 base::RunLoop run_loop; |
140 base::Closure quit_closure = BindToCurrentLoop( | 140 base::Closure quit_closure = BindToCurrentLoop(run_loop.QuitClosure()); |
141 run_loop.QuitClosure()); | 141 EXPECT_CALL(*this, OnStarted()).WillOnce(RunClosure(quit_closure)); |
142 EXPECT_CALL(*this, OnStarted()).WillOnce( | |
143 RunClosure(quit_closure)); | |
144 EXPECT_CALL(*this, OnStarted()).RetiresOnSaturation(); | 142 EXPECT_CALL(*this, OnStarted()).RetiresOnSaturation(); |
145 stop_cb1 = StartCapture(params_); | 143 stop_cb1 = StartCapture(params_); |
146 stop_cb2 = StartCapture(params_); | 144 stop_cb2 = StartCapture(params_); |
147 FakeChannelSetup(); | 145 FakeChannelSetup(); |
148 run_loop.Run(); | 146 run_loop.Run(); |
149 } | 147 } |
150 | 148 |
151 { | 149 { |
152 base::RunLoop run_loop; | 150 base::RunLoop run_loop; |
153 base::Closure quit_closure = BindToCurrentLoop( | 151 base::Closure quit_closure = BindToCurrentLoop(run_loop.QuitClosure()); |
154 run_loop.QuitClosure()); | 152 EXPECT_CALL(*this, OnStopped()).WillOnce(RunClosure(quit_closure)); |
155 EXPECT_CALL(*this, OnStopped()).WillOnce( | |
156 RunClosure(quit_closure)); | |
157 EXPECT_CALL(*this, OnStopped()).RetiresOnSaturation(); | 153 EXPECT_CALL(*this, OnStopped()).RetiresOnSaturation(); |
158 stop_cb1.Run(); | 154 stop_cb1.Run(); |
159 stop_cb2.Run(); | 155 stop_cb2.Run(); |
160 run_loop.Run(); | 156 run_loop.Run(); |
161 } | 157 } |
162 | 158 |
163 release_cb1.Run(); | 159 release_cb1.Run(); |
164 release_cb2.Run(); | 160 release_cb2.Run(); |
165 cleanup_run_loop_.Run(); | 161 cleanup_run_loop_.Run(); |
166 } | 162 } |
167 | 163 |
168 TEST_F(VideoCaptureImplManagerTest, NoLeak) { | 164 TEST_F(VideoCaptureImplManagerTest, NoLeak) { |
169 manager_->UseDevice(0).Reset(); | 165 manager_->UseDevice(0).Reset(); |
170 manager_.reset(); | 166 manager_.reset(); |
171 cleanup_run_loop_.Run(); | 167 cleanup_run_loop_.Run(); |
172 } | 168 } |
173 | 169 |
174 } // namespace content | 170 } // namespace content |
OLD | NEW |