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

Side by Side Diff: Source/core/css/parser/SizesAttributeParserTest.cpp

Issue 236713005: Use SizesAttributeParser to get the right srcset resource (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sizes_parser8
Patch Set: Added preloder and JS tests. Fixed bugs; Created 6 years, 8 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 "config.h" 5 #include "config.h"
6 #include "core/css/parser/SizesAttributeParser.h" 6 #include "core/css/parser/SizesAttributeParser.h"
7 7
8 #include "core/css/MediaValuesCached.h" 8 #include "core/css/MediaValuesCached.h"
9 9
10 #include <gtest/gtest.h> 10 #include <gtest/gtest.h>
(...skipping 28 matching lines...) Expand all
39 {" /**/ ", 500}, 39 {" /**/ ", 500},
40 {" /**/ 300px", 300}, 40 {" /**/ 300px", 300},
41 {"300px /**/ ", 300}, 41 {"300px /**/ ", 300},
42 {" /**/ (min-width:500px) /**/ 300px", 300}, 42 {" /**/ (min-width:500px) /**/ 300px", 300},
43 {"-100px, 200px", 200}, 43 {"-100px, 200px", 200},
44 {"-50vw, 20vw", 100}, 44 {"-50vw, 20vw", 100},
45 {"50asdf, 200px", 200}, 45 {"50asdf, 200px", 200},
46 {"asdf, 200px", 200}, 46 {"asdf, 200px", 200},
47 {"(max-width: 3000px) 200w, 400w", 500}, 47 {"(max-width: 3000px) 200w, 400w", 500},
48 {",, , /**/ ,200px", 200}, 48 {",, , /**/ ,200px", 200},
49 {"50vw", 250},
eseidel 2014/04/20 21:27:43 Is this enough testing? Or is most covered by the
Yoav Weiss 2014/04/20 21:48:03 The integration with HTMLImageElement and HTMLPrel
49 // FIXME - test all other units, zero length and calc(). 50 // FIXME - test all other units, zero length and calc().
50 {0, 0} // Do not remove the terminator line. 51 {0, 0} // Do not remove the terminator line.
51 }; 52 };
52 53
53 MediaValuesCached::MediaValuesCachedData data; 54 MediaValuesCached::MediaValuesCachedData data;
54 data.viewportWidth = 500; 55 data.viewportWidth = 500;
55 data.viewportHeight = 500; 56 data.viewportHeight = 500;
56 data.deviceWidth = 500; 57 data.deviceWidth = 500;
57 data.deviceHeight = 500; 58 data.deviceHeight = 500;
58 data.devicePixelRatio = 2.0; 59 data.devicePixelRatio = 2.0;
59 data.colorBitsPerComponent = 24; 60 data.colorBitsPerComponent = 24;
60 data.monochromeBitsPerComponent = 0; 61 data.monochromeBitsPerComponent = 0;
61 data.pointer = MediaValues::MousePointer; 62 data.pointer = MediaValues::MousePointer;
62 data.defaultFontSize = 16; 63 data.defaultFontSize = 16;
63 data.threeDEnabled = true; 64 data.threeDEnabled = true;
64 data.scanMediaType = false; 65 data.scanMediaType = false;
65 data.screenMediaType = true; 66 data.screenMediaType = true;
66 data.printMediaType = false; 67 data.printMediaType = false;
67 data.strictMode = true; 68 data.strictMode = true;
68 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data); 69 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data);
69 70
70 for (unsigned i = 0; testCases[i].input; ++i) { 71 for (unsigned i = 0; testCases[i].input; ++i) {
71 int effectiveSize = SizesAttributeParser::findEffectiveSize(testCases[i] .input, mediaValues); 72 int effectiveSize = SizesAttributeParser::findEffectiveSize(testCases[i] .input, mediaValues);
72 ASSERT_EQ(testCases[i].output, effectiveSize); 73 ASSERT_EQ(testCases[i].output, effectiveSize);
73 } 74 }
74 } 75 }
75 76
76 } // namespace 77 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698