Skip to content

Commit 00d5247

Browse files
committed
add new test case "process"
1 parent bd8257d commit 00d5247

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<html>
2+
<head>
3+
</head>
4+
<body>
5+
<script>
6+
var gui = require('nw.gui');
7+
var fs = require('fs');
8+
9+
10+
process.on('exit', function(){
11+
12+
fs.openSync('a.txt', 'w');
13+
14+
});
15+
16+
gui.Window.get().close(true);
17+
</script>
18+
sdew
19+
</body>
20+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "nw-demo",
3+
"main": "index.html",
4+
"window": { "show" : true }
5+
}

tests/automation/process/index.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+
<meta charset="utf-8">
5+
<title>process test</title>
6+
</head>
7+
<body>
8+
<p>Process test</p>
9+
10+
<script src="../res/mocha_util.js"></script>
11+
<script src="mocha_test.js"></script>
12+
13+
</body>
14+
15+
</html>
16+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var path = require('path');
2+
var assert = require('assert');
3+
var fs = require('fs-extra');
4+
var curDir = fs.realpathSync('.');
5+
6+
describe('process', function() {
7+
describe('exit', function(){
8+
it('event process.exit should be fired after calling win.close(true)', function(done) {
9+
10+
11+
var child = spawnChildProcess(path.join(curDir, 'exit'));
12+
13+
setTimeout(function() {
14+
var tmpFilePath = path.join(curDir, 'exit', 'a.txt');
15+
fs.exists(tmpFilePath, function (exists) {
16+
if (exists) {
17+
fs.unlink(tmpFilePath);
18+
done();
19+
} else {
20+
done('the event `exit` does not been called.');
21+
}
22+
});
23+
24+
}, 1500);
25+
26+
27+
});
28+
29+
});
30+
31+
});
32+

tests/automation/process/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name":"process_wrapper",
3+
"main":"index.html"
4+
}
5+

0 commit comments

Comments
 (0)