1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var pass = chrome.test.callbackPass;
13 function checkRestoreAfterFullscreen(theWindow) {
14 chrome.test.assertEq('normal', theWindow.state);
15 chrome.test.assertEq(width, theWindow.width);
16 chrome.test.assertEq(height, theWindow.height);
17 chrome.windows.remove(theWindow.id, pass());
20 function checkFullscreen(theWindow) {
21 if (theWindow.type == 'panel') {
22 // Panels do not support fullscreen.
23 chrome.test.assertEq('normal', theWindow.state);
25 chrome.test.assertEq('fullscreen', theWindow.state);
28 chrome.windows.update(theWindow.id, {'state': 'normal'},
29 pass(checkRestoreAfterFullscreen));
32 function checkRestoreWithBounds(theWindow) {
33 chrome.test.assertEq('normal', theWindow.state);
34 chrome.test.assertEq(width, theWindow.width);
35 chrome.test.assertEq(height, theWindow.height);
37 chrome.windows.update(theWindow.id, {'state': 'fullscreen'},
38 pass(checkFullscreen));
41 function checkMaximized(theWindow) {
42 if (theWindow.type == 'panel') {
43 // Maximize is the same as restore for panels.
44 chrome.test.assertEq('normal', theWindow.state);
45 chrome.test.assertEq(width, theWindow.width);
46 chrome.test.assertEq(height, theWindow.height);
48 chrome.test.assertEq('maximized', theWindow.state);
49 chrome.test.assertTrue(width < theWindow.width ||
50 height < theWindow.height);
54 height += deltaHeight;
55 chrome.windows.update(theWindow.id,
56 {'state': 'normal', 'width': width, 'height': height},
57 pass(checkRestoreWithBounds));
60 function checkRestored(theWindow) {
61 chrome.test.assertEq('normal', theWindow.state);
62 chrome.test.assertEq(width, theWindow.width);
63 chrome.test.assertEq(height, theWindow.height);
65 chrome.windows.update(theWindow.id, {'state': 'maximized'}, pass(checkMaximized));
68 function checkMinimized(theWindow) {
69 chrome.test.assertEq('minimized', theWindow.state);
70 chrome.windows.update(theWindow.id, {'state': 'normal'}, pass(checkRestored));
73 function minimizeWindow(theWindow) {
74 chrome.test.assertEq('normal', theWindow.state);
75 width = theWindow.width;
76 height = theWindow.height;
77 chrome.windows.update(theWindow.id, {'state': 'minimized'}, pass(checkMinimized));
80 function testWindowState(windowType) {
81 // Specifying size prevents 'panel' windows from computing size
82 // asynchronously. It ensures panel sizes stay fixed through the test.
83 // Do not use the big size because the maximium panel sizes are based on a
84 // factor of the screen resolution and the try bot might be configured with
85 // 800x600 resolution.
86 chrome.windows.create({ 'url': 'hello.html', 'type': windowType, 'width': 200,
88 pass(minimizeWindow));
91 chrome.test.runTests([
92 function changeWindowState() {
93 testWindowState('normal');
95 function changePopupWindowState() {
96 testWindowState('popup');
98 function changePanelWindowState() {
99 testWindowState('panel');