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

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

Issue 1267883002: Pass GpuMemoryBuffer backed VideoFrame from browser to renderer processes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gmbtracker-multiple
Patch Set: Rebase Created 5 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
OLDNEW
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/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "media/base/video_capture_types.h" 10 #include "media/base/video_capture_types.h"
11 #include "media/capture/video/fake_video_capture_device.h" 11 #include "media/capture/video/fake_video_capture_device.h"
12 #include "media/capture/video/fake_video_capture_device_factory.h" 12 #include "media/capture/video/fake_video_capture_device_factory.h"
13 #include "media/capture/video/video_capture_device.h" 13 #include "media/capture/video/video_capture_device.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using ::testing::_; 17 using ::testing::_;
18 using ::testing::Bool; 18 using ::testing::Bool;
19 using ::testing::Combine; 19 using ::testing::Combine;
20 using ::testing::SaveArg; 20 using ::testing::SaveArg;
21 using ::testing::Values; 21 using ::testing::Values;
22 22
23 namespace media { 23 namespace media {
24 24
25 namespace { 25 namespace {
26 26
27 // This class is a Client::Buffer that allocates and frees the requested |size|. 27 // This class is a Client::Buffer that allocates and frees the requested |size|.
28 class MockBuffer : public VideoCaptureDevice::Client::Buffer { 28 class MockBuffer : public VideoCaptureDevice::Client::Buffer {
29 public: 29 public:
30 MockBuffer(int buffer_id, size_t size) 30 MockBuffer(int buffer_id, size_t mapped_size)
31 : id_(buffer_id), size_(size), data_(new uint8[size_]) {} 31 : id_(buffer_id),
32 mapped_size_(mapped_size),
33 data_(new uint8[mapped_size]) {}
32 ~MockBuffer() override { delete[] data_; } 34 ~MockBuffer() override { delete[] data_; }
33 35
34 int id() const override { return id_; } 36 int id() const override { return id_; }
35 size_t size() const override { return size_; } 37 gfx::Size dimensions() const override { return gfx::Size(); }
38 size_t mapped_size() const override { return mapped_size_; }
36 void* data(int plane) override { return data_; } 39 void* data(int plane) override { return data_; }
37 ClientBuffer AsClientBuffer(int plane) override { return nullptr; } 40 ClientBuffer AsClientBuffer(int plane) override { return nullptr; }
38 #if defined(OS_POSIX) 41 #if defined(OS_POSIX)
39 base::FileDescriptor AsPlatformFile() override { 42 base::FileDescriptor AsPlatformFile() override {
40 return base::FileDescriptor(); 43 return base::FileDescriptor();
41 } 44 }
42 #endif 45 #endif
43 46
44 private: 47 private:
45 const int id_; 48 const int id_;
46 const size_t size_; 49 const size_t mapped_size_;
47 uint8* const data_; 50 uint8* const data_;
48 }; 51 };
49 52
50 class MockClient : public VideoCaptureDevice::Client { 53 class MockClient : public VideoCaptureDevice::Client {
51 public: 54 public:
52 MOCK_METHOD1(OnError, void(const std::string& reason)); 55 MOCK_METHOD1(OnError, void(const std::string& reason));
53 56
54 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb) 57 explicit MockClient(base::Callback<void(const VideoCaptureFormat&)> frame_cb)
55 : frame_cb_(frame_cb) {} 58 : frame_cb_(frame_cb) {}
56 59
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 EXPECT_GE(supported_formats[2].frame_rate, 20.0); 231 EXPECT_GE(supported_formats[2].frame_rate, 20.0);
229 EXPECT_EQ(supported_formats[3].frame_size.width(), 1920); 232 EXPECT_EQ(supported_formats[3].frame_size.width(), 1920);
230 EXPECT_EQ(supported_formats[3].frame_size.height(), 1080); 233 EXPECT_EQ(supported_formats[3].frame_size.height(), 1080);
231 EXPECT_EQ(supported_formats[3].pixel_format, 234 EXPECT_EQ(supported_formats[3].pixel_format,
232 VIDEO_CAPTURE_PIXEL_FORMAT_I420); 235 VIDEO_CAPTURE_PIXEL_FORMAT_I420);
233 EXPECT_GE(supported_formats[3].frame_rate, 20.0); 236 EXPECT_GE(supported_formats[3].frame_rate, 20.0);
234 } 237 }
235 } 238 }
236 239
237 }; // namespace media 240 }; // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/fake_video_capture_device.cc ('k') | media/capture/video/video_capture_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698