Skip to content

Commit

Permalink
Merge pull request #1020 from richardcypher/nwinmem
Browse files Browse the repository at this point in the history
[test]add case for #984
  • Loading branch information
rogerwang committed Aug 22, 2013
2 parents cf1fc61 + 55a4d63 commit 7b2ce8f
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/automatic_tests/app_path_escape/xdk/index.html
Expand Up @@ -7,5 +7,9 @@
</head>
<body>
hello world
<script type="text/javascript">
var gui = require('nw.gui');
gui.App.quit();
</script>
</body>
</html>
31 changes: 31 additions & 0 deletions tests/automatic_tests/nw-in-mem/mocha_test.js
@@ -0,0 +1,31 @@
var os = require('os');
var path = require('path');
var exec = require('child_process').exec;
var spawn = require('child_process').spawn;
describe('nw in memory after quiting',function(){
it('nw.exe should not be in memory after gui.App.quit is called on windows',function(done){
this.timeout(0);
if(os.platform() == "win32") {
var app = spawn(process.execPath, [path.join(global.tests_dir,'nw-in-mem/package')])
app.on('close',function(){
var nwname = "nw.exe";
var nwcount = 0;
exec("tasklist", function(err, stdout, stderr) {
if(err){ return console.log(err); }
stdout.split('\n').filter(function(line){
var p=line.trim().split(/\s+/),pname=p[0];
if(pname.toLowerCase().indexOf(nwname)>=0)
nwcount++;
});

if(nwcount == 2)
done();
else if(nwcount > 2)
done('nw.exe is still in memory after the quit of app');
})
});
}
else
done();
})
})
Binary file added tests/automatic_tests/nw-in-mem/package/c2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions tests/automatic_tests/nw-in-mem/package/c2runtime.js

Large diffs are not rendered by default.

Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions tests/automatic_tests/nw-in-mem/package/index.html
@@ -0,0 +1,107 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Veille</title>

<!-- Allow fullscreen mode on iOS devices. (These are Apple specific meta tags.) -->
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="HandheldFriendly" content="true" />

<!-- All margins and padding must be zero for the canvas to fill the screen. -->
<style type="text/css">
* {
padding: 0;
margin: 0;
}
body {
background: #000;
color: #fff;
overflow: hidden;
-ms-touch-action: none;
}
canvas {
-ms-touch-action: none;
}
</style>


</head>

<body>
<div id="fb-root"></div>

<!-- The canvas must be inside a div called c2canvasdiv -->
<div id="c2canvasdiv">

<!-- The canvas the project will render to. If you change its ID, don't forget to change the
ID the runtime looks for in the jQuery events above (ready() and cr_sizeCanvas()). -->
<canvas id="c2canvas" width="800" height="600"></canvas>

</div>

<!-- For node-webkit to show file dialogs -->
<input style="display:none;" id="c2nwOpenFileDialog" type="file" />
<input style="display:none;" id="c2nwChooseFolderDialog" type="file" nwdirectory />
<input style="display:none;" id="c2nwSaveDialog" type="file" nwsaveas />

<!-- Pages load faster with scripts at the bottom -->

<!-- Construct 2 exported games require jQuery. -->
<script src="jquery-2.0.0.min.js"></script>



<!-- The runtime script. You can rename it, but don't forget to rename the reference here as well.
This file will have been minified and obfuscated if you enabled "Minify script" during export. -->
<script src="c2runtime.js"></script>

<script>
window["c2nodewebkit"] = true;
window["nwgui"] = require("nw.gui");

// Uncomment to show dev tools on startup
//window["nwgui"].Window.get().showDevTools();

// Size the canvas to fill the browser viewport.
jQuery(window).resize(function() {
cr_sizeCanvas(jQuery(window).width(), jQuery(window).height());
});

// Start the Construct 2 project running on window load.
jQuery(document).ready(function ()
{
// Create new runtime using the c2canvas
cr_createRuntime("c2canvas");

window["nwgui"].Window.get().show();
});

// Pause and resume on page becoming visible/invisible
function onVisibilityChanged() {
if (document.hidden || document.mozHidden || document.webkitHidden || document.msHidden)
cr_setSuspended(true);
else
cr_setSuspended(false);
};

document.addEventListener("visibilitychange", onVisibilityChanged, false);
document.addEventListener("mozvisibilitychange", onVisibilityChanged, false);
document.addEventListener("webkitvisibilitychange", onVisibilityChanged, false);
document.addEventListener("msvisibilitychange", onVisibilityChanged, false);
window["nwgui"].Window.get().on('loaded', function() {
setTimeout(function() {
simulateClick();
}, 1000);
});
function simulateClick() {
var evt = new Event('mousedown');
document.dispatchEvent(evt);
}

</script>
</body>
</html>
6 changes: 6 additions & 0 deletions tests/automatic_tests/nw-in-mem/package/jquery-2.0.0.min.js

Large diffs are not rendered by default.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/automatic_tests/nw-in-mem/package/nw.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions tests/automatic_tests/nw-in-mem/package/package.json
@@ -0,0 +1,17 @@
{
"main": "index.html",
"name": "Veille",
"description": "Ecran de veille NW/C2",
"version": "1.1",
"window": {
"icon": "logo.png",
"toolbar": false,
"width": 800,
"height": 600,
"position": "center",
"show": false
},
"dom_storage_quota": 50,
"user-agent": "Mozilla/5.0 (%osinfo) AppleWebKit/%webkit_ver (KHTML, like Gecko, Chrome, Safari) NodeWebkit/%nwver",
"chromium-args": "--disable-extensions --disable-plugins --disable-internal-flash --disable-popup-blocking --enable-gamepad --enable-html5-camera --allow-file-access-from-files"
}

0 comments on commit 7b2ce8f

Please sign in to comment.