Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 | |
| 7 #include "core/css/parser/SizesAttributeParser.h" | |
| 8 | |
| 9 #include <gtest/gtest.h> | |
| 10 | |
| 11 namespace WebCore { | |
| 12 | |
| 13 typedef struct { | |
| 14 const char* input; | |
| 15 const int output; | |
| 16 } TestCase; | |
| 17 | |
| 18 TEST(SizesAttributeParserTest, Basic) | |
| 19 { | |
| 20 // The first string represents the input string. | |
| 21 // The second string represents the output string, if present. | |
| 22 // Otherwise, the output string is identical to the first string. | |
| 23 TestCase testCases[] = { | |
| 24 {"screen", 300}, | |
| 25 {"(min-width:500px)", 300}, | |
| 26 {"(min-width:500px) 200px", 0}, | |
| 27 {"(min-width:500px) 200px, 400px", 0}, | |
| 28 {0, 0} // Do not remove the terminator line. | |
| 29 }; | |
| 30 | |
| 31 RefPtr<MediaValues> mediaValues = MediaValues::create(MediaValues::CachingMo de, | |
|
eseidel
2014/04/08 06:02:14
Wow, this is bad. Instead we should use a struct:
| |
| 32 500, // Viewport Width | |
| 33 500, // Viewport height | |
| 34 500, // Device Width | |
| 35 500, // Device Height | |
| 36 2.0, // Device pixel ratio | |
| 37 24, // Color bits per component | |
| 38 0, // Monochrome bits per component | |
| 39 MediaValues::MousePointer, // Pointer device | |
| 40 16, // Default font size | |
| 41 true, // 3D enabled | |
| 42 false, // scan media type | |
| 43 true, // screen media type | |
| 44 false, // print media type | |
| 45 true // Strict mode | |
| 46 ); | |
| 47 | |
| 48 for (unsigned i = 0; testCases[i].input; ++i) { | |
| 49 int effectiveSize = SizesAttributeParser::findEffectiveSize(testCases[i] .input, mediaValues); | |
| 50 ASSERT_EQ(testCases[i].output, effectiveSize); | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 } // namespace | |
| OLD | NEW |