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

Side by Side Diff: media/capture/video/video_capture_device_unittest.cc

Issue 2699073002: Make MockImageCaptureClient RefCountedThreadSafe (Closed)
Patch Set: rebase Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/capture/video/video_capture_device.h" 5 #include "media/capture/video/video_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 DoResurrectLastOutputBuffer(); 151 DoResurrectLastOutputBuffer();
152 NOTREACHED() << "This should never be called"; 152 NOTREACHED() << "This should never be called";
153 return Buffer(); 153 return Buffer();
154 } 154 }
155 155
156 private: 156 private:
157 scoped_refptr<base::SingleThreadTaskRunner> main_thread_; 157 scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
158 base::Callback<void(const VideoCaptureFormat&)> frame_cb_; 158 base::Callback<void(const VideoCaptureFormat&)> frame_cb_;
159 }; 159 };
160 160
161 class MockImageCaptureClient : public base::RefCounted<MockImageCaptureClient> { 161 class MockImageCaptureClient
162 : public base::RefCountedThreadSafe<MockImageCaptureClient> {
162 public: 163 public:
163 // GMock doesn't support move-only arguments, so we use this forward method. 164 // GMock doesn't support move-only arguments, so we use this forward method.
164 void DoOnPhotoTaken(mojom::BlobPtr blob) { 165 void DoOnPhotoTaken(mojom::BlobPtr blob) {
165 if (strcmp("image/jpeg", blob->mime_type.c_str()) == 0) { 166 if (strcmp("image/jpeg", blob->mime_type.c_str()) == 0) {
166 ASSERT_GT(blob->data.size(), 4u); 167 ASSERT_GT(blob->data.size(), 4u);
167 // Check some bytes that univocally identify |data| as a JPEG File. 168 // Check some bytes that univocally identify |data| as a JPEG File.
168 // https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#File_format_ structure 169 // https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#File_format_ structure
169 EXPECT_EQ(0xFF, blob->data[0]); // First SOI byte 170 EXPECT_EQ(0xFF, blob->data[0]); // First SOI byte
170 EXPECT_EQ(0xD8, blob->data[1]); // Second SOI byte 171 EXPECT_EQ(0xD8, blob->data[1]); // Second SOI byte
171 EXPECT_EQ(0xFF, blob->data[2]); // First JFIF-APP0 byte 172 EXPECT_EQ(0xFF, blob->data[2]); // First JFIF-APP0 byte
(...skipping 18 matching lines...) Expand all
190 capabilities_ = std::move(capabilities); 191 capabilities_ = std::move(capabilities);
191 OnCorrectGetPhotoCapabilities(); 192 OnCorrectGetPhotoCapabilities();
192 } 193 }
193 MOCK_METHOD0(OnCorrectGetPhotoCapabilities, void(void)); 194 MOCK_METHOD0(OnCorrectGetPhotoCapabilities, void(void));
194 MOCK_METHOD1(OnGetPhotoCapabilitiesFailure, 195 MOCK_METHOD1(OnGetPhotoCapabilitiesFailure,
195 void(const base::Callback<void(mojom::PhotoCapabilitiesPtr)>&)); 196 void(const base::Callback<void(mojom::PhotoCapabilitiesPtr)>&));
196 197
197 const mojom::PhotoCapabilities* capabilities() { return capabilities_.get(); } 198 const mojom::PhotoCapabilities* capabilities() { return capabilities_.get(); }
198 199
199 private: 200 private:
200 friend class base::RefCounted<MockImageCaptureClient>; 201 friend class base::RefCountedThreadSafe<MockImageCaptureClient>;
201 virtual ~MockImageCaptureClient() {} 202 virtual ~MockImageCaptureClient() {}
202 203
203 mojom::PhotoCapabilitiesPtr capabilities_; 204 mojom::PhotoCapabilitiesPtr capabilities_;
204 }; 205 };
205 206
206 class DeviceEnumerationListener 207 class DeviceEnumerationListener
207 : public base::RefCounted<DeviceEnumerationListener> { 208 : public base::RefCounted<DeviceEnumerationListener> {
208 public: 209 public:
209 MOCK_METHOD1(DoOnEnumerateDeviceDescriptors, 210 MOCK_METHOD1(DoOnEnumerateDeviceDescriptors,
210 void(VideoCaptureDeviceDescriptors* device_descriptors)); 211 void(VideoCaptureDeviceDescriptors* device_descriptors));
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 632
632 device->GetPhotoCapabilities(std::move(scoped_get_callback)); 633 device->GetPhotoCapabilities(std::move(scoped_get_callback));
633 run_loop.Run(); 634 run_loop.Run();
634 635
635 ASSERT_TRUE(image_capture_client_->capabilities()); 636 ASSERT_TRUE(image_capture_client_->capabilities());
636 637
637 device->StopAndDeAllocate(); 638 device->StopAndDeAllocate();
638 } 639 }
639 640
640 }; // namespace media 641 }; // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698