Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/test/data/extensions/api_test/window_update/show_state/test.js

Issue 8775046: Convert another batch of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 pass = chrome.test.callbackPass;
6
7 var width = 0;
8 var height = 0;
9 var changedWidth = 500;
10 var changedHeight = 500;
11
12 function checkRestoreWithBounds(theWindow) {
13 chrome.test.assertEq('normal', theWindow.state);
14 if (theWindow.type == 'panel') {
15 // Panels decide their own bounds.
16 chrome.test.assertEq(width, theWindow.width);
17 chrome.test.assertEq(height, theWindow.height);
18 } else {
19 chrome.test.assertEq(changedWidth, theWindow.width);
20 chrome.test.assertEq(changedHeight, theWindow.height);
21 }
22
23 chrome.windows.remove(theWindow.id, pass());
24 }
25
26 function checkMaximized(theWindow) {
27 if (theWindow.type == 'panel') {
28 // Maximize is the same as restore for panels.
29 chrome.test.assertEq('normal', theWindow.state);
30 chrome.test.assertEq(width, theWindow.width);
31 chrome.test.assertEq(height, theWindow.height);
32 } else {
33 chrome.test.assertEq('maximized', theWindow.state);
34 chrome.test.assertTrue(width < theWindow.width ||
35 height < theWindow.height);
36 }
37
38 chrome.windows.update(theWindow.id,
39 {'state': 'normal', width: changedWidth, height: changedHeight},
40 pass(checkRestoreWithBounds));
41 }
42
43 function checkRestored(theWindow) {
44 chrome.test.assertEq('normal', theWindow.state);
45 chrome.test.assertEq(width, theWindow.width);
46 chrome.test.assertEq(height, theWindow.height);
47
48 chrome.windows.update(theWindow.id, {'state': 'maximized'}, pass(checkMaximize d));
49 }
50
51 function checkMinimized(theWindow) {
52 chrome.test.assertEq('minimized', theWindow.state);
53 chrome.windows.update(theWindow.id, {'state': 'normal'}, pass(checkRestored));
54 }
55
56 function minimizeWindow(theWindow) {
57 chrome.test.assertEq('normal', theWindow.state);
58 width = theWindow.width;
59 height = theWindow.height;
60 chrome.windows.update(theWindow.id, {'state': 'minimized'}, pass(checkMinimize d));
61 }
62
63 function testWindowState(windowType) {
64 // Specifying size prevents 'panel' windows from computing size asynchronously . It ensures
65 // panel sizes stay fixed through the test.
66 chrome.windows.create({'url': 'hello.html', 'type': windowType, 'width':100, ' height':100 },
67 pass(minimizeWindow));
68 }
69
70 chrome.test.runTests([
71 function changeWindowState() {
72 testWindowState('normal');
73 },
74 function changePopupWindowState() {
75 testWindowState('popup');
76 },
77 function changePanelWindowState() {
78 testWindowState('panel');
79 }
80 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698