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 callbackPass = chrome.test.callbackPass; |
| 6 |
5 var assertState = function(win) { | 7 var assertState = function(win) { |
6 if (win.id == 'normal') { | 8 if (win.id == 'normal') { |
7 chrome.test.assertFalse(win.isMinimized()); | 9 chrome.test.assertFalse(win.isMinimized()); |
8 chrome.test.assertFalse(win.isMaximized()); | 10 chrome.test.assertFalse(win.isMaximized()); |
9 } | 11 } |
10 if (win.id == 'maximized') { | 12 if (win.id == 'maximized') { |
11 chrome.test.assertFalse(win.isMinimized()); | 13 chrome.test.assertFalse(win.isMinimized()); |
12 chrome.test.assertTrue(win.isMaximized()); | 14 chrome.test.assertTrue(win.isMaximized()); |
13 } | 15 } |
14 } | 16 } |
15 | 17 |
16 var testRestoreState = function(state_type) { | 18 var testRestoreState = function(state_type) { |
17 chrome.app.window.create( | 19 chrome.app.window.create( |
18 'empty.html', | 20 'empty.html', |
19 { id: state_type, state: state_type }, | 21 { id: state_type, state: state_type }, |
20 chrome.test.callbackPass(windowCreated) | 22 callbackPass(function(win) { |
| 23 win.onWindowFirstShown.addListener(callbackPass(function() { |
| 24 assertState(win); |
| 25 win.onClosed.addListener(callbackPass(function() { |
| 26 chrome.app.window.create( |
| 27 'empty.html', |
| 28 { id: state_type }, |
| 29 callbackPass(function(win2) { |
| 30 win2.onWindowFirstShown.addListener(callbackPass(function() { |
| 31 assertState(win2); |
| 32 })); |
| 33 }) |
| 34 ); |
| 35 })); |
| 36 win.close(); |
| 37 })); |
| 38 }) |
21 ); | 39 ); |
22 function windowCreated(win) { | |
23 assertState(win); | |
24 win.onClosed.addListener(chrome.test.callbackPass(windowClosed)); | |
25 win.close(); | |
26 function windowClosed() { | |
27 chrome.app.window.create( | |
28 'empty.html', | |
29 { id: state_type }, | |
30 function(win2) { assertState(win2); } | |
31 ); | |
32 } | |
33 }; | |
34 } | 40 } |
35 | 41 |
36 chrome.app.runtime.onLaunched.addListener(function() { | 42 chrome.app.runtime.onLaunched.addListener(function() { |
37 chrome.test.runTests([ | 43 chrome.test.runTests([ |
38 function testRestoreNormal() { | 44 function testRestoreNormal() { |
39 testRestoreState('normal'); | 45 testRestoreState('normal'); |
40 }, | 46 }, |
41 function testRestoreMaximized() { | 47 function testRestoreMaximized() { |
42 testRestoreState('maximized'); | 48 testRestoreState('maximized'); |
43 }, | 49 }, |
44 // Minimize and fullscreen behavior are platform dependent. | 50 // Minimize and fullscreen behavior are platform dependent. |
45 ]); | 51 ]); |
46 }); | 52 }); |
OLD | NEW |