OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "config.h" | 5 #include "config.h" |
6 #include "core/css/parser/BisonCSSParser.h" | 6 #include "core/css/parser/BisonCSSParser.h" |
7 | 7 |
8 #include "core/css/MediaList.h" | 8 #include "core/css/MediaList.h" |
9 #include "core/css/StyleRule.h" | 9 #include "core/css/StyleRule.h" |
10 #include "wtf/dtoa/utils.h" | 10 #include "wtf/dtoa/utils.h" |
11 #include "wtf/text/StringBuilder.h" | 11 #include "wtf/text/StringBuilder.h" |
12 | 12 |
13 #include <gtest/gtest.h> | 13 #include <gtest/gtest.h> |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 static void testMediaQuery(const char* expected, MediaQuerySet& querySet) | 17 static void testMediaQuery(const char* expected, MediaQuerySet& querySet) |
18 { | 18 { |
19 const WillBeHeapVector<OwnPtrWillBeMember<MediaQuery> >& queryVector = query
Set.queryVector(); | 19 const WillBeHeapVector<OwnPtrWillBeMember<MediaQuery>>& queryVector = queryS
et.queryVector(); |
20 size_t queryVectorSize = queryVector.size(); | 20 size_t queryVectorSize = queryVector.size(); |
21 StringBuilder output; | 21 StringBuilder output; |
22 | 22 |
23 for (size_t i = 0; i < queryVectorSize; ) { | 23 for (size_t i = 0; i < queryVectorSize; ) { |
24 String queryText = queryVector[i]->cssText(); | 24 String queryText = queryVector[i]->cssText(); |
25 output.append(queryText); | 25 output.append(queryText); |
26 ++i; | 26 ++i; |
27 if (i >= queryVectorSize) | 27 if (i >= queryVectorSize) |
28 break; | 28 break; |
29 output.appendLiteral(", "); | 29 output.appendLiteral(", "); |
(...skipping 19 matching lines...) Expand all Loading... |
49 | 49 |
50 for (unsigned i = 0; i < ARRAY_SIZE(testCases); ++i) { | 50 for (unsigned i = 0; i < ARRAY_SIZE(testCases); ++i) { |
51 RefPtrWillBeRawPtr<StyleRuleBase> rule = parser.parseRule(nullptr, Strin
g(testCases[i].input)); | 51 RefPtrWillBeRawPtr<StyleRuleBase> rule = parser.parseRule(nullptr, Strin
g(testCases[i].input)); |
52 | 52 |
53 EXPECT_TRUE(rule->isMediaRule()); | 53 EXPECT_TRUE(rule->isMediaRule()); |
54 testMediaQuery(testCases[i].output, *static_cast<StyleRuleMedia*>(rule.g
et())->mediaQueries()); | 54 testMediaQuery(testCases[i].output, *static_cast<StyleRuleMedia*>(rule.g
et())->mediaQueries()); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 } // namespace blink | 58 } // namespace blink |
OLD | NEW |