Skip to content

Commit f51c67d

Browse files
committed
[test] Test-case for crash dump
1 parent e12f497 commit f51c67d

File tree

5 files changed

+138
-0
lines changed

5 files changed

+138
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Test case for crash dump!</title>
5+
</head>
6+
<body>
7+
<h1>Hello World!</h1>
8+
We are using node.js
9+
<script>
10+
var gui = require('nw.gui');
11+
var App = gui.App;
12+
//action: 0 for crashBrowser();
13+
//action: 1 for crashRenderer();
14+
var action = gui.App.argv[0];
15+
if (action == 0)
16+
window.open('index1.html')
17+
else
18+
setTimeout(function(){
19+
window.open('index2.html')
20+
}, 1000);
21+
var client = require('../../nw_test_app').createClient({
22+
argv: gui.App.argv,
23+
data: ""
24+
});
25+
26+
27+
</script>
28+
</body>
29+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Test case for crash dump browser!</title>
5+
</head>
6+
<body>
7+
<h1>Hello World!</h1>
8+
We are using node.js
9+
<script>
10+
var gui = require('nw.gui');
11+
var App = gui.App;
12+
App.setCrashDumpDir('./automatic_tests/crash_dump/tmp');
13+
App.crashBrowser();
14+
</script>
15+
</body>
16+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Test case for crash dump render!</title>
5+
</head>
6+
<body>
7+
<h1>Hello World!</h1>
8+
We are using node.js
9+
<script>
10+
var gui = require('nw.gui');
11+
var App = gui.App;
12+
App.setCrashDumpDir('./automatic_tests/crash_dump/tmp');
13+
App.crashRenderer();
14+
</script>
15+
</body>
16+
</html>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
var path = require('path');
2+
var app_test = require('./nw_test_app');
3+
var assert = require('assert');
4+
var fs = require('fs');
5+
var fs_extra = require('fs-extra');
6+
var results;
7+
describe('crash dump', function() {
8+
9+
after(function () {
10+
fs_extra.remove('./automatic_tests/crash_dump/tmp', function (er) {
11+
if (er) throw er;
12+
});
13+
});
14+
15+
describe('crashBrowser()', function() {
16+
before(function(done) {
17+
this.timeout(0);
18+
var child = app_test.createChildProcess({
19+
execPath: process.execPath,
20+
appPath: path.join(global.tests_dir, 'crash_dump'),
21+
args:[0],
22+
end: function(data, app) {
23+
result = fs.readdirSync('./automatic_tests/crash_dump/tmp');
24+
done();
25+
}
26+
});
27+
});
28+
29+
it('should work fine', function() {
30+
assert.equal(result.length, 1);
31+
var r = result[0].indexOf("renderer");
32+
assert.equal(r, -1);
33+
});
34+
35+
})
36+
37+
describe('crashRenderer()', function() {
38+
before(function(done) {
39+
this.timeout(0);
40+
var child = app_test.createChildProcess({
41+
execPath: process.execPath,
42+
appPath: path.join(global.tests_dir, 'crash_dump'),
43+
args:[1],
44+
end: function(data, app) {
45+
setTimeout(function() {
46+
result = fs.readdirSync('./automatic_tests/crash_dump/tmp');
47+
done();
48+
}, 2000);
49+
}
50+
});
51+
});
52+
53+
it('should work fine', function() {
54+
assert.equal(result.length, 2);
55+
var r = result[1].indexOf("renderer");
56+
assert.notEqual(r, -1);
57+
});
58+
})
59+
60+
describe('App.setCrashDumpDir(dir)', function() {
61+
before(function(done) {
62+
this.timeout(0);
63+
result = fs.readdirSync('./automatic_tests/crash_dump/tmp');
64+
done();
65+
});
66+
67+
it('should work fine', function() {
68+
assert.equal(result.length, 2);
69+
});
70+
})
71+
72+
73+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "crash_dump_test",
3+
"main": "index.html"
4+
}

0 commit comments

Comments
 (0)