| 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 chrome.test.runTests([ | 8 chrome.test.runTests([ |
| 9 function testCreateWindow() { | 9 function testCreateWindow() { |
| 10 chrome.appWindow.create('test.html', {}, callbackPass(function (win) { | 10 chrome.app.window.create('test.html', {}, callbackPass(function (win) { |
| 11 chrome.test.assertTrue(typeof win.window === 'object'); | 11 chrome.test.assertTrue(typeof win.window === 'object'); |
| 12 })) | 12 })) |
| 13 }, | 13 }, |
| 14 | 14 |
| 15 function testUpdateWindowWidth() { | 15 function testUpdateWindowWidth() { |
| 16 chrome.appWindow.create('test.html', | 16 chrome.app.window.create('test.html', |
| 17 {width:512, height:384, frame:'custom'}, | 17 {width:512, height:384, frame:'custom'}, |
| 18 callbackPass(function(win) { | 18 callbackPass(function(win) { |
| 19 chrome.test.assertEq(512, win.innerWidth); | 19 chrome.test.assertEq(512, win.innerWidth); |
| 20 chrome.test.assertEq(384, win.innerHeight); | 20 chrome.test.assertEq(384, win.innerHeight); |
| 21 var oldWidth = win.outerWidth, oldHeight = win.outerHeight; | 21 var oldWidth = win.outerWidth, oldHeight = win.outerHeight; |
| 22 win.resizeBy(-256, 0); | 22 win.resizeBy(-256, 0); |
| 23 chrome.test.assertEq(oldWidth - 256, win.outerWidth); | 23 chrome.test.assertEq(oldWidth - 256, win.outerWidth); |
| 24 chrome.test.assertEq(oldHeight, win.outerHeight); | 24 chrome.test.assertEq(oldHeight, win.outerHeight); |
| 25 })); | 25 })); |
| 26 }, | 26 }, |
| 27 | 27 |
| 28 /*function testMaximize() { | 28 /*function testMaximize() { |
| 29 chrome.appWindow.create('test.html', {width: 200, height: 200}, | 29 chrome.app.window.create('test.html', {width: 200, height: 200}, |
| 30 callbackPass(function(win) { | 30 callbackPass(function(win) { |
| 31 win.onresize = callbackPass(function(e) { | 31 win.onresize = callbackPass(function(e) { |
| 32 // Crude test to check we're somewhat maximized. | 32 // Crude test to check we're somewhat maximized. |
| 33 chrome.test.assertTrue( | 33 chrome.test.assertTrue( |
| 34 win.outerHeight > screen.availHeight * 0.8); | 34 win.outerHeight > screen.availHeight * 0.8); |
| 35 chrome.test.assertTrue( | 35 chrome.test.assertTrue( |
| 36 win.outerWidth > screen.availWidth * 0.8); | 36 win.outerWidth > screen.availWidth * 0.8); |
| 37 }); | 37 }); |
| 38 win.chrome.appWindow.maximize(); | 38 win.chrome.app.window.maximize(); |
| 39 })); | 39 })); |
| 40 },*/ | 40 },*/ |
| 41 | 41 |
| 42 /*function testRestore() { | 42 /*function testRestore() { |
| 43 chrome.appWindow.create('test.html', {width: 200, height: 200}, | 43 chrome.app.window.create('test.html', {width: 200, height: 200}, |
| 44 callbackPass(function(win) { | 44 callbackPass(function(win) { |
| 45 var oldWidth = win.innerWidth; | 45 var oldWidth = win.innerWidth; |
| 46 var oldHeight = win.innerHeight; | 46 var oldHeight = win.innerHeight; |
| 47 win.onresize = callbackPass(function() { | 47 win.onresize = callbackPass(function() { |
| 48 chrome.test.assertTrue(win.innerWidth != oldWidth); | 48 chrome.test.assertTrue(win.innerWidth != oldWidth); |
| 49 chrome.test.assertTrue(win.innerHeight != oldHeight); | 49 chrome.test.assertTrue(win.innerHeight != oldHeight); |
| 50 // Seems like every time we resize, we get two resize events. | 50 // Seems like every time we resize, we get two resize events. |
| 51 // See http://crbug.com/133869. | 51 // See http://crbug.com/133869. |
| 52 win.onresize = callbackPass(function() { | 52 win.onresize = callbackPass(function() { |
| 53 // Ignore the immediately following resize, as it's a clone of | 53 // Ignore the immediately following resize, as it's a clone of |
| 54 // the one we just got. | 54 // the one we just got. |
| 55 win.onresize = callbackPass(function() { | 55 win.onresize = callbackPass(function() { |
| 56 chrome.test.assertEq(oldWidth, win.innerWidth); | 56 chrome.test.assertEq(oldWidth, win.innerWidth); |
| 57 chrome.test.assertEq(oldHeight, win.innerHeight); | 57 chrome.test.assertEq(oldHeight, win.innerHeight); |
| 58 }); | 58 }); |
| 59 }) | 59 }) |
| 60 win.chrome.appWindow.restore(); | 60 win.chrome.app.window.restore(); |
| 61 }); | 61 }); |
| 62 win.chrome.appWindow.maximize(); | 62 win.chrome.app.window.maximize(); |
| 63 })); | 63 })); |
| 64 },*/ | 64 },*/ |
| 65 ]); | 65 ]); |
| 66 }); | 66 }); |
| OLD | NEW |