Skip to content

Commit 87b1e04

Browse files
working
1 parent 170b1f7 commit 87b1e04

File tree

7 files changed

+128
-98
lines changed

7 files changed

+128
-98
lines changed

build.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ git submodule update
33
rm -rf build
44
mkdir build
55
cd build
6-
qmake ../shorty
6+
qmake ../qtqmltest
77
make

build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ git submodule update
33
rm -rf build
44
mkdir build
55
cd build
6-
qmake ../shorty
7-
make
6+
qmake ../qtqmltest
7+
make

loader.qml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import QtQuick 2.5
2+
import QtQuick.Window 2.0
3+
Window {
4+
id: window
5+
visible: true
6+
minimumWidth: 0
7+
minimumHeight: 0
8+
maximumHeight: 5000
9+
maximumWidth: 10000
10+
flags: Qt.FramelessWindowHint
11+
12+
Timer{
13+
//Qt.quit cannot be called onLoaded/Completed
14+
id: quitTimer
15+
interval: 10
16+
onTriggered: {
17+
Qt.quit();
18+
}
19+
}
20+
21+
property bool loaded: false
22+
23+
24+
Loader{
25+
anchors.centerIn: parent
26+
id: loader
27+
source: "../" + script
28+
onLoaded: {
29+
window.height = item.height
30+
window.width = item.width
31+
if(item.hasOwnProperty("start"))
32+
item.start()
33+
34+
//Find tests
35+
var tests = []
36+
for(var i in item.data){
37+
var child = item.data[i]
38+
if(child.hasOwnProperty("__isTest")){
39+
child.compareRender = compare
40+
tests.push(child)
41+
}
42+
}
43+
tests.reverse();
44+
runTest(tests);
45+
}
46+
47+
//pops one test of the stack and runs it, passes a callback for the next test
48+
function runTest(tests){
49+
console.log(tests)
50+
if(tests.length <= 0){
51+
quitTimer.start()
52+
return
53+
}
54+
var test = tests.pop()
55+
console.log("TESTNAME: "+ test.name)
56+
test.start(function(){
57+
console.log("TESTDONE: "+ test.name)
58+
runTest(tests)
59+
});
60+
}
61+
62+
function compare(tag, render, callback){
63+
console.log("compare; ", tag, render, callback)
64+
if(typeof render === "function")
65+
callback = render;
66+
if(render === undefined)
67+
render = true;
68+
69+
//todo: ugly
70+
var path = source.toString()
71+
.replace("/qml/", "/png/")
72+
.replace(".qml", "")
73+
//.replace("file:///", "") //only on windows
74+
.replace("file://", "")
75+
if(tag)
76+
path = path + "-" + tag
77+
78+
if(!render){
79+
console.log("LOG: skip render" + path)
80+
callback(true)
81+
return
82+
}
83+
84+
85+
console.log("LOG: render " + path)
86+
screenshot.shootFull(path+ ".png", window)
87+
callback(true) //doesnt compare in qt only generate image
88+
}
89+
}
90+
}

qtqmltest/screenshot.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ bool fileExists(QString path) {
4242
void Screenshot::shootFull(const QString &name, QQuickWindow *view)
4343
{
4444

45-
qDebug() << "Shoot full: " << name;
46-
if(fileExists(name)) return;
45+
qDebug() << "Shoot: " << name;
46+
//if(fileExists(name)) return;
4747
QImage image = view->grabWindow();
48-
qDebug() << "Grabbed";
4948
image.save(name);
50-
qDebug() << "Saved";
5149
}
5250

5351
void Screenshot::shoot(const QString &name, QQuickWindow *view)

render.js

+25-22
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
* Created by henrikrudstrom on 29.02.16.
33
*/
44
var fs = require('fs');
5-
var exec = require("child_process").execFileSync;
6-
var execAsync = require("child_process").execFile;
5+
var execFile = require("child_process").execFileSync;
6+
var exec = require("child_process").execSync;
77
var glob = require("glob");
88

99
var devPath = __dirname.split("/").pop();
10-
var loader = "tests/qtloader.qml";
10+
var loader = "dev/loader.qml";
1111
var paths = [
12-
"tests/Tests/TestCase.qml",
13-
"tests/Tests/SimpleRenderTest.qml"
12+
"tests/Tests/qml/*.qml",
13+
//"tests/Tests/SimpleRenderTest.qml"
1414
];
1515

1616
function isRenderTest(file, callback) {
@@ -26,24 +26,31 @@ function isRenderTest(file, callback) {
2626
});
2727

2828
}
29+
if(process.argv.length == 2){
30+
paths.forEach(function(paths) {
31+
glob(paths, function(er, files) {
2932

30-
paths.forEach(function(path) {
31-
// glob(path, function(er, files) {
32-
// console.log(path)
33-
render(path);
34-
//});
35-
// glob("tests/**/*.qml", function(er, files) {
36-
// files.forEach(function(file) {
37-
// isRenderTest(file, function() { render(file); });
38-
// });
39-
// });
40-
});
33+
files.forEach(function(file) {
34+
console.log("Rendering " + file)
35+
render(file);
36+
});
37+
});
38+
// glob("tests/**/*.qml", function(er, files) {
39+
// files.forEach(function(file) {
40+
// isRenderTest(file, function() { render(file); });
41+
// });
42+
// });
43+
});
44+
} else if (process.argv.length == 3){
45+
render(process.argv[2])
46+
}
4147

4248

4349
function render(path) {
4450
//console.log(path);
4551
var png = path.replace(".qml", ".png");
46-
execRender(devPath + "/bin/shorty", loader, path);
52+
execRender(devPath + "/bin/qtqmltest", loader, path);
53+
exec("sleep 1")
4754
// try {
4855
// fs.accessSync(png, fs.F_OK);
4956
// } catch (e) {
@@ -63,10 +70,6 @@ function render(path) {
6370
}
6471

6572
function execRender(shorty, loader, file){
66-
//console.log(shorty, loader, file)
67-
//shorty = shorty.replace("/", "\\");
68-
//loader = loader.replace("/", "\\");
69-
//file = file.replace("/", "\\");
7073
console.log(shorty, loader, file)
71-
exec(shorty, [loader, file]);
74+
execFile(shorty, [loader, file]);
7275
}

simple_screenshot.qml

-62
This file was deleted.

tests.pro

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
//lupdate_only {
2-
SOURCES = *.qml \
1+
DISTFILES = *.qml \
32
../tests/Render/Simple/*.qml \
43
../tests/Render/Async/*.qml \
54
../tests/QtQuick/qml/*.qml \
65
../tests/QMLEngine/qml/*.qml \
76
../tests/Tests/*.qml \
7+
../tests/Tests/qml/*.qml \
8+
../tests/qml/*.qml
89
../tests/*.qml
9-
//}
1010

11-
DISTFILES += \
12-
../tests/Render/Async/tester.qml \
13-
TestCase2.qml \
14-
Describe.qml
11+
}
12+
13+
14+
15+
1516

1617

1718

0 commit comments

Comments
 (0)