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', {width:512, height:384}, |
21 chrome.windows.create( | 17 callbackPass(function(win) { |
22 {type: 'shell', width: 128, height: 128}, | 18 // TODO(jeremya): assert that width and height specified in options |
23 callbackPass(function() { | 19 // above specify the innerWidth, not the outerWidth. |
24 getShellWindowCount(callbackPass(function(shellWindowCount) { | 20 chrome.test.assertEq(512, win.outerWidth); |
25 chrome.test.assertEq(1, shellWindowCount); | 21 chrome.test.assertEq(384, win.outerHeight); |
26 })); | 22 win.resizeTo(256, 384); |
27 })); | 23 chrome.test.assertEq(256, win.outerWidth); |
28 })); | 24 chrome.test.assertEq(384, win.outerHeight); |
29 }, | 25 })); |
30 | 26 }, |
31 function testUpdateWindowWidth() { | |
32 chrome.windows.create( | |
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 ]); | 27 ]); |
55 }); | 28 }); |
OLD | NEW |