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

Side by Side Diff: LayoutTests/svg/zoom/page/zoom-zoom-coords.xhtml

Issue 1038463002: Add a tolerance factor to the test. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: rebase Created 5 years, 9 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 | « LayoutTests/TestExpectations ('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 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/x link"> 1 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/x link">
2 <head> 2 <head>
3 <style type="text/css"> 3 <style type="text/css">
4 @font-face { 4 @font-face {
5 font-family: "Ahem"; 5 font-family: "Ahem";
6 src: url(../../../resources/Ahem.ttf); 6 src: url(../../../resources/Ahem.ttf);
7 } 7 }
8 body { 8 body {
9 margin:0px; 9 margin:0px;
10 border:0px; 10 border:0px;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 <image id="image3" x="100px" y="0" width="50px" height="50px" xlink:href="../. ./W3C-SVG-1.1/resources/magnify.png" /> 46 <image id="image3" x="100px" y="0" width="50px" height="50px" xlink:href="../. ./W3C-SVG-1.1/resources/magnify.png" />
47 <text id="text3" x="100px" y="75px">Test</text> 47 <text id="text3" x="100px" y="75px">Test</text>
48 </svg> 48 </svg>
49 </div> 49 </div>
50 50
51 <div id="description"></div> 51 <div id="description"></div>
52 <div id="console"></div> 52 <div id="console"></div>
53 53
54 <script> 54 <script>
55 function executeTest() { 55 function executeTest() {
56 // 0.02 is slightly larger than one LayoutUnit, which is the biggest allowab le difference.
57 var tolerance = 0.02;
58
56 description("This test checks getBoundingClientRect() on zoomed HTML and SVG elements"); 59 description("This test checks getBoundingClientRect() on zoomed HTML and SVG elements");
57 60
58 debug("Gray rectangles: 100x50"); 61 debug("Gray rectangles: 100x50");
59 debug("Green rectangles: 100x50, zoom=200%"); 62 debug("Green rectangles: 100x50, zoom=200%");
60 debug("Blue rectangles: 200x100, zoom=50%"); 63 debug("Blue rectangles: 200x100, zoom=50%");
61 debug(""); 64 debug("");
62 65
63 debug("Checking HTML elements:"); 66 debug("Checking HTML elements:");
64 debug(""); 67 debug("");
65 68
66 div1 = document.getElementById("div1").getBoundingClientRect(); 69 div1 = document.getElementById("div1").getBoundingClientRect();
67 shouldBeEqualToString('div1.left.toFixed(2)', '0.00'); 70 shouldBe('div1.left', '0.00', false, tolerance);
68 shouldBeEqualToString('div1.top.toFixed(2)', '0.00'); 71 shouldBe('div1.top', '0.00', false, tolerance);
69 shouldBeEqualToString('div1.width.toFixed(2)', '100.00'); 72 shouldBe('div1.width', '100.00', false, tolerance);
70 shouldBeEqualToString('div1.height.toFixed(2)', '50.00'); 73 shouldBe('div1.height', '50.00', false, tolerance);
71 shouldBeEqualToString('div1.right.toFixed(2)', '100.00'); 74 shouldBe('div1.right', '100.00', false, tolerance);
72 shouldBeEqualToString('div1.bottom.toFixed(2)', '50.00'); 75 shouldBe('div1.bottom', '50.00', false, tolerance);
73 debug(""); 76 debug("");
74 77
75 div2 = document.getElementById("div2").getBoundingClientRect(); 78 div2 = document.getElementById("div2").getBoundingClientRect();
76 shouldBeEqualToString('div2.left.toFixed(2)', '0.00'); 79 shouldBe('div2.left', '0.00', false, tolerance);
77 shouldBeEqualToString('div2.top.toFixed(2)', '25.00'); 80 shouldBe('div2.top', '25.00', false, tolerance);
78 shouldBeEqualToString('div2.width.toFixed(2)', '100.00'); 81 shouldBe('div2.width', '100.00', false, tolerance);
79 shouldBeEqualToString('div2.height.toFixed(2)', '50.00'); 82 shouldBe('div2.height', '50.00', false, tolerance);
80 shouldBeEqualToString('div2.right.toFixed(2)', '100.00'); 83 shouldBe('div2.right', '100.00', false, tolerance);
81 shouldBeEqualToString('div2.bottom.toFixed(2)', '75.00'); 84 shouldBe('div2.bottom', '75.00', false, tolerance);
82 debug(""); 85 debug("");
83 86
84 div3 = document.getElementById("div3").getBoundingClientRect(); 87 div3 = document.getElementById("div3").getBoundingClientRect();
85 shouldBeEqualToString('div3.left.toFixed(2)', '0.00'); 88 shouldBe('div3.left', '0.00', false, tolerance);
86 shouldBeEqualToString('div3.top.toFixed(2)', '300.00'); 89 shouldBe('div3.top', '300.00', false, tolerance);
87 shouldBeEqualToString('div3.width.toFixed(2)', '200.00'); 90 shouldBe('div3.width', '200.00', false, tolerance);
88 shouldBeEqualToString('div3.height.toFixed(2)', '100.00'); 91 shouldBe('div3.height', '100.00', false, tolerance);
89 shouldBeEqualToString('div3.right.toFixed(2)', '200.00'); 92 shouldBe('div3.right', '200.00', false, tolerance);
90 shouldBeEqualToString('div3.bottom.toFixed(2)', '400.00'); 93 shouldBe('div3.bottom', '400.00', false, tolerance);
91 debug(""); 94 debug("");
92 95
93 debug("Checking SVG elements:"); 96 debug("Checking SVG elements:");
94 debug(""); 97 debug("");
95 98
96 svg1 = document.getElementById("svg1").getBoundingClientRect(); 99 svg1 = document.getElementById("svg1").getBoundingClientRect();
97 shouldBeEqualToString('svg1.left.toFixed(2)', '0.00'); 100 shouldBe('svg1.left', '0.00', false, tolerance);
98 shouldBeEqualToString('svg1.top.toFixed(2)', '250.00'); 101 shouldBe('svg1.top', '250.00', false, tolerance);
99 shouldBeEqualToString('svg1.width.toFixed(2)', '150.00'); 102 shouldBe('svg1.width', '150.00', false, tolerance);
100 shouldBeEqualToString('svg1.height.toFixed(2)', '50.00'); 103 shouldBe('svg1.height', '50.00', false, tolerance);
101 shouldBeEqualToString('svg1.right.toFixed(2)', '150.00'); 104 shouldBe('svg1.right', '150.00', false, tolerance);
102 shouldBeEqualToString('svg1.bottom.toFixed(2)', '300.00'); 105 shouldBe('svg1.bottom', '300.00', false, tolerance);
103 rect1 = document.getElementById("rect1").getBoundingClientRect(); 106 rect1 = document.getElementById("rect1").getBoundingClientRect();
104 shouldBeEqualToString('rect1.left.toFixed(2)', '0.00'); 107 shouldBe('rect1.left', '0.00', false, tolerance);
105 shouldBeEqualToString('rect1.top.toFixed(2)', '250.00'); 108 shouldBe('rect1.top', '250.00', false, tolerance);
106 shouldBeEqualToString('rect1.width.toFixed(2)', '100.00'); 109 shouldBe('rect1.width', '100.00', false, tolerance);
107 shouldBeEqualToString('rect1.height.toFixed(2)', '50.00'); 110 shouldBe('rect1.height', '50.00', false, tolerance);
108 shouldBeEqualToString('rect1.right.toFixed(2)', '100.00'); 111 shouldBe('rect1.right', '100.00', false, tolerance);
109 shouldBeEqualToString('rect1.bottom.toFixed(2)', '300.00'); 112 shouldBe('rect1.bottom', '300.00', false, tolerance);
110 image1 = document.getElementById("image1").getBoundingClientRect(); 113 image1 = document.getElementById("image1").getBoundingClientRect();
111 shouldBeEqualToString('image1.left.toFixed(2)', '100.00'); 114 shouldBe('image1.left', '100.00', false, tolerance);
112 shouldBeEqualToString('image1.top.toFixed(2)', '250.00'); 115 shouldBe('image1.top', '250.00', false, tolerance);
113 shouldBeEqualToString('image1.width.toFixed(2)', '50.00'); 116 shouldBe('image1.width', '50.00', false, tolerance);
114 shouldBeEqualToString('image1.height.toFixed(2)', '25.00'); 117 shouldBe('image1.height', '25.00', false, tolerance);
115 shouldBeEqualToString('image1.right.toFixed(2)', '150.00'); 118 shouldBe('image1.right', '150.00', false, tolerance);
116 shouldBeEqualToString('image1.bottom.toFixed(2)', '275.00'); 119 shouldBe('image1.bottom', '275.00', false, tolerance);
117 text1 = document.getElementById("text1").getBoundingClientRect(); 120 text1 = document.getElementById("text1").getBoundingClientRect();
118 shouldBeEqualToString('text1.left.toFixed(2)', '100.00'); 121 shouldBe('text1.left', '100.00', false, tolerance);
119 shouldBeEqualToString('text1.top.toFixed(2)', '282.66'); 122 shouldBe('text1.top', '282.66', false, tolerance);
120 shouldBeEqualToString('text1.width.toFixed(2)', '49.20'); 123 shouldBe('text1.width', '47.98', false, tolerance);
121 shouldBeEqualToString('text1.height.toFixed(2)', '6.16'); 124 shouldBe('text1.height', '6.16', false, tolerance);
122 shouldBeEqualToString('text1.right.toFixed(2)', '149.20'); 125 shouldBe('text1.right', '147.98', false, tolerance);
123 shouldBeEqualToString('text1.bottom.toFixed(2)', '288.82'); 126 shouldBe('text1.bottom', '288.82', false, tolerance);
124 debug(""); 127 debug("");
125 128
126 svg2 = document.getElementById("svg2").getBoundingClientRect(); 129 svg2 = document.getElementById("svg2").getBoundingClientRect();
127 shouldBeEqualToString('svg2.left.toFixed(2)', '75.00'); 130 shouldBe('svg2.left', '75.00', false, tolerance);
128 shouldBeEqualToString('svg2.top.toFixed(2)', '100.00'); 131 shouldBe('svg2.top', '100.00', false, tolerance);
129 shouldBeEqualToString('svg2.width.toFixed(2)', '150.00'); 132 shouldBe('svg2.width', '150.00', false, tolerance);
130 shouldBeEqualToString('svg2.height.toFixed(2)', '50.00'); 133 shouldBe('svg2.height', '50.00', false, tolerance);
131 shouldBeEqualToString('svg2.right.toFixed(2)', '225.00'); 134 shouldBe('svg2.right', '225.00', false, tolerance);
132 shouldBeEqualToString('svg2.bottom.toFixed(2)', '150.00'); 135 shouldBe('svg2.bottom', '150.00', false, tolerance);
133 rect2 = document.getElementById("rect2").getBoundingClientRect(); 136 rect2 = document.getElementById("rect2").getBoundingClientRect();
134 shouldBeEqualToString('rect2.left.toFixed(2)', '75.00'); 137 shouldBe('rect2.left', '75.00', false, tolerance);
135 shouldBeEqualToString('rect2.top.toFixed(2)', '100.00'); 138 shouldBe('rect2.top', '100.00', false, tolerance);
136 shouldBeEqualToString('rect2.width.toFixed(2)', '100.00'); 139 shouldBe('rect2.width', '100.00', false, tolerance);
137 shouldBeEqualToString('rect2.height.toFixed(2)', '50.00'); 140 shouldBe('rect2.height', '50.00', false, tolerance);
138 shouldBeEqualToString('rect2.right.toFixed(2)', '175.00'); 141 shouldBe('rect2.right', '175.00', false, tolerance);
139 shouldBeEqualToString('rect2.bottom.toFixed(2)', '150.00'); 142 shouldBe('rect2.bottom', '150.00', false, tolerance);
140 image2 = document.getElementById("image2").getBoundingClientRect(); 143 image2 = document.getElementById("image2").getBoundingClientRect();
141 shouldBeEqualToString('image2.left.toFixed(2)', '175.00'); 144 shouldBe('image2.left', '175.00', false, tolerance);
142 shouldBeEqualToString('image2.top.toFixed(2)', '100.00'); 145 shouldBe('image2.top', '100.00', false, tolerance);
143 shouldBeEqualToString('image2.width.toFixed(2)', '50.00'); 146 shouldBe('image2.width', '50.00', false, tolerance);
144 shouldBeEqualToString('image2.height.toFixed(2)', '25.00'); 147 shouldBe('image2.height', '25.00', false, tolerance);
145 shouldBeEqualToString('image2.right.toFixed(2)', '225.00'); 148 shouldBe('image2.right', '225.00', false, tolerance);
146 shouldBeEqualToString('image2.bottom.toFixed(2)', '125.00'); 149 shouldBe('image2.bottom', '125.00', false, tolerance);
147 text2 = document.getElementById("text2").getBoundingClientRect(); 150 text2 = document.getElementById("text2").getBoundingClientRect();
148 shouldBeEqualToString('text2.left.toFixed(2)', '175.00'); 151 shouldBe('text2.left', '175.00', false, tolerance);
149 shouldBeEqualToString('text2.top.toFixed(2)', '132.66'); 152 shouldBe('text2.top', '132.66', false, tolerance);
150 shouldBeEqualToString('text2.width.toFixed(2)', '47.44'); 153 shouldBe('text2.width', '47.98', false, tolerance);
151 shouldBeEqualToString('text2.height.toFixed(2)', '5.94'); 154 shouldBe('text2.height', '5.94', false, tolerance);
152 shouldBeEqualToString('text2.right.toFixed(2)', '222.44'); 155 shouldBe('text2.right', '222.98', false, tolerance);
153 shouldBeEqualToString('text2.bottom.toFixed(2)', '138.60'); 156 shouldBe('text2.bottom', '138.60', false, tolerance);
154 debug(""); 157 debug("");
155 158
156 svg3 = document.getElementById("svg3").getBoundingClientRect(); 159 svg3 = document.getElementById("svg3").getBoundingClientRect();
157 shouldBeEqualToString('svg3.left.toFixed(2)', '900.00'); 160 shouldBe('svg3.left', '900.00', false, tolerance);
158 shouldBeEqualToString('svg3.top.toFixed(2)', '500.00'); 161 shouldBe('svg3.top', '500.00', false, tolerance);
159 shouldBeEqualToString('svg3.width.toFixed(2)', '300.00'); 162 shouldBe('svg3.width', '300.00', false, tolerance);
160 shouldBeEqualToString('svg3.height.toFixed(2)', '100.00'); 163 shouldBe('svg3.height', '100.00', false, tolerance);
161 shouldBeEqualToString('svg3.right.toFixed(2)', '1200.00'); 164 shouldBe('svg3.right', '1200.00', false, tolerance);
162 shouldBeEqualToString('svg3.bottom.toFixed(2)', '600.00'); 165 shouldBe('svg3.bottom', '600.00', false, tolerance);
163 rect3 = document.getElementById("rect3").getBoundingClientRect(); 166 rect3 = document.getElementById("rect3").getBoundingClientRect();
164 shouldBeEqualToString('rect3.left.toFixed(2)', '900.00'); 167 shouldBe('rect3.left', '900.00', false, tolerance);
165 shouldBeEqualToString('rect3.top.toFixed(2)', '500.00'); 168 shouldBe('rect3.top', '500.00', false, tolerance);
166 shouldBeEqualToString('rect3.width.toFixed(2)', '200.00'); 169 shouldBe('rect3.width', '200.00', false, tolerance);
167 shouldBeEqualToString('rect3.height.toFixed(2)', '100.00'); 170 shouldBe('rect3.height', '100.00', false, tolerance);
168 shouldBeEqualToString('rect3.right.toFixed(2)', '1100.00'); 171 shouldBe('rect3.right', '1100.00', false, tolerance);
169 shouldBeEqualToString('rect3.bottom.toFixed(2)', '600.00'); 172 shouldBe('rect3.bottom', '600.00', false, tolerance);
170 image3 = document.getElementById("image3").getBoundingClientRect(); 173 image3 = document.getElementById("image3").getBoundingClientRect();
171 shouldBeEqualToString('image3.left.toFixed(2)', '1100.00'); 174 shouldBe('image3.left', '1100.00', false, tolerance);
172 shouldBeEqualToString('image3.top.toFixed(2)', '500.00'); 175 shouldBe('image3.top', '500.00', false, tolerance);
173 shouldBeEqualToString('image3.width.toFixed(2)', '100.00'); 176 shouldBe('image3.width', '100.00', false, tolerance);
174 shouldBeEqualToString('image3.height.toFixed(2)', '50.00'); 177 shouldBe('image3.height', '50.00', false, tolerance);
175 shouldBeEqualToString('image3.right.toFixed(2)', '1200.00'); 178 shouldBe('image3.right', '1200.00', false, tolerance);
176 shouldBeEqualToString('image3.bottom.toFixed(2)', '550.00'); 179 shouldBe('image3.bottom', '550.00', false, tolerance);
177 text3 = document.getElementById("text3").getBoundingClientRect(); 180 text3 = document.getElementById("text3").getBoundingClientRect();
178 shouldBeEqualToString('text3.left.toFixed(2)', '1100.00'); 181 shouldBe('text3.left', '1100.00', false, tolerance);
179 shouldBeEqualToString('text3.top.toFixed(2)', '565.33'); 182 shouldBe('text3.top', '565.33', false, tolerance);
180 shouldBeEqualToString('text3.width.toFixed(2)', '98.41'); 183 shouldBe('text3.width', '95.97', false, tolerance);
181 shouldBeEqualToString('text3.height.toFixed(2)', '12.31'); 184 shouldBe('text3.height', '12.31', false, tolerance);
182 shouldBeEqualToString('text3.right.toFixed(2)', '1198.41'); 185 shouldBe('text3.right', '1195.97', false, tolerance);
183 shouldBeEqualToString('text3.bottom.toFixed(2)', '577.64'); 186 shouldBe('text3.bottom', '577.64', false, tolerance);
184 debug(""); 187 debug("");
185 } 188 }
186 </script> 189 </script>
187 190
188 <script src="../../../resources/js-test.js"></script> 191 <script src="../../../resources/js-test.js"></script>
189 <script>var zoomCount = 2;</script> 192 <script>var zoomCount = 2;</script>
190 <script src="../../../fast/repaint/resources/text-based-repaint.js"></script> 193 <script src="../../../fast/repaint/resources/text-based-repaint.js"></script>
191 <script src="../resources/testPageZoom.js"></script> 194 <script src="../resources/testPageZoom.js"></script>
192 <script> 195 <script>
193 if (window.testRunner) { 196 if (window.testRunner) {
194 window.jsTestIsAsync = true; 197 window.jsTestIsAsync = true;
195 window.postZoomCallback = executeTest; 198 window.postZoomCallback = executeTest;
196 document.fonts.ready.then(function() { 199 document.fonts.ready.then(function() {
197 forceStyleRecalc(); 200 forceStyleRecalc();
198 repaintTest() 201 repaintTest()
199 }); 202 });
200 } else { 203 } else {
201 debug("This test only works in DRT."); 204 debug("This test only works in DRT.");
202 } 205 }
203 </script> 206 </script>
204 207
205 </body> 208 </body>
206 </html> 209 </html>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698