Skip to content

Commit

Permalink
add new manual test for nw.Window API
Browse files Browse the repository at this point in the history
  • Loading branch information
ffanny committed Dec 29, 2018
1 parent bb0f376 commit 46fafa6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
40 changes: 39 additions & 1 deletion test/manual/window/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<script>
var gui = nw;
var win;


gui.Window.open('popup.html', {
x: 100, y: 100, width: 200, height: 300
}, function(w) { win = w; });
Expand Down Expand Up @@ -39,7 +41,7 @@
if (win != null)
win.close(true);
this.close(true);
});
});

gui.Window.get().show();
</script>
Expand All @@ -51,6 +53,11 @@
<br/>
<button onclick="win.hide()">Hide</button>
<br/>
<button onclick="win.reloadDev()">reloadDev</button>
<br/>
<button onclick="win.setPosition('center')">setPosition(center)</button>
<<!--button onclick="win.setPosition('mouse')">mouse</button>-->
<br/>
<button onclick="win.maximize()">Maximize</button>
<br/>
<button onclick="win.unmaximize()">Unmaximize</button>
Expand All @@ -63,12 +70,16 @@
<br/>
<button onclick="win.leaveFullscreen()">LeaveFullscreen</button>
<br/>
<button onclick="win.toggleFullscreen()">toggleFullscreen</button>
<br/>
<button onclick="win.close()">Close</button>
<br/>
<button onclick="win.close(true)">Force Close</button>
<br/>
<button onclick="win.showDevTools()">Open DevTools</button>
<br/>
<button onclick="win.closeDevTools()">Close DevTools</button>
<br/>
<button onclick="win.setMinimumSize(100, 200)">setMinimumSize(100, 200)</button>
<br/>
<button onclick="win.setMaximumSize(200, 400)">setMaximumSize(200, 400)</button>
Expand All @@ -84,6 +95,28 @@
<button onclick="win.setResizable(true)">setResizable(true)</button>
<button onclick="win.setResizable(false)">(false)</button>
<br/>
<!--<button onclick="win.setShadow(true)">setShadow (MAC)(true)</button>
<button onclick="win.setShadow(false)">(false)</button>
<br/>-->
<button onclick="win.setVisibleOnAllWorkspaces(true)">setVisibleOnAllWorkspaces(MAC,LINUX)(true)</button>
<button onclick="win.setVisibleOnAllWorkspaces(false)">(false)</button>
<br/>
<button onclick="win.setShowInTaskbar(true)">setShowInTaskbar (true)</button>
<button onclick="win.setShowInTaskbar(false)">(false)</button>
<br/>
<button onclick="win.requestAttention(true)">requestAttention (true)</button>
<button onclick="win.requestAttention(false)">(false)</button>
<br/>
<button onclick="win.requestAttention(10)">requestAttention (10s)</button>
<br/>
<button onclick="win.enterKioskMode()">enterKioskMode</button>
<br/>
<button onclick="win.leaveKioskMode()">leaveKioskMode</button>
<br/>
<button onclick="win.toggleKioskMode()">toggleKioskMode</button>
<br/>
<button onclick="win.print({})">print</button>
<br/>
<p>Focus another application within 2sec, popup window should on top.</p>
<button onclick="setTimeout(function(){win.setAlwaysOnTop(true);},2000)">setAlwaysOnTop(true)</button>
<button onclick="win.setAlwaysOnTop(false)">(false)</button>
Expand All @@ -94,7 +127,12 @@
<br/>
<button onclick="takeSnapshot()">takeSnapshot</button>
<br/>
<!--<button onclick="removeAllListeners()">removeAllListeners</button>
<br/>-->
Reload the window and do all tests again.
<br/>
<button onclick="win.reload()">Reload</button>
<br/>
<button onclick="win.reloadIgnoringCache()">Reload ignoring cache</button>
</body>
</html>
11 changes: 11 additions & 0 deletions test/manual/window/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
var enable = false;
var gui = require('nw.gui');
var win = gui.Window.get();

var menu = new nw.Menu({ type: 'menubar' });
var submenu = new nw.Menu();
submenu.append(new nw.MenuItem({ label: 'Item A' }));
submenu.append(new nw.MenuItem({ label: 'Item B' }));
menu.append(new nw.MenuItem({
label: 'First Menu',
submenu: submenu
}));
win.menu = menu;

win.on('close', function() {
if (enable)
this.close(true);
Expand Down

0 comments on commit 46fafa6

Please sign in to comment.