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

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

Issue 2359243002: VideoCaptureDeviceTest: improve error logging (Closed)
Patch Set: Created 4 years, 3 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;
77 using ::testing::WithArgs;
76 78
77 namespace media { 79 namespace media {
78 namespace { 80 namespace {
79 81
82 void DumpError(const tracked_objects::Location& location,
83 const std::string& message) {
84 DPLOG(ERROR) << location.ToString() << " " << message;
85 }
86
80 class MockVideoCaptureClient : public VideoCaptureDevice::Client { 87 class MockVideoCaptureClient : public VideoCaptureDevice::Client {
81 public: 88 public:
82 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); 89 MOCK_METHOD0(DoReserveOutputBuffer, void(void));
83 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); 90 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
84 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); 91 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
85 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); 92 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void));
86 MOCK_METHOD2(OnError, 93 MOCK_METHOD2(OnError,
87 void(const tracked_objects::Location& from_here, 94 void(const tracked_objects::Location& from_here,
88 const std::string& reason)); 95 const std::string& reason));
89 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void)); 96 MOCK_CONST_METHOD0(GetBufferPoolUtilization, double(void));
90 97
91 explicit MockVideoCaptureClient( 98 explicit MockVideoCaptureClient(
92 base::Callback<void(const VideoCaptureFormat&)> frame_cb) 99 base::Callback<void(const VideoCaptureFormat&)> frame_cb)
93 : main_thread_(base::ThreadTaskRunnerHandle::Get()), 100 : main_thread_(base::ThreadTaskRunnerHandle::Get()), frame_cb_(frame_cb) {
94 frame_cb_(frame_cb) {} 101 ON_CALL(*this, OnError(_, _))
102 .WillByDefault(WithArgs<0, 1>(Invoke(DumpError)));
chfremer 2016/09/22 17:44:18 Is the WithArgs<0, 1> really needed? It seems the
mcasas 2016/09/22 17:58:36 Ooops, isn't needed indeed, it's a leftover from a
103 }
95 104
96 void OnIncomingCapturedData(const uint8_t* data, 105 void OnIncomingCapturedData(const uint8_t* data,
97 int length, 106 int length,
98 const VideoCaptureFormat& format, 107 const VideoCaptureFormat& format,
99 int rotation, 108 int rotation,
100 base::TimeTicks reference_time, 109 base::TimeTicks reference_time,
101 base::TimeDelta timestamp) override { 110 base::TimeDelta timestamp) override {
102 ASSERT_GT(length, 0); 111 ASSERT_GT(length, 0);
103 ASSERT_TRUE(data); 112 ASSERT_TRUE(data);
104 main_thread_->PostTask(FROM_HERE, base::Bind(frame_cb_, format)); 113 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_))); 557 &MockImageCaptureClient::OnTakePhotoFailure, image_capture_client_)));
549 558
550 EXPECT_CALL(*image_capture_client_.get(), OnCorrectPhotoTaken()).Times(1); 559 EXPECT_CALL(*image_capture_client_.get(), OnCorrectPhotoTaken()).Times(1);
551 device->TakePhoto(std::move(scoped_callback)); 560 device->TakePhoto(std::move(scoped_callback));
552 WaitForCapturedFrame(); 561 WaitForCapturedFrame();
553 562
554 device->StopAndDeAllocate(); 563 device->StopAndDeAllocate();
555 } 564 }
556 565
557 }; // namespace media 566 }; // 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