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

Side by Side Diff: Source/core/html/parser/HTMLSrcsetParserTest.cpp

Issue 311053011: Initialize all ImageCandidate's member variables (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added initialization test Created 6 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
« no previous file with comments | « Source/core/html/parser/HTMLSrcsetParser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 #include "core/html/parser/HTMLSrcsetParser.h" 6 #include "core/html/parser/HTMLSrcsetParser.h"
7 7
8 #include <gtest/gtest.h> 8 #include <gtest/gtest.h>
9 #include <limits.h> 9 #include <limits.h>
10 10
11 namespace WebCore { 11 namespace WebCore {
12 12
13 typedef struct { 13 typedef struct {
14 float deviceScaleFactor; 14 float deviceScaleFactor;
15 int effectiveSize; 15 int effectiveSize;
16 const char* srcInput; 16 const char* srcInput;
17 const char* srcsetInput; 17 const char* srcsetInput;
18 const char* outputURL; 18 const char* outputURL;
19 float outputDensity; 19 float outputDensity;
20 int outputResourceWidth; 20 int outputResourceWidth;
21 } TestCase; 21 } TestCase;
22 22
23 TEST(ImageCandidateTest, Basic)
24 {
25 ImageCandidate candidate;
26 ASSERT_EQ(candidate.density(), 1);
27 ASSERT_EQ(candidate.resourceWidth(), -1);
28 ASSERT_EQ(candidate.srcOrigin(), false);
29
30 }
31
23 TEST(HTMLSrcsetParserTest, Basic) 32 TEST(HTMLSrcsetParserTest, Basic)
24 { 33 {
25 TestCase testCases[] = { 34 TestCase testCases[] = {
26 {2.0, -1, "", "1x.gif 1x, 2x.gif 2x", "2x.gif", 2.0, -1}, 35 {2.0, -1, "", "1x.gif 1x, 2x.gif 2x", "2x.gif", 2.0, -1},
27 {2.0, -1, "", "1x.gif 1q, 2x.gif 2x", "2x.gif", 2.0, -1}, 36 {2.0, -1, "", "1x.gif 1q, 2x.gif 2x", "2x.gif", 2.0, -1},
28 {1.0, -1, "", "1x.gif 1q, 2x.gif 2x", "1x.gif", 1.0, -1}, 37 {1.0, -1, "", "1x.gif 1q, 2x.gif 2x", "1x.gif", 1.0, -1},
29 {1.0, -1, "", "1x.gif 1x 100h, 2x.gif 2x", "2x.gif", 2.0, -1}, 38 {1.0, -1, "", "1x.gif 1x 100h, 2x.gif 2x", "2x.gif", 2.0, -1},
30 {1.0, -1, "", "1x.gif 1x 100w, 2x.gif 2x", "2x.gif", 2.0, -1}, 39 {1.0, -1, "", "1x.gif 1x 100w, 2x.gif 2x", "2x.gif", 2.0, -1},
31 {1.0, -1, "", "1x.gif 1x 100h 100w, 2x.gif 2x", "2x.gif", 2.0, -1}, 40 {1.0, -1, "", "1x.gif 1x 100h 100w, 2x.gif 2x", "2x.gif", 2.0, -1},
32 {2.0, -1, "", "1x.gif 1x, 2x.gif -2x", "1x.gif", 1.0, -1}, 41 {2.0, -1, "", "1x.gif 1x, 2x.gif -2x", "1x.gif", 1.0, -1},
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 for (unsigned i = 0; testCases[i].srcInput; ++i) { 93 for (unsigned i = 0; testCases[i].srcInput; ++i) {
85 TestCase test = testCases[i]; 94 TestCase test = testCases[i];
86 ImageCandidate candidate = bestFitSourceForImageAttributes(test.deviceSc aleFactor, test.effectiveSize, test.srcInput, test.srcsetInput); 95 ImageCandidate candidate = bestFitSourceForImageAttributes(test.deviceSc aleFactor, test.effectiveSize, test.srcInput, test.srcsetInput);
87 ASSERT_EQ(test.outputDensity, candidate.density()); 96 ASSERT_EQ(test.outputDensity, candidate.density());
88 ASSERT_EQ(test.outputResourceWidth, candidate.resourceWidth()); 97 ASSERT_EQ(test.outputResourceWidth, candidate.resourceWidth());
89 ASSERT_STREQ(test.outputURL, candidate.toString().ascii().data()); 98 ASSERT_STREQ(test.outputURL, candidate.toString().ascii().data());
90 } 99 }
91 } 100 }
92 101
93 } // namespace 102 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLSrcsetParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698