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

Side by Side Diff: content/renderer/media/media_stream_constraints_util_video_content_unittest.cc

Issue 2776243005: Fix constants in constraints util tests. (Closed)
Patch Set: Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/renderer/media/media_stream_constraints_util_video_content.h" 5 #include "content/renderer/media/media_stream_constraints_util_video_content.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 9
10 #include "content/renderer/media/media_stream_video_source.h" 10 #include "content/renderer/media/media_stream_video_source.h"
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 CheckNonResolutionDefaults(result); 881 CheckNonResolutionDefaults(result);
882 } 882 }
883 883
884 // Ideal intersects a box. 884 // Ideal intersects a box.
885 { 885 {
886 constraint_factory_.Reset(); 886 constraint_factory_.Reset();
887 constraint_factory_.basic().height.setMin(100); 887 constraint_factory_.basic().height.setMin(100);
888 constraint_factory_.basic().height.setMax(500); 888 constraint_factory_.basic().height.setMax(500);
889 constraint_factory_.basic().width.setMin(100); 889 constraint_factory_.basic().width.setMin(100);
890 constraint_factory_.basic().width.setMax(500); 890 constraint_factory_.basic().width.setMax(500);
891 const int kIdealAspectRatio = 2.0; 891 const double kIdealAspectRatio = 2.0;
892 constraint_factory_.basic().aspectRatio.setIdeal(kIdealAspectRatio); 892 constraint_factory_.basic().aspectRatio.setIdeal(kIdealAspectRatio);
893 auto result = SelectSettings(); 893 auto result = SelectSettings();
894 EXPECT_TRUE(result.HasValue()); 894 EXPECT_TRUE(result.HasValue());
895 // Ideal aspect-ratio is included in the bounding box, with the value 895 // Ideal aspect-ratio is included in the bounding box, with the value
896 // closest to a standard width or height being the cut with the maximum 896 // closest to a standard width or height being the cut with the maximum
897 // width. 897 // width.
898 EXPECT_EQ( 898 EXPECT_EQ(
899 std::round(constraint_factory_.basic().width.max() / kIdealAspectRatio), 899 std::round(constraint_factory_.basic().width.max() / kIdealAspectRatio),
900 result.Height()); 900 result.Height());
901 EXPECT_EQ(constraint_factory_.basic().width.max(), result.Width()); 901 EXPECT_EQ(constraint_factory_.basic().width.max(), result.Width());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 EXPECT_TRUE(result.HasValue()); 1002 EXPECT_TRUE(result.HasValue());
1003 // Ideal is closest to the min height and max width. 1003 // Ideal is closest to the min height and max width.
1004 EXPECT_EQ(constraint_factory_.basic().height.min(), result.Height()); 1004 EXPECT_EQ(constraint_factory_.basic().height.min(), result.Height());
1005 EXPECT_EQ(constraint_factory_.basic().width.max(), result.Width()); 1005 EXPECT_EQ(constraint_factory_.basic().width.max(), result.Width());
1006 CheckNonResolutionDefaults(result); 1006 CheckNonResolutionDefaults(result);
1007 } 1007 }
1008 } 1008 }
1009 1009
1010 TEST_F(MediaStreamConstraintsUtilVideoContentTest, MandatoryExactFrameRate) { 1010 TEST_F(MediaStreamConstraintsUtilVideoContentTest, MandatoryExactFrameRate) {
1011 constraint_factory_.Reset(); 1011 constraint_factory_.Reset();
1012 const int kFrameRate = 45.0; 1012 const double kFrameRate = 45.0;
1013 constraint_factory_.basic().frameRate.setExact(kFrameRate); 1013 constraint_factory_.basic().frameRate.setExact(kFrameRate);
1014 auto result = SelectSettings(); 1014 auto result = SelectSettings();
1015 EXPECT_TRUE(result.HasValue()); 1015 EXPECT_TRUE(result.HasValue());
1016 EXPECT_EQ(kFrameRate, result.FrameRate()); 1016 EXPECT_EQ(kFrameRate, result.FrameRate());
1017 CheckNonFrameRateDefaults(result); 1017 CheckNonFrameRateDefaults(result);
1018 } 1018 }
1019 1019
1020 TEST_F(MediaStreamConstraintsUtilVideoContentTest, MandatoryMinFrameRate) { 1020 TEST_F(MediaStreamConstraintsUtilVideoContentTest, MandatoryMinFrameRate) {
1021 constraint_factory_.Reset(); 1021 constraint_factory_.Reset();
1022 const double kFrameRate = 45.0; 1022 const double kFrameRate = 45.0;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 // The whole range is less that the default, so expect the maximum. 1091 // The whole range is less that the default, so expect the maximum.
1092 EXPECT_EQ(kMaxFrameRate, result.FrameRate()); 1092 EXPECT_EQ(kMaxFrameRate, result.FrameRate());
1093 CheckNonFrameRateDefaults(result); 1093 CheckNonFrameRateDefaults(result);
1094 } 1094 }
1095 } 1095 }
1096 1096
1097 TEST_F(MediaStreamConstraintsUtilVideoContentTest, IdealFrameRate) { 1097 TEST_F(MediaStreamConstraintsUtilVideoContentTest, IdealFrameRate) {
1098 // Unconstrained. 1098 // Unconstrained.
1099 { 1099 {
1100 constraint_factory_.Reset(); 1100 constraint_factory_.Reset();
1101 const int kIdealFrameRate = 45.0; 1101 const double kIdealFrameRate = 45.0;
1102 constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate); 1102 constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate);
1103 auto result = SelectSettings(); 1103 auto result = SelectSettings();
1104 EXPECT_TRUE(result.HasValue()); 1104 EXPECT_TRUE(result.HasValue());
1105 EXPECT_EQ(kIdealFrameRate, result.FrameRate()); 1105 EXPECT_EQ(kIdealFrameRate, result.FrameRate());
1106 CheckNonFrameRateDefaults(result); 1106 CheckNonFrameRateDefaults(result);
1107 } 1107 }
1108 1108
1109 // Ideal greater than maximum. 1109 // Ideal greater than maximum.
1110 { 1110 {
1111 constraint_factory_.Reset(); 1111 constraint_factory_.Reset();
1112 const int kIdealFrameRate = 45.0; 1112 const double kIdealFrameRate = 45.0;
1113 const int kMaxFrameRate = 30.0; 1113 const double kMaxFrameRate = 30.0;
1114 constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate); 1114 constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate);
1115 constraint_factory_.basic().frameRate.setMax(kMaxFrameRate); 1115 constraint_factory_.basic().frameRate.setMax(kMaxFrameRate);
1116 auto result = SelectSettings(); 1116 auto result = SelectSettings();
1117 EXPECT_TRUE(result.HasValue()); 1117 EXPECT_TRUE(result.HasValue());
1118 EXPECT_EQ(kMaxFrameRate, result.FrameRate()); 1118 EXPECT_EQ(kMaxFrameRate, result.FrameRate());
1119 CheckNonFrameRateDefaults(result); 1119 CheckNonFrameRateDefaults(result);
1120 } 1120 }
1121 1121
1122 // Ideal less than minimum. 1122 // Ideal less than minimum.
1123 { 1123 {
1124 constraint_factory_.Reset(); 1124 constraint_factory_.Reset();
1125 const int kIdealFrameRate = 45.0; 1125 const double kIdealFrameRate = 45.0;
1126 const int kMinFrameRate = 50.0; 1126 const double kMinFrameRate = 50.0;
1127 constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate); 1127 constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate);
1128 constraint_factory_.basic().frameRate.setMin(kMinFrameRate); 1128 constraint_factory_.basic().frameRate.setMin(kMinFrameRate);
1129 auto result = SelectSettings(); 1129 auto result = SelectSettings();
1130 EXPECT_TRUE(result.HasValue()); 1130 EXPECT_TRUE(result.HasValue());
1131 EXPECT_EQ(kMinFrameRate, result.FrameRate()); 1131 EXPECT_EQ(kMinFrameRate, result.FrameRate());
1132 CheckNonFrameRateDefaults(result); 1132 CheckNonFrameRateDefaults(result);
1133 } 1133 }
1134 1134
1135 // Ideal within range. 1135 // Ideal within range.
1136 { 1136 {
1137 constraint_factory_.Reset(); 1137 constraint_factory_.Reset();
1138 const int kIdealFrameRate = 45.0; 1138 const double kIdealFrameRate = 45.0;
1139 const int kMinFrameRate = 35.0; 1139 const double kMinFrameRate = 35.0;
1140 const int kMaxFrameRate = 50.0; 1140 const double kMaxFrameRate = 50.0;
1141 constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate); 1141 constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate);
1142 constraint_factory_.basic().frameRate.setMin(kMinFrameRate); 1142 constraint_factory_.basic().frameRate.setMin(kMinFrameRate);
1143 constraint_factory_.basic().frameRate.setMax(kMaxFrameRate); 1143 constraint_factory_.basic().frameRate.setMax(kMaxFrameRate);
1144 auto result = SelectSettings(); 1144 auto result = SelectSettings();
1145 EXPECT_TRUE(result.HasValue()); 1145 EXPECT_TRUE(result.HasValue());
1146 EXPECT_EQ(kIdealFrameRate, result.FrameRate()); 1146 EXPECT_EQ(kIdealFrameRate, result.FrameRate());
1147 CheckNonFrameRateDefaults(result); 1147 CheckNonFrameRateDefaults(result);
1148 } 1148 }
1149 } 1149 }
1150 1150
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 auto result = SelectSettings(); 1652 auto result = SelectSettings();
1653 EXPECT_EQ(std::round(480 * 1.32), result.Width()); 1653 EXPECT_EQ(std::round(480 * 1.32), result.Width());
1654 EXPECT_EQ(480, result.Height()); 1654 EXPECT_EQ(480, result.Height());
1655 // Exact aspect ratio prevents the resolution from being adjusted. 1655 // Exact aspect ratio prevents the resolution from being adjusted.
1656 EXPECT_EQ(media::RESOLUTION_POLICY_FIXED_RESOLUTION, 1656 EXPECT_EQ(media::RESOLUTION_POLICY_FIXED_RESOLUTION,
1657 result.ResolutionChangePolicy()); 1657 result.ResolutionChangePolicy());
1658 } 1658 }
1659 } 1659 }
1660 1660
1661 } // namespace content 1661 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698