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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 class MockVideoCaptureImpl : public VideoCaptureImpl { | 29 class MockVideoCaptureImpl : public VideoCaptureImpl { |
30 public: | 30 public: |
31 MockVideoCaptureImpl(media::VideoCaptureSessionId session_id, | 31 MockVideoCaptureImpl(media::VideoCaptureSessionId session_id, |
32 VideoCaptureMessageFilter* filter, | 32 VideoCaptureMessageFilter* filter, |
33 base::Closure destruct_callback) | 33 base::Closure destruct_callback) |
34 : VideoCaptureImpl(session_id, filter), | 34 : VideoCaptureImpl(session_id, filter), |
35 destruct_callback_(destruct_callback) { | 35 destruct_callback_(destruct_callback) { |
36 } | 36 } |
37 | 37 |
38 virtual ~MockVideoCaptureImpl() { | 38 ~MockVideoCaptureImpl() override { destruct_callback_.Run(); } |
39 destruct_callback_.Run(); | |
40 } | |
41 | 39 |
42 private: | 40 private: |
43 base::Closure destruct_callback_; | 41 base::Closure destruct_callback_; |
44 | 42 |
45 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureImpl); | 43 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureImpl); |
46 }; | 44 }; |
47 | 45 |
48 class MockVideoCaptureImplManager : public VideoCaptureImplManager { | 46 class MockVideoCaptureImplManager : public VideoCaptureImplManager { |
49 public: | 47 public: |
50 explicit MockVideoCaptureImplManager( | 48 explicit MockVideoCaptureImplManager( |
51 base::Closure destruct_video_capture_callback) | 49 base::Closure destruct_video_capture_callback) |
52 : destruct_video_capture_callback_( | 50 : destruct_video_capture_callback_( |
53 destruct_video_capture_callback) {} | 51 destruct_video_capture_callback) {} |
54 virtual ~MockVideoCaptureImplManager() {} | 52 ~MockVideoCaptureImplManager() override {} |
55 | 53 |
56 protected: | 54 protected: |
57 virtual VideoCaptureImpl* CreateVideoCaptureImplForTesting( | 55 VideoCaptureImpl* CreateVideoCaptureImplForTesting( |
58 media::VideoCaptureSessionId id, | 56 media::VideoCaptureSessionId id, |
59 VideoCaptureMessageFilter* filter) const override { | 57 VideoCaptureMessageFilter* filter) const override { |
60 return new MockVideoCaptureImpl(id, | 58 return new MockVideoCaptureImpl(id, |
61 filter, | 59 filter, |
62 destruct_video_capture_callback_); | 60 destruct_video_capture_callback_); |
63 } | 61 } |
64 | 62 |
65 private: | 63 private: |
66 base::Closure destruct_video_capture_callback_; | 64 base::Closure destruct_video_capture_callback_; |
67 | 65 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 cleanup_run_loop_.Run(); | 166 cleanup_run_loop_.Run(); |
169 } | 167 } |
170 | 168 |
171 TEST_F(VideoCaptureImplManagerTest, NoLeak) { | 169 TEST_F(VideoCaptureImplManagerTest, NoLeak) { |
172 manager_->UseDevice(0).Reset(); | 170 manager_->UseDevice(0).Reset(); |
173 manager_.reset(); | 171 manager_.reset(); |
174 cleanup_run_loop_.Run(); | 172 cleanup_run_loop_.Run(); |
175 } | 173 } |
176 | 174 |
177 } // namespace content | 175 } // namespace content |
OLD | NEW |