OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 var callbackPass = chrome.test.callbackPass; |
| 6 |
| 7 // Only a few chrome.windows.* API methods are tested, it is assumed that the |
| 8 // full API is tested elsewhere. |
| 9 chrome.test.runTests([ |
| 10 function testGetCurrentWindow() { |
| 11 chrome.windows.getCurrent(callbackPass(function(window) { |
| 12 chrome.test.assertEq(250, window.width); |
| 13 chrome.test.assertEq('shell', window.type); |
| 14 })); |
| 15 }, |
| 16 |
| 17 function testUpdateWindowWidth() { |
| 18 chrome.windows.getCurrent(callbackPass(function(window) { |
| 19 chrome.windows.update( |
| 20 window.id, {width: 300}, callbackPass(function() { |
| 21 // The timeout is rather lame, but reading back the width from the |
| 22 // window manager (on Linux) immediately still reports the old |
| 23 // value. |
| 24 setTimeout(callbackPass(function() { |
| 25 chrome.windows.getCurrent(callbackPass(function(window) { |
| 26 chrome.test.assertEq(300, window.width); |
| 27 })); |
| 28 }), 100); |
| 29 })); |
| 30 })); |
| 31 }, |
| 32 |
| 33 function testCreateWindow() { |
| 34 var getShellWindowCount = function(callback) { |
| 35 chrome.windows.getAll(function(windows) { |
| 36 callback(windows.filter( |
| 37 function(window) { return window.type == 'shell'}).length); |
| 38 }); |
| 39 }; |
| 40 |
| 41 getShellWindowCount(callbackPass(function(shellWindowCount) { |
| 42 chrome.test.assertEq(1, shellWindowCount); |
| 43 chrome.windows.create({type: 'shell'}, callbackPass(function() { |
| 44 getShellWindowCount(callbackPass(function(shellWindowCount) { |
| 45 chrome.test.assertEq(2, shellWindowCount); |
| 46 })); |
| 47 })); |
| 48 })); |
| 49 } |
| 50 ]); |
OLD | NEW |