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

Side by Side Diff: sky/engine/core/css/parser/SizesAttributeParserTest.cpp

Issue 732813002: Remove sizes attr. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
(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 #include "core/css/parser/SizesAttributeParser.h"
7
8 #include "core/MediaTypeNames.h"
9 #include "core/css/MediaValuesCached.h"
10
11 #include <gtest/gtest.h>
12
13 namespace blink {
14
15 typedef struct {
16 const char* input;
17 const unsigned effectiveSize;
18 const bool viewportDependant;
19 } TestCase;
20
21 TEST(SizesAttributeParserTest, Basic)
22 {
23 TestCase testCases[] = {
24 {"screen", 500, true},
25 {"(min-width:500px)", 500, true},
26 {"(min-width:500px) 200px", 200, false},
27 {"(min-width:500px) 50vw", 250, true},
28 {"(min-width:500px) 200px, 400px", 200, false},
29 {"400px, (min-width:500px) 200px", 400, false},
30 {"40vw, (min-width:500px) 201px", 200, true},
31 {"(min-width:500px) 201px, 40vw", 201, false},
32 {"(min-width:5000px) 40vw, 201px", 201, false},
33 {"(min-width:500px) calc(201px), calc(40vw)", 201, false},
34 {"(min-width:5000px) calc(40vw), calc(201px)", 201, false},
35 {"(min-width:5000px) 200px, 400px", 400, false},
36 {"(blalbadfsdf) 200px, 400px", 400, false},
37 {"0", 0, false},
38 {"-0", 0, false},
39 {"1", 500, true},
40 {"300px, 400px", 300, false},
41 {"(min-width:5000px) 200px, (min-width:500px) 400px", 400, false},
42 {"", 500, true},
43 {" ", 500, true},
44 {" /**/ ", 500, true},
45 {" /**/ 300px", 300, false},
46 {"300px /**/ ", 300, false},
47 {" /**/ (min-width:500px) /**/ 300px", 300, false},
48 {"-100px, 200px", 200, false},
49 {"-50vw, 20vw", 100, true},
50 {"50asdf, 200px", 200, false},
51 {"asdf, 200px", 200, false},
52 {"(max-width: 3000px) 200w, 400w", 500, true},
53 {",, , /**/ ,200px", 200, false},
54 {"50vw", 250, true},
55 {"5em", 80, false},
56 {"5rem", 80, false},
57 {"calc(40vw*2)", 400, true},
58 {"(min-width:5000px) calc(5000px/10), (min-width:500px) calc(1200px/3)", 400, false},
59 {"(min-width:500px) calc(1200/3)", 500, true},
60 {"(min-width:500px) calc(1200px/(0px*14))", 500, true},
61 {"(max-width: 3000px) 200px, 400px", 200, false},
62 {"(max-width: 3000px) 20em, 40em", 320, false},
63 {"(max-width: 3000px) 0, 40em", 0, false},
64 {"(max-width: 3000px) 50vw, 40em", 250, true},
65 {"(max-width: 3000px) 50px, 40vw", 50, false},
66 {0, 0, false} // Do not remove the terminator line.
67 };
68
69 MediaValuesCached::MediaValuesCachedData data;
70 data.viewportWidth = 500;
71 data.viewportHeight = 500;
72 data.deviceWidth = 500;
73 data.deviceHeight = 500;
74 data.devicePixelRatio = 2.0;
75 data.colorBitsPerComponent = 24;
76 data.monochromeBitsPerComponent = 0;
77 data.primaryPointerType = PointerTypeFine;
78 data.defaultFontSize = 16;
79 data.threeDEnabled = true;
80 data.mediaType = MediaTypeNames::screen;
81 data.strictMode = true;
82 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data);
83
84 for (unsigned i = 0; testCases[i].input; ++i) {
85 SizesAttributeParser parser(mediaValues, testCases[i].input);
86 ASSERT_EQ(testCases[i].effectiveSize, parser.length());
87 ASSERT_EQ(testCases[i].viewportDependant, parser.viewportDependant());
88 }
89 }
90
91 } // namespace
OLDNEW
« no previous file with comments | « sky/engine/core/css/parser/SizesAttributeParser.cpp ('k') | sky/engine/core/html/HTMLImageElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698