Index: Source/core/css/parser/SizesAttributeParserTest.cpp |
diff --git a/Source/core/css/parser/SizesAttributeParserTest.cpp b/Source/core/css/parser/SizesAttributeParserTest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f1fcb6b918ab3cbeb17b3668808828bf2f6b7379 |
--- /dev/null |
+++ b/Source/core/css/parser/SizesAttributeParserTest.cpp |
@@ -0,0 +1,54 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+ |
+#include "core/css/parser/SizesAttributeParser.h" |
+ |
+#include <gtest/gtest.h> |
+ |
+namespace WebCore { |
+ |
+typedef struct { |
+ const char* input; |
+ const int output; |
+} TestCase; |
+ |
+TEST(SizesAttributeParserTest, Basic) |
+{ |
+ // The first string represents the input string. |
+ // The second string represents the output string, if present. |
+ // Otherwise, the output string is identical to the first string. |
+ TestCase testCases[] = { |
+ {"screen", 300}, |
+ {"(min-width:500px)", 300}, |
+ {"(min-width:500px) 200px", 0}, |
+ {"(min-width:500px) 200px, 400px", 0}, |
+ {0, 0} // Do not remove the terminator line. |
+ }; |
+ |
+ RefPtr<MediaValues> mediaValues = MediaValues::create(MediaValues::CachingMode, |
eseidel
2014/04/08 06:02:14
Wow, this is bad. Instead we should use a struct:
|
+ 500, // Viewport Width |
+ 500, // Viewport height |
+ 500, // Device Width |
+ 500, // Device Height |
+ 2.0, // Device pixel ratio |
+ 24, // Color bits per component |
+ 0, // Monochrome bits per component |
+ MediaValues::MousePointer, // Pointer device |
+ 16, // Default font size |
+ true, // 3D enabled |
+ false, // scan media type |
+ true, // screen media type |
+ false, // print media type |
+ true // Strict mode |
+ ); |
+ |
+ for (unsigned i = 0; testCases[i].input; ++i) { |
+ int effectiveSize = SizesAttributeParser::findEffectiveSize(testCases[i].input, mediaValues); |
+ ASSERT_EQ(testCases[i].output, effectiveSize); |
+ } |
+} |
+ |
+} // namespace |