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

Side by Side Diff: content/browser/media/media_internals_unittest.cc

Issue 2214533002: move //media/capture to //device/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/media/media_internals.h" 5 #include "content/browser/media/media_internals.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 ~MediaInternalsVideoCaptureDeviceTest() override { 107 ~MediaInternalsVideoCaptureDeviceTest() override {
108 media_internals_->RemoveUpdateCallback(update_cb_); 108 media_internals_->RemoveUpdateCallback(update_cb_);
109 } 109 }
110 110
111 protected: 111 protected:
112 MediaInternals::UpdateCallback update_cb_; 112 MediaInternals::UpdateCallback update_cb_;
113 }; 113 };
114 114
115 // TODO(chfremer): Consider removing this. This test seem be 115 // TODO(chfremer): Consider removing this. This test seem to be a duplicate
116 // a duplicate implementation of the functionality under test. 116 // implementation of the functionality under test. https://crbug.com/630694
117 // https://crbug.com/630694
118 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ 117 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \
119 defined(OS_ANDROID) 118 defined(OS_ANDROID)
120 TEST_F(MediaInternalsVideoCaptureDeviceTest, 119 TEST_F(MediaInternalsVideoCaptureDeviceTest,
121 AllCaptureApiTypesHaveProperStringRepresentation) { 120 AllCaptureApiTypesHaveProperStringRepresentation) {
122 using VideoCaptureApi = media::VideoCaptureApi; 121 using VideoCaptureApi = device::VideoCaptureApi;
123 std::map<VideoCaptureApi, std::string> api_to_string_map; 122 std::map<VideoCaptureApi, std::string> api_to_string_map;
124 api_to_string_map[VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE] = "V4L2 SPLANE"; 123 api_to_string_map[VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE] = "V4L2 SPLANE";
125 api_to_string_map[VideoCaptureApi::WIN_MEDIA_FOUNDATION] = "Media Foundation"; 124 api_to_string_map[VideoCaptureApi::WIN_MEDIA_FOUNDATION] = "Media Foundation";
126 api_to_string_map[VideoCaptureApi::WIN_DIRECT_SHOW] = "Direct Show"; 125 api_to_string_map[VideoCaptureApi::WIN_DIRECT_SHOW] = "Direct Show";
127 api_to_string_map[VideoCaptureApi::MACOSX_AVFOUNDATION] = "AV Foundation"; 126 api_to_string_map[VideoCaptureApi::MACOSX_AVFOUNDATION] = "AV Foundation";
128 api_to_string_map[VideoCaptureApi::MACOSX_DECKLINK] = "DeckLink"; 127 api_to_string_map[VideoCaptureApi::MACOSX_DECKLINK] = "DeckLink";
129 api_to_string_map[VideoCaptureApi::ANDROID_API1] = "Camera API1"; 128 api_to_string_map[VideoCaptureApi::ANDROID_API1] = "Camera API1";
130 api_to_string_map[VideoCaptureApi::ANDROID_API2_LEGACY] = 129 api_to_string_map[VideoCaptureApi::ANDROID_API2_LEGACY] =
131 "Camera API2 Legacy"; 130 "Camera API2 Legacy";
132 api_to_string_map[VideoCaptureApi::ANDROID_API2_FULL] = "Camera API2 Full"; 131 api_to_string_map[VideoCaptureApi::ANDROID_API2_FULL] = "Camera API2 Full";
133 api_to_string_map[VideoCaptureApi::ANDROID_API2_LIMITED] = 132 api_to_string_map[VideoCaptureApi::ANDROID_API2_LIMITED] =
134 "Camera API2 Limited"; 133 "Camera API2 Limited";
135 api_to_string_map[VideoCaptureApi::ANDROID_TANGO] = "Tango API"; 134 api_to_string_map[VideoCaptureApi::ANDROID_TANGO] = "Tango API";
136 EXPECT_EQ(static_cast<size_t>(VideoCaptureApi::UNKNOWN), 135 EXPECT_EQ(static_cast<size_t>(VideoCaptureApi::UNKNOWN),
137 api_to_string_map.size()); 136 api_to_string_map.size());
138 for (const auto& map_entry : api_to_string_map) { 137 for (const auto& map_entry : api_to_string_map) {
139 media::VideoCaptureDeviceDescriptor descriptor; 138 device::VideoCaptureDeviceDescriptor descriptor;
140 descriptor.capture_api = map_entry.first; 139 descriptor.capture_api = map_entry.first;
141 EXPECT_EQ(map_entry.second, descriptor.GetCaptureApiTypeString()); 140 EXPECT_EQ(map_entry.second, descriptor.GetCaptureApiTypeString());
142 } 141 }
143 } 142 }
144 #endif 143 #endif
145 144
146 TEST_F(MediaInternalsVideoCaptureDeviceTest, 145 TEST_F(MediaInternalsVideoCaptureDeviceTest,
147 VideoCaptureFormatStringIsInExpectedFormat) { 146 VideoCaptureFormatStringIsInExpectedFormat) {
148 // Since media internals will send video capture capabilities to JavaScript in 147 // Since media internals will send video capture capabilities to JavaScript in
149 // an expected format and there are no public methods for accessing the 148 // an expected format and there are no public methods for accessing the
(...skipping 14 matching lines...) Expand all
164 media::VideoCaptureFormat::PixelStorageToString(kPixelStorage).c_str()); 163 media::VideoCaptureFormat::PixelStorageToString(kPixelStorage).c_str());
165 EXPECT_EQ(expected_string, 164 EXPECT_EQ(expected_string,
166 media::VideoCaptureFormat::ToString(capture_format)); 165 media::VideoCaptureFormat::ToString(capture_format));
167 } 166 }
168 167
169 TEST_F(MediaInternalsVideoCaptureDeviceTest, 168 TEST_F(MediaInternalsVideoCaptureDeviceTest,
170 NotifyVideoCaptureDeviceCapabilitiesEnumerated) { 169 NotifyVideoCaptureDeviceCapabilitiesEnumerated) {
171 const int kWidth = 1280; 170 const int kWidth = 1280;
172 const int kHeight = 720; 171 const int kHeight = 720;
173 const float kFrameRate = 30.0f; 172 const float kFrameRate = 30.0f;
174 const media::VideoPixelFormat kPixelFormat = 173 const media::VideoPixelFormat kPixelFormat = media::PIXEL_FORMAT_I420;
175 media::PIXEL_FORMAT_I420;
176 const media::VideoCaptureFormat format_hd({kWidth, kHeight}, 174 const media::VideoCaptureFormat format_hd({kWidth, kHeight},
177 kFrameRate, kPixelFormat); 175 kFrameRate, kPixelFormat);
178 media::VideoCaptureFormats formats{}; 176 media::VideoCaptureFormats formats{};
179 formats.push_back(format_hd); 177 formats.push_back(format_hd);
180 media::VideoCaptureDeviceDescriptor descriptor; 178 device::VideoCaptureDeviceDescriptor descriptor;
181 descriptor.device_id = "dummy"; 179 descriptor.device_id = "dummy";
182 descriptor.display_name = "dummy"; 180 descriptor.display_name = "dummy";
183 #if defined(OS_MACOSX) 181 #if defined(OS_MACOSX)
184 descriptor.capture_api = media::VideoCaptureApi::MACOSX_AVFOUNDATION; 182 descriptor.capture_api = device::VideoCaptureApi::MACOSX_AVFOUNDATION;
185 #elif defined(OS_WIN) 183 #elif defined(OS_WIN)
186 descriptor.capture_api = media::VideoCaptureApi::WIN_DIRECT_SHOW; 184 descriptor.capture_api = device::VideoCaptureApi::WIN_DIRECT_SHOW;
187 #elif defined(OS_LINUX) 185 #elif defined(OS_LINUX)
188 descriptor.device_id = "/dev/dummy"; 186 descriptor.device_id = "/dev/dummy";
189 descriptor.capture_api = media::VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE; 187 descriptor.capture_api = device::VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE;
190 #elif defined(OS_ANDROID) 188 #elif defined(OS_ANDROID)
191 descriptor.capture_api = media::VideoCaptureApi::ANDROID_API2_LEGACY; 189 descriptor.capture_api = device::VideoCaptureApi::ANDROID_API2_LEGACY;
192 #endif 190 #endif
193 std::vector<std::tuple<media::VideoCaptureDeviceDescriptor, 191 std::vector<std::tuple<device::VideoCaptureDeviceDescriptor,
194 media::VideoCaptureFormats>> 192 media::VideoCaptureFormats>>
195 descriptors_and_formats{}; 193 descriptors_and_formats{};
196 descriptors_and_formats.push_back(std::make_tuple(descriptor, formats)); 194 descriptors_and_formats.push_back(std::make_tuple(descriptor, formats));
197 195
198 // When updating video capture capabilities, the update will serialize 196 // When updating video capture capabilities, the update will serialize
199 // a JSON array of objects to string. So here, the |UpdateCallbackImpl| will 197 // a JSON array of objects to string. So here, the |UpdateCallbackImpl| will
200 // deserialize the first object in the array. This means we have to have 198 // deserialize the first object in the array. This means we have to have
201 // exactly one device_info in the |descriptors_and_formats|. 199 // exactly one device_info in the |descriptors_and_formats|.
202 media_internals_->UpdateVideoCaptureDeviceCapabilities( 200 media_internals_->UpdateVideoCaptureDeviceCapabilities(
203 descriptors_and_formats); 201 descriptors_and_formats);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 ExpectStatus("closed"); 302 ExpectStatus("closed");
305 } 303 }
306 304
307 INSTANTIATE_TEST_CASE_P( 305 INSTANTIATE_TEST_CASE_P(
308 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values( 306 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values(
309 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, 307 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER,
310 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, 308 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER,
311 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); 309 media::AudioLogFactory::AUDIO_OUTPUT_STREAM));
312 310
313 } // namespace content 311 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/media_internals.cc ('k') | content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698