first mockup in go

This commit is contained in:
2019-08-18 23:21:16 +02:00
parent 9ce235274f
commit 969ae63d02
5638 changed files with 579400 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
var webpage = require("webpage"),
fs = require("fs");
var html_path = fs.absolute("test.html");
var examples = [];
function run_example(example_index) {
if (example_index >= examples.length) {
phantom.exit(0);
return;
}
var example = examples[example_index];
var snapshot_index = 0;
var page = webpage.create();
page.viewportSize = { width: 500, height: 300 };
page.clipRect = { width: 500, height: 300 };
page.onAlert = function (msg) {
var e = JSON.parse(msg);
if (e.fn == "snapshot") {
page.render("output/" + example.name + snapshot_index + ".png");
snapshot_index += 1;
} else if (e.fn == "mousemove") {
page.sendEvent("mousemove", e.x, e.y);
}
};
page.open(html_path, function (status) {
if (status == "fail") {
console.log("Failed to load test page: " + example.name);
phantom.exit(1);
} else {
page.evaluate(example.runner);
}
page.close();
run_example(example_index + 1);
});
}
exports.def = function (name, runner) {
examples.push({ name: name, runner: runner });
};
exports.run = function () {
if (fs.isDirectory("output")) {
fs.list("output").forEach(function (path) {
if (path != "." && path != "..") {
fs.remove("output/" + path);
}
});
} else {
fs.makeDirectory("output");
}
run_example(0);
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -0,0 +1,32 @@
#!/bin/sh
# visual_specs.js creates output in output/XXX.png
phantomjs visual_specs.js
# clear out old diffs
mkdir -p diff
rm -f diff/*
# generate diffs
PASS=1
for i in exemplary/*.png
do
FN=`basename $i`
perceptualdiff $i output/$FN -output diff/$FN
if [ $? -eq 0 ]
then
echo "OK: $FN"
else
echo "FAIL: $FN"
PASS=0
fi
done
# pass / fail
if [ $PASS -eq 1 ]
then
echo "Success."
else
echo "Failed."
exit 1
fi

View File

@@ -0,0 +1,66 @@
var examples = require('./examples');
examples.def('line', function () {
Morris.Line({
element: 'chart',
data: [
{ x: 0, y: 10, z: 30 }, { x: 1, y: 20, z: 20 },
{ x: 2, y: 30, z: 10 }, { x: 3, y: 30, z: 10 },
{ x: 4, y: 20, z: 20 }, { x: 5, y: 10, z: 30 }
],
xkey: 'x',
ykeys: ['y', 'z'],
labels: ['y', 'z'],
parseTime: false
});
window.snapshot();
});
examples.def('area', function () {
Morris.Area({
element: 'chart',
data: [
{ x: 0, y: 1, z: 1 }, { x: 1, y: 2, z: 1 },
{ x: 2, y: 3, z: 1 }, { x: 3, y: 3, z: 1 },
{ x: 4, y: 2, z: 1 }, { x: 5, y: 1, z: 1 }
],
xkey: 'x',
ykeys: ['y', 'z'],
labels: ['y', 'z'],
parseTime: false
});
window.snapshot();
});
examples.def('bar', function () {
Morris.Bar({
element: 'chart',
data: [
{ x: 0, y: 1, z: 3 }, { x: 1, y: 2, z: 2 },
{ x: 2, y: 3, z: 1 }, { x: 3, y: 3, z: 1 },
{ x: 4, y: 2, z: 2 }, { x: 5, y: 1, z: 3 }
],
xkey: 'x',
ykeys: ['y', 'z'],
labels: ['y', 'z']
});
window.snapshot();
});
examples.def('stacked_bar', function () {
Morris.Bar({
element: 'chart',
data: [
{ x: 0, y: 1, z: 1 }, { x: 1, y: 2, z: 1 },
{ x: 2, y: 3, z: 1 }, { x: 3, y: 3, z: 1 },
{ x: 4, y: 2, z: 1 }, { x: 5, y: 1, z: 1 }
],
xkey: 'x',
ykeys: ['y', 'z'],
labels: ['y', 'z'],
stacked: true
});
window.snapshot();
});
examples.run();