| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var callbackPass = chrome.test.callbackPass; | 5 var callbackPass = chrome.test.callbackPass; |
| 6 | 6 |
| 7 chrome.experimental.app.onLaunched.addListener(function() { | 7 chrome.experimental.app.onLaunched.addListener(function() { |
| 8 // Only a few chrome.windows.* API methods are tested, it is assumed that the | |
| 9 // full API is tested elsewhere. | |
| 10 chrome.test.runTests([ | 8 chrome.test.runTests([ |
| 11 function testCreateWindow() { | 9 function testCreateWindow() { |
| 12 var getShellWindowCount = function(callback) { | 10 chrome.appWindow.create('test.html', {}, callbackPass(function (win) { |
| 13 chrome.windows.getAll(function(windows) { | 11 chrome.test.assertTrue(typeof win.window === 'object'); |
| 14 callback(windows.filter( | 12 })) |
| 15 function(window) { return window.type == 'shell' }).length); | 13 }, |
| 16 }); | |
| 17 }; | |
| 18 | 14 |
| 19 getShellWindowCount(callbackPass(function(shellWindowCount) { | 15 function testUpdateWindowWidth() { |
| 20 chrome.test.assertEq(0, shellWindowCount); | 16 chrome.appWindow.create('test.html', |
| 21 chrome.windows.create( | 17 {width:512, height:384, frame:'custom'}, |
| 22 {type: 'shell', width: 128, height: 128}, | 18 callbackPass(function(win) { |
| 23 callbackPass(function() { | 19 // TODO(jeremya): assert that width and height specified in options |
| 24 getShellWindowCount(callbackPass(function(shellWindowCount) { | 20 // above specify the innerWidth, not the outerWidth. |
| 25 chrome.test.assertEq(1, shellWindowCount); | 21 //chrome.test.assertEq(512, win.outerWidth); |
| 26 })); | 22 //chrome.test.assertEq(384, win.outerHeight); |
| 27 })); | 23 var oldWidth = win.outerWidth, oldHeight = win.outerHeight; |
| 28 })); | 24 win.resizeBy(-256, 0); |
| 29 }, | 25 chrome.test.assertEq(oldWidth - 256, win.outerWidth); |
| 30 | 26 chrome.test.assertEq(oldHeight, win.outerHeight); |
| 31 function testUpdateWindowWidth() { | 27 })); |
| 32 chrome.windows.create( | 28 }, |
| 33 {type: 'shell', width: 128, height: 128}, | |
| 34 callbackPass(function(window) { | |
| 35 chrome.windows.update( | |
| 36 window.id, | |
| 37 // 256 is a width that will snap to the Aura grid, thus this | |
| 38 // should be the actual width on Aura (when read back). | |
| 39 {width: 256, height: 128}, | |
| 40 callbackPass(function() { | |
| 41 // The timeout is rather lame, but reading back the width from | |
| 42 // the window manager (on Linux) immediately still reports the | |
| 43 // old value. | |
| 44 setTimeout(callbackPass(function() { | |
| 45 chrome.windows.getCurrent(callbackPass(function(window) { | |
| 46 chrome.test.assertEq(256, window.width); | |
| 47 })); | |
| 48 }), 1000); | |
| 49 })); | |
| 50 })); | |
| 51 }, | |
| 52 | |
| 53 | |
| 54 ]); | 29 ]); |
| 55 }); | 30 }); |
| OLD | NEW |