1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:27:44 +00:00

LibWeb: Add DOMQuad and text tests

This commit is contained in:
Bastiaan van der Plaat 2023-08-20 22:03:41 +02:00 committed by Sam Atkins
parent e4270bc01d
commit c88f14902b
11 changed files with 218 additions and 0 deletions

View file

@ -0,0 +1,4 @@
1. {"p1":{"x":0,"y":0,"z":0,"w":1},"p2":{"x":100,"y":0,"z":0,"w":1},"p3":{"x":100,"y":100,"z":0,"w":1},"p4":{"x":0,"y":100,"z":0,"w":1}}
2. {"p1":{"x":0,"y":0,"z":0,"w":1},"p2":{"x":100,"y":0,"z":0,"w":1},"p3":{"x":100,"y":100,"z":0,"w":1},"p4":{"x":0,"y":100,"z":0,"w":1}}
3. {"p1":{"x":0,"y":0,"z":0,"w":1},"p2":{"x":100,"y":0,"z":0,"w":1},"p3":{"x":100,"y":100,"z":0,"w":1},"p4":{"x":0,"y":100,"z":0,"w":1}}
4. {"x":0,"y":0,"width":100,"height":100,"top":0,"right":100,"bottom":100,"left":0}

View file

@ -0,0 +1,36 @@
<script src="../include.js"></script>
<script>
test(() => {
let testCounter = 1;
function testPart(part) {
println(`${testCounter++}. ${JSON.stringify(part())}`);
}
// 1. Creating a DOMQuad
testPart(() => new DOMQuad(
new DOMPoint(0, 0),
new DOMPoint(100, 0),
new DOMPoint(100, 100),
new DOMPoint(0, 100)
));
// 2. Creating DOMQuad with fromRect
testPart(() => DOMQuad.fromRect({ x: 0, y: 0, width: 100, height: 100 }));
// 3. Creating DOMQuad with fromQuad
testPart(() => DOMQuad.fromQuad({
p1: { x: 0, y: 0, z: 0, w: 1 },
p2: { x: 100, y: 0, z: 0, w: 1 },
p3: { x: 100, y: 100, z: 0, w: 1 },
p4: { x: 0, y: 100, z: 0, w: 1 }
}));
// 4. Getting the bounds of a DOMQuad
testPart(() => new DOMQuad(
new DOMPoint(0, 0),
new DOMPoint(100, 0),
new DOMPoint(100, 100),
new DOMPoint(0, 100)
).getBounds());
});
</script>