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

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

Issue 2359243002: VideoCaptureDeviceTest: improve error logging (Closed)
Patch Set: chfremer@ comment Created 4 years, 2 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize 65 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize
66 #define MAYBE_CaptureMjpeg CaptureMjpeg 66 #define MAYBE_CaptureMjpeg CaptureMjpeg
67 #define MAYBE_TakePhoto TakePhoto 67 #define MAYBE_TakePhoto TakePhoto
68 #else 68 #else
69 #define MAYBE_AllocateBadSize AllocateBadSize 69 #define MAYBE_AllocateBadSize AllocateBadSize
70 #define MAYBE_CaptureMjpeg CaptureMjpeg 70 #define MAYBE_CaptureMjpeg CaptureMjpeg
71 #define MAYBE_TakePhoto DISABLED_TakePhoto 71 #define MAYBE_TakePhoto DISABLED_TakePhoto
72 #endif 72 #endif
73 73
74 using ::testing::_; 74 using ::testing::_;
75 using ::testing::Invoke;
75 using ::testing::SaveArg; 76 using ::testing::SaveArg;
76 77
77 namespace media { 78 namespace media {
78 namespace { 79 namespace {
79 80
81 void DumpError(const tracked_objects::Location& location,
82 const std::string& message) {
83 DPLOG(ERROR) << location.ToString() << " " << message;
84 }
85
80 class MockVideoCaptureClient : public VideoCaptureDevice::Client { 86 class MockVideoCaptureClient : public VideoCaptureDevice::Client {
81 public: 87 public:
82 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); 88 MOCK_METHOD0(DoReserveOutputBuffer, void(void));
83 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); 89 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
84 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); 90 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
85 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); 91 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void));
86 MOCK_METHOD2(OnError, 92 MOCK_METHOD2(OnError,
87 void(const tracked_objects::Location& from_here, 93 void(const tracked_objects::Location& from_here,
88 const std::string& reason)); 94 const std::string& reason));
89 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void)); 95 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void));
90 96
91 explicit MockVideoCaptureClient( 97 explicit MockVideoCaptureClient(
92 base::Callback<void(const VideoCaptureFormat&)> frame_cb) 98 base::Callback<void(const VideoCaptureFormat&)> frame_cb)
93 : main_thread_(base::ThreadTaskRunnerHandle::Get()), 99 : main_thread_(base::ThreadTaskRunnerHandle::Get()), frame_cb_(frame_cb) {
94 frame_cb_(frame_cb) {} 100 ON_CALL(*this, OnError(_, _)).WillByDefault(Invoke(DumpError));
chfremer 2016/09/22 18:05:33 Sgtm. Alternatively, we could use a Lambda express
101 }
95 102
96 void OnIncomingCapturedData(const uint8_t* data, 103 void OnIncomingCapturedData(const uint8_t* data,
97 int length, 104 int length,
98 const VideoCaptureFormat& format, 105 const VideoCaptureFormat& format,
99 int rotation, 106 int rotation,
100 base::TimeTicks reference_time, 107 base::TimeTicks reference_time,
101 base::TimeDelta timestamp) override { 108 base::TimeDelta timestamp) override {
102 ASSERT_GT(length, 0); 109 ASSERT_GT(length, 0);
103 ASSERT_TRUE(data); 110 ASSERT_TRUE(data);
104 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format)); 111 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format));
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 &MockImageCaptureClient::OnTakePhotoFailure, image_capture_client_))); 555 &MockImageCaptureClient::OnTakePhotoFailure, image_capture_client_)));
549 556
550 EXPECT_CALL(*image_capture_client_.get(), OnCorrectPhotoTaken()).Times(1); 557 EXPECT_CALL(*image_capture_client_.get(), OnCorrectPhotoTaken()).Times(1);
551 device->TakePhoto(std::move(scoped_callback)); 558 device->TakePhoto(std::move(scoped_callback));
552 WaitForCapturedFrame(); 559 WaitForCapturedFrame();
553 560
554 device->StopAndDeAllocate(); 561 device->StopAndDeAllocate();
555 } 562 }
556 563
557 }; // namespace media 564 }; // 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