Skip to content

Commit 2e4b3ad

Browse files
Merge branch 'merge-qml-testing'
Conflicts: render.js
2 parents 45221ed + 2ee8848 commit 2e4b3ad

14 files changed

+700
-56
lines changed

.gitmodules

-3
This file was deleted.

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.replace(" ", "_")
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+
}

0 commit comments

Comments
 (0)