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

Side by Side Diff: third_party/WebKit/Source/core/css/MediaQuerySetTest.cpp

Issue 2017303002: Revert of Remove StringBuilder::appendLiteral. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 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 "core/css/MediaQuery.h" 5 #include "core/css/MediaQuery.h"
6 6
7 #include "core/css/MediaList.h" 7 #include "core/css/MediaList.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "wtf/PassOwnPtr.h" 9 #include "wtf/PassOwnPtr.h"
10 #include "wtf/text/StringBuilder.h" 10 #include "wtf/text/StringBuilder.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 typedef struct { 14 typedef struct {
15 const char* input; 15 const char* input;
16 const char* output; 16 const char* output;
17 bool shouldWorkOnOldParser; 17 bool shouldWorkOnOldParser;
18 } TestCase; 18 } TestCase;
19 19
20 static void testMediaQuery(TestCase test, MediaQuerySet& querySet, bool oldParse r) 20 static void testMediaQuery(TestCase test, MediaQuerySet& querySet, bool oldParse r)
21 { 21 {
22 StringBuilder output; 22 StringBuilder output;
23 size_t j = 0; 23 size_t j = 0;
24 while (j < querySet.queryVector().size()) { 24 while (j < querySet.queryVector().size()) {
25 String queryText = querySet.queryVector()[j]->cssText(); 25 String queryText = querySet.queryVector()[j]->cssText();
26 output.append(queryText); 26 output.append(queryText);
27 ++j; 27 ++j;
28 if (j >= querySet.queryVector().size()) 28 if (j >= querySet.queryVector().size())
29 break; 29 break;
30 output.append(", "); 30 output.appendLiteral(", ");
31 } 31 }
32 if (!oldParser || test.shouldWorkOnOldParser) { 32 if (!oldParser || test.shouldWorkOnOldParser) {
33 if (test.output) 33 if (test.output)
34 ASSERT_STREQ(test.output, output.toString().ascii().data()); 34 ASSERT_STREQ(test.output, output.toString().ascii().data());
35 else 35 else
36 ASSERT_STREQ(test.input, output.toString().ascii().data()); 36 ASSERT_STREQ(test.input, output.toString().ascii().data());
37 } 37 }
38 } 38 }
39 39
40 TEST(MediaQuerySetTest, Basic) 40 TEST(MediaQuerySetTest, Basic)
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 for (unsigned i = 0; testCases[i].input; ++i) { 173 for (unsigned i = 0; testCases[i].input; ++i) {
174 MediaQuerySet* oldParserQuerySet = MediaQuerySet::create(testCases[i].in put); 174 MediaQuerySet* oldParserQuerySet = MediaQuerySet::create(testCases[i].in put);
175 MediaQuerySet* threadSafeQuerySet = MediaQuerySet::createOffMainThread(t estCases[i].input); 175 MediaQuerySet* threadSafeQuerySet = MediaQuerySet::createOffMainThread(t estCases[i].input);
176 testMediaQuery(testCases[i], *oldParserQuerySet, true); 176 testMediaQuery(testCases[i], *oldParserQuerySet, true);
177 testMediaQuery(testCases[i], *threadSafeQuerySet, false); 177 testMediaQuery(testCases[i], *threadSafeQuerySet, false);
178 } 178 }
179 } 179 }
180 180
181 } // namespace blink 181 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaQueryExp.cpp ('k') | third_party/WebKit/Source/core/css/StylePropertySerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698