Skip to content

Commit

Permalink
Merge pull request #4 from koundinyad/type-2.0
Browse files Browse the repository at this point in the history
add test screenshots for v1 and v2
  • Loading branch information
dhowe authored Nov 4, 2024
2 parents 33ae435 + 361ce52 commit c89ae65
Show file tree
Hide file tree
Showing 28 changed files with 78 additions and 45 deletions.
47 changes: 22 additions & 25 deletions test/unit/visual/cases/type.v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ visualSuite("Type.v1", function () {
);

visualTest(
"all alignments with multi-line Manual Text",
"all alignments with multi-line manual text",
function (p5, screenshot) {
const alignments = [
{ alignX: p5.LEFT, alignY: p5.TOP },
Expand Down Expand Up @@ -293,26 +293,23 @@ visualSuite("Type.v1", function () {
});

visualSuite("textLeading", function () {
visualTest(
"text leading with different values",
function (p5, screenshot) {
p5.createCanvas(300, 200);
const leadingValues = [10, 20, 30];
let yOffset = 0;
visualTest("text leading with different values", function (p5, screenshot) {
p5.createCanvas(300, 200);
const leadingValues = [10, 20, 30];
let yOffset = 0;

p5.textSize(20);
p5.textAlign(p5.LEFT, p5.TOP);

leadingValues.forEach((leading) => {
p5.textLeading(leading);
p5.text(`Leading: ${leading}`, 0, yOffset);
p5.text("This is a line of text.", 0, yOffset + 30);
p5.text("This is another line of text.", 0, yOffset + 30 + leading);
yOffset += 30 + leading;
});
screenshot();
}
);
p5.textSize(20);
p5.textAlign(p5.LEFT, p5.TOP);

leadingValues.forEach((leading) => {
p5.textLeading(leading);
p5.text(`Leading: ${leading}`, 0, yOffset);
p5.text("This is a line of text.", 0, yOffset + 30);
p5.text("This is another line of text.", 0, yOffset + 30 + leading);
yOffset += 30 + leading;
});
screenshot();
});
});

visualSuite("textWidth", function () {
Expand Down Expand Up @@ -557,10 +554,10 @@ export function visualTest(
);
const expected = expectedScreenshots
? await Promise.all(
expectedFilenames.map((path) =>
myp5.loadImage("/unit/visual" + path.slice(2))
expectedFilenames.map((path) =>
myp5.loadImage("/unit/visual" + path.slice(2))
)
)
)
: [];

for (let i = 0; i < actual.length; i++) {
Expand All @@ -573,8 +570,8 @@ export function visualTest(
)}\n\nReceived:\n${toBase64(actual[i])}\n\nDiff:\n${toBase64(
result.diff
)}\n\n` +
"If this is unexpected, paste these URLs into your browser to inspect them.\n\n" +
`If this change is expected, please delete the screenshots/${name} folder and run tests again to generate a new screenshot.`
"If this is unexpected, paste these URLs into your browser to inspect them.\n\n" +
`If this change is expected, please delete the screenshots/${name} folder and run tests again to generate a new screenshot.`
);
}
} else {
Expand Down
37 changes: 17 additions & 20 deletions test/unit/visual/cases/type.v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ visualSuite("Type.v2", function () {
);

visualTest(
"all alignments with multi-line Manual Text",
"all alignments with multi-line manual text",
function (p5, screenshot) {
const alignments = [
{ alignX: p5.LEFT, alignY: p5.TOP },
Expand Down Expand Up @@ -288,26 +288,23 @@ visualSuite("Type.v2", function () {
});

visualSuite("textLeading", function () {
visualTest(
"text leading with different values",
function (p5, screenshot) {
p5.createCanvas(300, 200);
const leadingValues = [10, 20, 30];
let yOffset = 0;
visualTest("text leading with different values", function (p5, screenshot) {
p5.createCanvas(300, 200);
const leadingValues = [10, 20, 30];
let yOffset = 0;

p5.textSize(20);
p5.textAlign(p5.LEFT, p5.TOP);

leadingValues.forEach((leading) => {
p5.textLeading(leading);
p5.text(`Leading: ${leading}`, 0, yOffset);
p5.text("This is a line of text.", 0, yOffset + 30);
p5.text("This is another line of text.", 0, yOffset + 30 + leading);
yOffset += 30 + leading;
});
screenshot();
}
);
p5.textSize(20);
p5.textAlign(p5.LEFT, p5.TOP);

leadingValues.forEach((leading) => {
p5.textLeading(leading);
p5.text(`Leading: ${leading}`, 0, yOffset);
p5.text("This is a line of text.", 0, yOffset + 30);
p5.text("This is another line of text.", 0, yOffset + 30 + leading);
yOffset += 30 + leading;
});
screenshot();
});
});

visualSuite("textWidth", function () {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"numScreenshots": 1
}

0 comments on commit c89ae65

Please sign in to comment.