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

Unified Diff: third_party/WebKit/Source/core/css/MediaValuesTest.cpp

Issue 1904523002: Fix double comparisons for Media Queries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unreachable build error Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaValues.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/MediaValuesTest.cpp
diff --git a/third_party/WebKit/Source/core/css/MediaValuesTest.cpp b/third_party/WebKit/Source/core/css/MediaValuesTest.cpp
index af9176bb0bf0949ef4252ad948f1d71fd171a51e..3ff0e4812a97a22f1cc2d91ab5775ea430e4c167 100644
--- a/third_party/WebKit/Source/core/css/MediaValuesTest.cpp
+++ b/third_party/WebKit/Source/core/css/MediaValuesTest.cpp
@@ -17,7 +17,7 @@ struct TestCase {
unsigned viewportWidth;
unsigned viewportHeight;
bool success;
- int output;
+ double output;
};
TEST(MediaValuesTest, Basic)
@@ -28,15 +28,16 @@ TEST(MediaValuesTest, Basic)
{ 40.0, CSSPrimitiveValue::UnitType::Rems, 16, 300, 300, true, 640 },
{ 40.0, CSSPrimitiveValue::UnitType::Exs, 16, 300, 300, true, 320 },
{ 40.0, CSSPrimitiveValue::UnitType::Chs, 16, 300, 300, true, 320 },
- { 43.0, CSSPrimitiveValue::UnitType::ViewportWidth, 16, 848, 976, true, 364 },
- { 43.0, CSSPrimitiveValue::UnitType::ViewportHeight, 16, 848, 976, true, 419 },
- { 43.0, CSSPrimitiveValue::UnitType::ViewportMin, 16, 848, 976, true, 364 },
- { 43.0, CSSPrimitiveValue::UnitType::ViewportMax, 16, 848, 976, true, 419 },
- { 1.3, CSSPrimitiveValue::UnitType::Centimeters, 16, 300, 300, true, 49 },
- { 1.3, CSSPrimitiveValue::UnitType::Millimeters, 16, 300, 300, true, 4 },
- { 1.3, CSSPrimitiveValue::UnitType::Inches, 16, 300, 300, true, 124 },
- { 13, CSSPrimitiveValue::UnitType::Points, 16, 300, 300, true, 17 },
- { 1.3, CSSPrimitiveValue::UnitType::Picas, 16, 300, 300, true, 20 },
+ { 43.0, CSSPrimitiveValue::UnitType::ViewportWidth, 16, 848, 976, true, 364.64 },
+ { 100.0, CSSPrimitiveValue::UnitType::ViewportWidth, 16, 821, 976, true, 821 },
+ { 43.0, CSSPrimitiveValue::UnitType::ViewportHeight, 16, 848, 976, true, 419.68 },
+ { 43.0, CSSPrimitiveValue::UnitType::ViewportMin, 16, 848, 976, true, 364.64 },
+ { 43.0, CSSPrimitiveValue::UnitType::ViewportMax, 16, 848, 976, true, 419.68 },
+ { 1.3, CSSPrimitiveValue::UnitType::Centimeters, 16, 300, 300, true, 49.133858 },
+ { 1.3, CSSPrimitiveValue::UnitType::Millimeters, 16, 300, 300, true, 4.913386 },
+ { 1.3, CSSPrimitiveValue::UnitType::Inches, 16, 300, 300, true, 124.8 },
+ { 13, CSSPrimitiveValue::UnitType::Points, 16, 300, 300, true, 17.333333 },
+ { 1.3, CSSPrimitiveValue::UnitType::Picas, 16, 300, 300, true, 20.8 },
{ 40.0, CSSPrimitiveValue::UnitType::UserUnits, 16, 300, 300, true, 40 },
{ 1.3, CSSPrimitiveValue::UnitType::Unknown, 16, 300, 300, false, 20 },
{ 0.0, CSSPrimitiveValue::UnitType::Unknown, 0, 0, 0, false, 0.0 } // Do not remove the terminating line.
@@ -44,16 +45,16 @@ TEST(MediaValuesTest, Basic)
for (unsigned i = 0; testCases[i].viewportWidth; ++i) {
- int output = 0;
+ double output = 0;
bool success = MediaValues::computeLength(testCases[i].value,
testCases[i].type,
testCases[i].fontSize,
testCases[i].viewportWidth,
testCases[i].viewportHeight,
output);
- ASSERT_EQ(testCases[i].success, success);
+ EXPECT_EQ(testCases[i].success, success);
if (success)
- ASSERT_EQ(testCases[i].output, output);
+ EXPECT_FLOAT_EQ(testCases[i].output, output);
}
}
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaValues.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698