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 "media/capture/video/fake_video_capture_device.h" | 5 #include "media/capture/video/fake_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> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "media/base/media_switches.h" | 20 #include "media/base/media_switches.h" |
21 #include "media/base/video_capture_types.h" | 21 #include "media/base/video_capture_types.h" |
22 #include "media/capture/video/fake_video_capture_device_factory.h" | 22 #include "media/capture/video/fake_video_capture_device_factory.h" |
23 #include "media/capture/video/video_capture_device.h" | 23 #include "media/capture/video/video_capture_device.h" |
24 #include "mojo/public/cpp/bindings/string.h" | |
25 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
27 | 26 |
28 using ::testing::_; | 27 using ::testing::_; |
29 using ::testing::Bool; | 28 using ::testing::Bool; |
30 using ::testing::Combine; | 29 using ::testing::Combine; |
31 using ::testing::SaveArg; | 30 using ::testing::SaveArg; |
32 using ::testing::Values; | 31 using ::testing::Values; |
33 | 32 |
34 namespace media { | 33 namespace media { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 MOCK_METHOD1(OnGetPhotoCapabilitiesFailure, | 144 MOCK_METHOD1(OnGetPhotoCapabilitiesFailure, |
146 void(const base::Callback<void(mojom::PhotoCapabilitiesPtr)>&)); | 145 void(const base::Callback<void(mojom::PhotoCapabilitiesPtr)>&)); |
147 | 146 |
148 const mojom::PhotoCapabilities* capabilities() { return capabilities_.get(); } | 147 const mojom::PhotoCapabilities* capabilities() { return capabilities_.get(); } |
149 | 148 |
150 MOCK_METHOD1(OnCorrectSetPhotoOptions, void(bool)); | 149 MOCK_METHOD1(OnCorrectSetPhotoOptions, void(bool)); |
151 MOCK_METHOD1(OnSetPhotoOptionsFailure, | 150 MOCK_METHOD1(OnSetPhotoOptionsFailure, |
152 void(const base::Callback<void(bool)>&)); | 151 void(const base::Callback<void(bool)>&)); |
153 | 152 |
154 // GMock doesn't support move-only arguments, so we use this forward method. | 153 // GMock doesn't support move-only arguments, so we use this forward method. |
155 void DoOnPhotoTaken(mojo::String mime_type, mojo::Array<uint8_t> data) { | 154 void DoOnPhotoTaken(const std::string& mime_type, |
| 155 const std::vector<uint8_t>& data) { |
156 // Only PNG images are supported right now. | 156 // Only PNG images are supported right now. |
157 EXPECT_STREQ("image/png", mime_type.storage().c_str()); | 157 EXPECT_STREQ("image/png", mime_type.c_str()); |
158 // Not worth decoding the incoming data. Just check that the header is PNG. | 158 // Not worth decoding the incoming data. Just check that the header is PNG. |
159 // http://www.libpng.org/pub/png/spec/1.2/PNG-Rationale.html#R.PNG-file-sign
ature | 159 // http://www.libpng.org/pub/png/spec/1.2/PNG-Rationale.html#R.PNG-file-sign
ature |
160 ASSERT_GT(data.size(), 4u); | 160 ASSERT_GT(data.size(), 4u); |
161 EXPECT_EQ('P', data[1]); | 161 EXPECT_EQ('P', data[1]); |
162 EXPECT_EQ('N', data[2]); | 162 EXPECT_EQ('N', data[2]); |
163 EXPECT_EQ('G', data[3]); | 163 EXPECT_EQ('G', data[3]); |
164 OnCorrectPhotoTaken(); | 164 OnCorrectPhotoTaken(); |
165 } | 165 } |
166 MOCK_METHOD0(OnCorrectPhotoTaken, void(void)); | 166 MOCK_METHOD0(OnCorrectPhotoTaken, void(void)); |
167 MOCK_METHOD1( | 167 MOCK_METHOD1(OnTakePhotoFailure, |
168 OnTakePhotoFailure, | 168 void(const base::Callback<void(const std::string&, |
169 void(const base::Callback<void(mojo::String, mojo::Array<uint8_t>)>&)); | 169 const std::vector<uint8_t>&)>&)); |
170 | 170 |
171 private: | 171 private: |
172 friend class base::RefCounted<ImageCaptureClient>; | 172 friend class base::RefCounted<ImageCaptureClient>; |
173 virtual ~ImageCaptureClient() {} | 173 virtual ~ImageCaptureClient() {} |
174 | 174 |
175 mojom::PhotoCapabilitiesPtr capabilities_; | 175 mojom::PhotoCapabilitiesPtr capabilities_; |
176 }; | 176 }; |
177 | 177 |
178 } // namespace | 178 } // namespace |
179 | 179 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 INSTANTIATE_TEST_CASE_P(, | 412 INSTANTIATE_TEST_CASE_P(, |
413 FakeVideoCaptureDeviceCommandLineTest, | 413 FakeVideoCaptureDeviceCommandLineTest, |
414 Values(CommandLineTestData{"fps=-1", 5}, | 414 Values(CommandLineTestData{"fps=-1", 5}, |
415 CommandLineTestData{"fps=29.97", 29.97f}, | 415 CommandLineTestData{"fps=29.97", 29.97f}, |
416 CommandLineTestData{"fps=60", 60}, | 416 CommandLineTestData{"fps=60", 60}, |
417 CommandLineTestData{"fps=1000", 60})); | 417 CommandLineTestData{"fps=1000", 60})); |
418 }; // namespace media | 418 }; // namespace media |
OLD | NEW |