OLD | NEW |
(Empty) | |
| 1 <script> |
| 2 var pass = chrome.test.callbackPass; |
| 3 |
| 4 var width = 0; |
| 5 var height = 0; |
| 6 var changedWidth = 500; |
| 7 var changedHeight = 500; |
| 8 |
| 9 function checkRestoreWithBounds(theWindow) { |
| 10 chrome.test.assertEq('normal', theWindow.state); |
| 11 if (theWindow.type == 'panel') { |
| 12 // Panels decide their own bounds. |
| 13 chrome.test.assertEq(width, theWindow.width); |
| 14 chrome.test.assertEq(height, theWindow.height); |
| 15 } else { |
| 16 chrome.test.assertEq(changedWidth, theWindow.width); |
| 17 chrome.test.assertEq(changedHeight, theWindow.height); |
| 18 } |
| 19 |
| 20 chrome.windows.remove(theWindow.id, pass()); |
| 21 } |
| 22 |
| 23 function checkMaximized(theWindow) { |
| 24 if (theWindow.type == 'panel') { |
| 25 // Maximize is the same as restore for panels. |
| 26 chrome.test.assertEq('normal', theWindow.state); |
| 27 chrome.test.assertEq(width, theWindow.width); |
| 28 chrome.test.assertEq(height, theWindow.height); |
| 29 } else { |
| 30 chrome.test.assertEq('maximized', theWindow.state); |
| 31 chrome.test.assertTrue(width < theWindow.width || |
| 32 height < theWindow.height); |
| 33 } |
| 34 |
| 35 chrome.windows.update(theWindow.id, |
| 36 {'state': 'normal', width: changedWidth, height: changedHeight}, |
| 37 pass(checkRestoreWithBounds)); |
| 38 } |
| 39 |
| 40 function checkRestored(theWindow) { |
| 41 chrome.test.assertEq('normal', theWindow.state); |
| 42 chrome.test.assertEq(width, theWindow.width); |
| 43 chrome.test.assertEq(height, theWindow.height); |
| 44 |
| 45 chrome.windows.update(theWindow.id, {'state': 'maximized'}, pass(checkMaximize
d)); |
| 46 } |
| 47 |
| 48 function checkMinimized(theWindow) { |
| 49 chrome.test.assertEq('minimized', theWindow.state); |
| 50 chrome.windows.update(theWindow.id, {'state': 'normal'}, pass(checkRestored)); |
| 51 } |
| 52 |
| 53 function minimizeWindow(theWindow) { |
| 54 chrome.test.assertEq('normal', theWindow.state); |
| 55 width = theWindow.width; |
| 56 height = theWindow.height; |
| 57 chrome.windows.update(theWindow.id, {'state': 'minimized'}, pass(checkMinimize
d)); |
| 58 } |
| 59 |
| 60 function testWindowState(windowType) { |
| 61 chrome.windows.create({'url': 'hello.html', 'type': windowType}, |
| 62 pass(minimizeWindow)); |
| 63 } |
| 64 |
| 65 chrome.test.runTests([ |
| 66 function changeWindowState() { |
| 67 testWindowState('normal'); |
| 68 }, |
| 69 function changePopupWindowState() { |
| 70 testWindowState('popup'); |
| 71 }, |
| 72 function changePanelWindowState() { |
| 73 testWindowState('panel'); |
| 74 } |
| 75 ]); |
| 76 </script> |
OLD | NEW |