4 document.write("This test must be run in a test runner.")
6 function testRects(offset, rects, radius) {
7 if (radius == undefined)
10 var gElement = document.createElementNS("http://www.w3.org/2000/svg", "g");
11 gElement.setAttribute("transform", "translate(" + offset[0] + ", " + offset[1] + ")");
12 document.getElementById("paths").appendChild(gElement);
14 for (var i in rects) {
15 var rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect");
16 rectElement.setAttribute("x", rects[i][0]);
17 rectElement.setAttribute("y", rects[i][1]);
18 rectElement.setAttribute("width", rects[i][2]);
19 rectElement.setAttribute("height", rects[i][3]);
20 rectElement.setAttribute("fill", "rgba(0, 0, 0, 0.2)");
21 rectElement.setAttribute("stroke", "rgba(0, 0, 0, 0.5)");
22 gElement.appendChild(rectElement);
25 if (window.internals) {
28 Array.prototype.push.apply(concatRects, rects[i]);
29 var pathString = window.internals.pathStringWithShrinkWrappedRects(concatRects, radius);
30 var pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
31 pathElement.setAttribute("d", pathString)
32 pathElement.setAttribute("fill", "none");
33 pathElement.setAttribute("stroke", "blue");
34 pathElement.setAttribute("stroke-width", "3");
35 gElement.appendChild(pathElement);
39 window.onload = function () {
40 // Right and left aligned, touching:
62 // Center aligned, touching:
64 testRects([170, 20], [
69 testRects([270, 20], [
74 testRects([370, 20], [
81 testRects([20, 200], [
86 testRects([120, 200], [
91 testRects([220, 200], [
96 testRects([200, 350], [
102 testRects([20, 300], [
106 // Combination of touching and non-touching:
108 testRects([280, 200], [
120 testRects([100, 300], [
124 testRects([100, 370], [
129 // Harder (widths less than the radius, horizontally arranged, etc.):
131 testRects([500, 20], [
136 testRects([600, 20], [
141 testRects([650, 100], [
146 testRects([700, 20], [
151 testRects([600, 200], [
156 testRects([700, 200], [
163 testRects([20, 450], [
166 [0, 40, 20, 20]], 100);
168 testRects([20, 520], [
171 [0, 40, 50, 20]], 100);
173 testRects([80, 450], [
176 [30, 40, 20, 20]], 100);
178 testRects([80, 520], [
181 [0, 40, 50, 20]], 100);
183 testRects([170, 450], [
186 [35, 80, 30, 40]], 100);
188 testRects([270, 450], [
191 [0, 80, 100, 40]], 100);
193 testRects([370, 450], [
196 [20, 80, 60, 40]], 100);
198 testRects([750, 500], [
205 testRects([400, 300], [
211 // Lines with overlap:
213 testRects([520, 450], [
218 testRects([520, 520], [
223 testRects([580, 450], [
228 testRects([580, 520], [
242 <svg id="paths" width="800" height="600"></svg>