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

Side by Side Diff: device/capture/content/capture_resolution_chooser_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/content/capture_resolution_chooser.h" 5 #include "device/capture/content/capture_resolution_chooser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using tracked_objects::Location; 13 using tracked_objects::Location;
14 14
15 namespace media { 15 namespace device {
16 16
17 namespace { 17 namespace {
18 18
19 // 16:9 maximum and minimum frame sizes. 19 // 16:9 maximum and minimum frame sizes.
20 const int kMaxFrameWidth = 3840; 20 const int kMaxFrameWidth = 3840;
21 const int kMaxFrameHeight = 2160; 21 const int kMaxFrameHeight = 2160;
22 const int kMinFrameWidth = 320; 22 const int kMinFrameWidth = 320;
23 const int kMinFrameHeight = 180; 23 const int kMinFrameHeight = 180;
24 24
25 // Checks whether |size| is strictly between (inclusive) |min_size| and 25 // Checks whether |size| is strictly between (inclusive) |min_size| and
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 chooser->SetTargetFrameArea(0); 185 chooser->SetTargetFrameArea(0);
186 EXPECT_EQ(smallest_size, chooser->capture_size()); 186 EXPECT_EQ(smallest_size, chooser->capture_size());
187 } 187 }
188 188
189 } // namespace 189 } // namespace
190 190
191 TEST(CaptureResolutionChooserTest, 191 TEST(CaptureResolutionChooserTest,
192 FixedResolutionPolicy_CaptureSizeAlwaysFixed) { 192 FixedResolutionPolicy_CaptureSizeAlwaysFixed) {
193 const gfx::Size the_one_frame_size(kMaxFrameWidth, kMaxFrameHeight); 193 const gfx::Size the_one_frame_size(kMaxFrameWidth, kMaxFrameHeight);
194 CaptureResolutionChooser chooser(the_one_frame_size, 194 CaptureResolutionChooser chooser(the_one_frame_size,
195 RESOLUTION_POLICY_FIXED_RESOLUTION); 195 media::RESOLUTION_POLICY_FIXED_RESOLUTION);
196 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); 196 EXPECT_EQ(the_one_frame_size, chooser.capture_size());
197 197
198 chooser.SetSourceSize(the_one_frame_size); 198 chooser.SetSourceSize(the_one_frame_size);
199 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); 199 EXPECT_EQ(the_one_frame_size, chooser.capture_size());
200 200
201 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth + 424, kMaxFrameHeight - 101)); 201 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth + 424, kMaxFrameHeight - 101));
202 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); 202 EXPECT_EQ(the_one_frame_size, chooser.capture_size());
203 203
204 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth - 202, kMaxFrameHeight + 56)); 204 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth - 202, kMaxFrameHeight + 56));
205 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); 205 EXPECT_EQ(the_one_frame_size, chooser.capture_size());
(...skipping 16 matching lines...) Expand all
222 // frame size. 222 // frame size.
223 chooser.SetTargetFrameArea(0); 223 chooser.SetTargetFrameArea(0);
224 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); 224 EXPECT_EQ(the_one_frame_size, chooser.capture_size());
225 chooser.SetTargetFrameArea(the_one_frame_size.GetArea() / 2); 225 chooser.SetTargetFrameArea(the_one_frame_size.GetArea() / 2);
226 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); 226 EXPECT_EQ(the_one_frame_size, chooser.capture_size());
227 } 227 }
228 228
229 TEST(CaptureResolutionChooserTest, 229 TEST(CaptureResolutionChooserTest,
230 FixedAspectRatioPolicy_CaptureSizeHasSameAspectRatio) { 230 FixedAspectRatioPolicy_CaptureSizeHasSameAspectRatio) {
231 CaptureResolutionChooser chooser(gfx::Size(kMaxFrameWidth, kMaxFrameHeight), 231 CaptureResolutionChooser chooser(gfx::Size(kMaxFrameWidth, kMaxFrameHeight),
232 RESOLUTION_POLICY_FIXED_ASPECT_RATIO); 232 media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO);
233 233
234 // Starting condition. 234 // Starting condition.
235 const gfx::Size min_size(kMinFrameWidth, kMinFrameHeight); 235 const gfx::Size min_size(kMinFrameWidth, kMinFrameHeight);
236 const gfx::Size max_size(kMaxFrameWidth, kMaxFrameHeight); 236 const gfx::Size max_size(kMaxFrameWidth, kMaxFrameHeight);
237 ExpectIsWithinBoundsAndSameAspectRatio(FROM_HERE, min_size, max_size, 237 ExpectIsWithinBoundsAndSameAspectRatio(FROM_HERE, min_size, max_size,
238 chooser.capture_size()); 238 chooser.capture_size());
239 239
240 // Max size in --> max size out. 240 // Max size in --> max size out.
241 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth, kMaxFrameHeight)); 241 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth, kMaxFrameHeight));
242 ExpectIsWithinBoundsAndSameAspectRatio(FROM_HERE, min_size, max_size, 242 ExpectIsWithinBoundsAndSameAspectRatio(FROM_HERE, min_size, max_size,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 const gfx::Size smallest_size(180 * kMaxFrameWidth / kMaxFrameHeight, 180); 294 const gfx::Size smallest_size(180 * kMaxFrameWidth / kMaxFrameHeight, 180);
295 295
296 TestSnappedFrameSizes(&chooser, smallest_size); 296 TestSnappedFrameSizes(&chooser, smallest_size);
297 TestTargetedFrameAreas(&chooser, smallest_size); 297 TestTargetedFrameAreas(&chooser, smallest_size);
298 } 298 }
299 299
300 TEST(CaptureResolutionChooserTest, 300 TEST(CaptureResolutionChooserTest,
301 AnyWithinLimitPolicy_CaptureSizeIsAnythingWithinLimits) { 301 AnyWithinLimitPolicy_CaptureSizeIsAnythingWithinLimits) {
302 const gfx::Size max_size(kMaxFrameWidth, kMaxFrameHeight); 302 const gfx::Size max_size(kMaxFrameWidth, kMaxFrameHeight);
303 CaptureResolutionChooser chooser(max_size, 303 CaptureResolutionChooser chooser(max_size,
304 RESOLUTION_POLICY_ANY_WITHIN_LIMIT); 304 media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT);
305 305
306 // Starting condition. 306 // Starting condition.
307 EXPECT_EQ(max_size, chooser.capture_size()); 307 EXPECT_EQ(max_size, chooser.capture_size());
308 308
309 // Max size in --> max size out. 309 // Max size in --> max size out.
310 chooser.SetSourceSize(max_size); 310 chooser.SetSourceSize(max_size);
311 EXPECT_EQ(max_size, chooser.capture_size()); 311 EXPECT_EQ(max_size, chooser.capture_size());
312 312
313 // Various source sizes within bounds. 313 // Various source sizes within bounds.
314 chooser.SetSourceSize(gfx::Size(640, 480)); 314 chooser.SetSourceSize(gfx::Size(640, 480));
(...skipping 28 matching lines...) Expand all
343 343
344 // For a chooser configured with the "any within limit" policy, the smallest 344 // For a chooser configured with the "any within limit" policy, the smallest
345 // possible computed size is smallest non-empty snapped size (which is 90 345 // possible computed size is smallest non-empty snapped size (which is 90
346 // lines of resolution) with the same aspect ratio as the maximum size. 346 // lines of resolution) with the same aspect ratio as the maximum size.
347 const gfx::Size smallest_size(90 * kMaxFrameWidth / kMaxFrameHeight, 90); 347 const gfx::Size smallest_size(90 * kMaxFrameWidth / kMaxFrameHeight, 90);
348 348
349 TestSnappedFrameSizes(&chooser, smallest_size); 349 TestSnappedFrameSizes(&chooser, smallest_size);
350 TestTargetedFrameAreas(&chooser, smallest_size); 350 TestTargetedFrameAreas(&chooser, smallest_size);
351 } 351 }
352 352
353 } // namespace media 353 } // namespace device
OLDNEW
« no previous file with comments | « device/capture/content/capture_resolution_chooser.cc ('k') | device/capture/content/screen_capture_device_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698