| OLD | NEW |
| 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 "content/browser/media/capture/capture_resolution_chooser.h" | 5 #include "media/capture/capture_resolution_chooser.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 using tracked_objects::Location; | 10 using tracked_objects::Location; |
| 11 | 11 |
| 12 namespace content { | 12 namespace media { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // 16:9 maximum and minimum frame sizes. | 16 // 16:9 maximum and minimum frame sizes. |
| 17 const int kMaxFrameWidth = 3840; | 17 const int kMaxFrameWidth = 3840; |
| 18 const int kMaxFrameHeight = 2160; | 18 const int kMaxFrameHeight = 2160; |
| 19 const int kMinFrameWidth = 320; | 19 const int kMinFrameWidth = 320; |
| 20 const int kMinFrameHeight = 180; | 20 const int kMinFrameHeight = 180; |
| 21 | 21 |
| 22 // Checks whether |size| is strictly between (inclusive) |min_size| and | 22 // Checks whether |size| is strictly between (inclusive) |min_size| and |
| (...skipping 11 matching lines...) Expand all Loading... |
| 34 static_cast<double>(size.width()) / size.height(), | 34 static_cast<double>(size.width()) / size.height(), |
| 35 0.01); | 35 0.01); |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 TEST(CaptureResolutionChooserTest, | 40 TEST(CaptureResolutionChooserTest, |
| 41 FixedResolutionPolicy_CaptureSizeAlwaysFixed) { | 41 FixedResolutionPolicy_CaptureSizeAlwaysFixed) { |
| 42 const gfx::Size the_one_frame_size(kMaxFrameWidth, kMaxFrameHeight); | 42 const gfx::Size the_one_frame_size(kMaxFrameWidth, kMaxFrameHeight); |
| 43 CaptureResolutionChooser chooser(the_one_frame_size, | 43 CaptureResolutionChooser chooser(the_one_frame_size, |
| 44 media::RESOLUTION_POLICY_FIXED_RESOLUTION); | 44 RESOLUTION_POLICY_FIXED_RESOLUTION); |
| 45 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); | 45 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); |
| 46 | 46 |
| 47 chooser.SetSourceSize(the_one_frame_size); | 47 chooser.SetSourceSize(the_one_frame_size); |
| 48 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); | 48 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); |
| 49 | 49 |
| 50 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth + 424, kMaxFrameHeight - 101)); | 50 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth + 424, kMaxFrameHeight - 101)); |
| 51 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); | 51 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); |
| 52 | 52 |
| 53 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth - 202, kMaxFrameHeight + 56)); | 53 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth - 202, kMaxFrameHeight + 56)); |
| 54 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); | 54 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); |
| 55 | 55 |
| 56 chooser.SetSourceSize(gfx::Size(kMinFrameWidth, kMinFrameHeight)); | 56 chooser.SetSourceSize(gfx::Size(kMinFrameWidth, kMinFrameHeight)); |
| 57 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); | 57 EXPECT_EQ(the_one_frame_size, chooser.capture_size()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 TEST(CaptureResolutionChooserTest, | 60 TEST(CaptureResolutionChooserTest, |
| 61 FixedAspectRatioPolicy_CaptureSizeHasSameAspectRatio) { | 61 FixedAspectRatioPolicy_CaptureSizeHasSameAspectRatio) { |
| 62 CaptureResolutionChooser chooser( | 62 CaptureResolutionChooser chooser( |
| 63 gfx::Size(kMaxFrameWidth, kMaxFrameHeight), | 63 gfx::Size(kMaxFrameWidth, kMaxFrameHeight), |
| 64 media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO); | 64 RESOLUTION_POLICY_FIXED_ASPECT_RATIO); |
| 65 | 65 |
| 66 // Starting condition. | 66 // Starting condition. |
| 67 const gfx::Size min_size(kMinFrameWidth, kMinFrameHeight); | 67 const gfx::Size min_size(kMinFrameWidth, kMinFrameHeight); |
| 68 const gfx::Size max_size(kMaxFrameWidth, kMaxFrameHeight); | 68 const gfx::Size max_size(kMaxFrameWidth, kMaxFrameHeight); |
| 69 ExpectIsWithinBoundsAndSameAspectRatio( | 69 ExpectIsWithinBoundsAndSameAspectRatio( |
| 70 FROM_HERE, min_size, max_size, chooser.capture_size()); | 70 FROM_HERE, min_size, max_size, chooser.capture_size()); |
| 71 | 71 |
| 72 // Max size in --> max size out. | 72 // Max size in --> max size out. |
| 73 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth, kMaxFrameHeight)); | 73 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth, kMaxFrameHeight)); |
| 74 ExpectIsWithinBoundsAndSameAspectRatio( | 74 ExpectIsWithinBoundsAndSameAspectRatio( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 chooser.SetSourceSize(gfx::Size(kMinFrameWidth, kMinFrameHeight / 2)); | 119 chooser.SetSourceSize(gfx::Size(kMinFrameWidth, kMinFrameHeight / 2)); |
| 120 ExpectIsWithinBoundsAndSameAspectRatio( | 120 ExpectIsWithinBoundsAndSameAspectRatio( |
| 121 FROM_HERE, min_size, max_size, chooser.capture_size()); | 121 FROM_HERE, min_size, max_size, chooser.capture_size()); |
| 122 } | 122 } |
| 123 | 123 |
| 124 TEST(CaptureResolutionChooserTest, | 124 TEST(CaptureResolutionChooserTest, |
| 125 AnyWithinLimitPolicy_CaptureSizeIsAnythingWithinLimits) { | 125 AnyWithinLimitPolicy_CaptureSizeIsAnythingWithinLimits) { |
| 126 const gfx::Size max_size(kMaxFrameWidth, kMaxFrameHeight); | 126 const gfx::Size max_size(kMaxFrameWidth, kMaxFrameHeight); |
| 127 CaptureResolutionChooser chooser( | 127 CaptureResolutionChooser chooser( |
| 128 max_size, media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT); | 128 max_size, RESOLUTION_POLICY_ANY_WITHIN_LIMIT); |
| 129 | 129 |
| 130 // Starting condition. | 130 // Starting condition. |
| 131 EXPECT_EQ(max_size, chooser.capture_size()); | 131 EXPECT_EQ(max_size, chooser.capture_size()); |
| 132 | 132 |
| 133 // Max size in --> max size out. | 133 // Max size in --> max size out. |
| 134 chooser.SetSourceSize(max_size); | 134 chooser.SetSourceSize(max_size); |
| 135 EXPECT_EQ(max_size, chooser.capture_size()); | 135 EXPECT_EQ(max_size, chooser.capture_size()); |
| 136 | 136 |
| 137 // Various source sizes within bounds. | 137 // Various source sizes within bounds. |
| 138 chooser.SetSourceSize(gfx::Size(640, 480)); | 138 chooser.SetSourceSize(gfx::Size(640, 480)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 159 | 159 |
| 160 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth * 2, kMaxFrameHeight)); | 160 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth * 2, kMaxFrameHeight)); |
| 161 EXPECT_EQ(gfx::Size(kMaxFrameWidth, kMaxFrameHeight / 2), | 161 EXPECT_EQ(gfx::Size(kMaxFrameWidth, kMaxFrameHeight / 2), |
| 162 chooser.capture_size()); | 162 chooser.capture_size()); |
| 163 | 163 |
| 164 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth, kMaxFrameHeight * 2)); | 164 chooser.SetSourceSize(gfx::Size(kMaxFrameWidth, kMaxFrameHeight * 2)); |
| 165 EXPECT_EQ(gfx::Size(kMaxFrameWidth / 2, kMaxFrameHeight), | 165 EXPECT_EQ(gfx::Size(kMaxFrameWidth / 2, kMaxFrameHeight), |
| 166 chooser.capture_size()); | 166 chooser.capture_size()); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace content | 169 } // namespace media |
| OLD | NEW |