Skip to content

Commit 2fc97ad

Browse files
committed
Merge remote-tracking branch 'origin/test'
2 parents 3f06b6e + 8939fe6 commit 2fc97ad

File tree

21 files changed

+276
-1654
lines changed

21 files changed

+276
-1654
lines changed

tests/automation/after_close_previous_window_then_open_new/mocha_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('after close previous window then open new', function() {
1919

2020
before(function(done) {
2121
this.timeout(0);
22-
if (!fs.exists(dumpDir))
22+
if (!fs.existsSync(dumpDir))
2323
fs.mkdirSync(dumpDir);
2424

2525
var appPath = path.join(global.tests_dir, 'internal');

tests/automation/app/index.html

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<title>Test Case for 'App.clearCache'</title>
6-
</head>
7-
<body onload='fun()'>
8-
<p id="wait" style="font-size:1.5em">Please wait to be closed.</p>
9-
</body>
10-
</html>
11-
<script>
12-
var test_done = false;
13-
function fun() {
14-
var win2 = gui.Window.open('index2.html');
15-
setTimeout(function() {
16-
test_done = true;
17-
}, 1000);
18-
}
19-
</script>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>app test</title>
6+
</head>
7+
<body>
8+
<p>app test</p>
209

2110
<script src="../res/mocha_util.js"></script>
2211
<script src="mocha_test.js"></script>
12+
13+
</body>
14+
15+
</html>
16+

tests/automation/app/index2.html

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/automation/app/mocha_test.js

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,52 @@
11
var gui = require('nw.gui');
2+
var path = require('path');
23
var assert = require('assert');
3-
var app_test = require('../../nw_test_app');
4-
//var local_server = require('../../server/server');
5-
var global = require('../globals');
4+
var fs = require('fs-extra');
5+
var curDir = fs.realpathSync('.');
66

77
describe('gui.App', function() {
8-
before(function(done) {
9-
this.timeout(0);
10-
var checkDone = function() {
11-
if (test_done)
12-
done();
13-
else
14-
setTimeout(function() {checkDone();}, 2000);
15-
}
16-
checkDone();
178

9+
10+
var server, child, result = false;
11+
12+
before(function(done) {
13+
this.timeout(0);
14+
server = createTCPServer(13013);
15+
child = spawnChildProcess(path.join(curDir, 'internal'));
16+
server.on('connection', function(socket) {
17+
socket.setEncoding('utf8');
18+
socket.on('data', function(data) {
19+
result = true;
20+
child.kill();
21+
done();
22+
});
1823
});
1924

25+
setTimeout(function() {
26+
if (!result) {
27+
child.kill();
28+
done('timeout');
29+
}
30+
}, 4500);
31+
32+
});
33+
34+
after(function () {
35+
server.close();
36+
});
37+
38+
2039
describe('manifest', function() {
2140
it('`gui.App.manifest` should equle to value of package.json', function() {
22-
assert.equal(gui.App.manifest.name, 'nw-gui.App-test');
41+
assert.equal(gui.App.manifest.name, 'nw-gui.App-test.wrapper');
2342
});
2443

2544
it('have main', function() {
2645
assert.equal(typeof gui.App.manifest.main, 'string');
2746
assert.equal(gui.App.manifest.main, 'index.html');
2847
});
2948

30-
/*
49+
3150
it('have window', function() {
3251
console.log('====have window:' + typeof gui.App.manifest.window);
3352
assert.equal(typeof gui.App.manifest.window, 'object');
@@ -36,9 +55,9 @@ describe('gui.App', function() {
3655
it('have dependencies', function() {
3756
assert.equal(typeof gui.App.manifest.dependencies, 'object');
3857
});
39-
*/
58+
4059
});
41-
/*
60+
4261
describe('clearCache()', function(done) {
4362
it('should clear the HTTP cache in memory and the one on disk', function() {
4463
var res_save = global.local_server.res_save;
@@ -49,7 +68,7 @@ describe('gui.App', function() {
4968
assert.equal(res_save[2].pathname, 'img.jpg');
5069
});
5170
});
52-
*/
71+
5372
});
5473

5574

tests/automation/app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2-
"name": "nw-gui.App-test",
3-
"main": "index.html"
2+
"name":"nw-gui.App-test.wrapper",
3+
"main":"index.html"
44
}
5+

tests/automation/chromium-args/mocha_test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('chromium-args', function() {
4141

4242

4343
describe('--app=url', function() {
44-
var result2 = false;
44+
var result = false, result2 = false;
4545

4646
var child, server;
4747

@@ -57,12 +57,20 @@ describe('chromium-args', function() {
5757
socket.setEncoding('utf8');
5858
socket.on('data', function(data) {
5959
result2 = data;
60+
result = true;
6061
done();
6162
});
6263
});
6364

6465
child = spawnChildProcess(path.join(curDir, 'internal'));
6566

67+
setTimeout(function() {
68+
if (!result) {
69+
child.kill();
70+
done('timeout');
71+
}
72+
}, 4500);
73+
6674
});
6775
});
6876

tests/automation/config.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"format": "xunit-file",
3-
"exclude": ["node_modules", "output", "internal", "res", "app", "node-remote", "save_devtools_settings", "single_instance",
4-
"source-maps", "temp_dir",
3+
"exclude": ["node_modules", "output", "internal", "res", "node-remote", "save_devtools_settings", "single_instance",
54
"call_require_with_node-main_set", "show_devtool_after_http_server_created_in_node_main", "reference-node-main"],
65
"single": "",
7-
"timeout": "5000",
6+
"timeout": "8000",
87
"slow": "200",
98
"quiet": false
109
}

tests/automation/console/internal/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
iframe_devtools.width = '1000';
6060

6161
function get_results() {
62-
var console_logs = devtools.document.getElementsByClassName('console-log-level');
62+
var console_logs = devtools.getElementsByClassName('console-log-level');
6363

6464
for (var i = 0; i < console_logs.length; i++)
6565
results.push(console_logs[i].childNodes[0].childNodes[0].innerHTML);
@@ -70,7 +70,7 @@
7070
}
7171

7272
function get_console_logs() {
73-
var console_msgs = devtools.document.getElementsByClassName('console');
73+
var console_msgs = devtools.getElementsByClassName('console');
7474

7575
<!-- make sure it is complete -->
7676
if(console_msgs == undefined || console_msgs[0] == undefined || console_msgs[0].click == undefined)

tests/automation/console/mocha_test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ describe('console.log', function() {
4343
});
4444
});
4545

46+
setTimeout(function() {
47+
done('timeout');
48+
}, 4500);
49+
4650
});
4751

4852
after(function(done){

tests/automation/cookies_api/mocha_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ describe('Window.cookies', function() {
111111
describe('remove', function() {
112112
before(function(done) {
113113
this.timeout(0);
114-
child = spawnChild(3);
114+
child = spawnChild(4);
115115
server.on('connection', function(socket) {
116116
socket.setEncoding('utf8');
117117
socket.on('data', function(data) {
118118
results = JSON.parse(data);
119-
changed = results[1];
119+
//changed = results[1];
120120
child.kill();
121121
done();
122122
});

tests/automation/crash_dump/mocha_test.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,21 @@ describe('crash dump', function() {
1616
var server;
1717

1818
before(function(done) {
19-
if (!fs.existsSync(tmpDir))
20-
fs.mkdirSync(tmpDir);
19+
20+
var ready = function() {
21+
fs.mkdirSync(tmpDir);
2122
server = createTCPServer(13013);
2223
done();
24+
};
25+
26+
if (fs.existsSync(tmpDir)) {
27+
fs_extra.remove(tmpDir, function() {
28+
ready();
29+
});
30+
} else {
31+
ready();
32+
}
33+
2334
});
2435

2536
after(function () {

tests/automation/crashonreload/mocha_test.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,22 @@ describe('crash on reload',function(){
1010

1111
var child = spawnChildProcess(path.join(curDir, 'internal'));
1212
child.on('exit', function (code){
13-
if (code != 0)
14-
return done('nw crashes');
1513
result = true;
16-
done();
14+
if (code != 0) {
15+
done('nw crashes');
16+
child.kill();
17+
} else {
18+
done();
19+
}
20+
1721
});
1822

1923
setTimeout(function(){
2024
if (!result) {
2125
child.kill();
2226
done();
2327
}
24-
}, 7500);
28+
29+
}, 4500);
2530
});
2631
});

tests/automation/document_cookies/mocha_test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ var server;
4848
setTimeout(function() {
4949
results.push(data);
5050
child.kill();
51-
//done();
52-
}, 2000);
51+
done();
52+
}, 1000);
5353
});
5454
});
55-
setTimeout(done, 3000);
55+
setTimeout(done, 10000);
5656
});
5757

5858
after(function() {
@@ -75,12 +75,12 @@ var server;
7575
setTimeout(function() {
7676
results.push(data);
7777
child.kill();
78-
//done();
79-
}, 2000);
78+
done();
79+
}, 1000);
8080
});
8181
});
8282

83-
setTimeout(done, 3000);
83+
setTimeout(done, 10000);
8484
});
8585

8686
after(function() {

tests/automation/failures.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Failed test cases
2+
=======================
3+
4+
* app
5+
6+
* chromedriver2_server
7+
8+
* chromium-args
9+
10+
* console
11+
12+
* cookies_api (bad bad bad)
13+
14+
* document_cookies
15+
16+
* node
17+
18+
* node-remote
19+
20+
* process
21+
22+
* reload_application
23+
24+
* save_devtools_settings
25+
26+
* single_instance
27+
28+
* source-maps
29+
30+
* temp_dir
31+
32+
* user-agent
33+
34+
* user-agent-app
35+
36+
* website
37+
38+
39+
40+
41+

0 commit comments

Comments
 (0)