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

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

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
1 <script> 1 <!--
2 var pass = chrome.test.callbackPass; 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
3 3 * source code is governed by a BSD-style license that can be found in the
4 var width = 0; 4 * LICENSE file.
5 var height = 0; 5 -->
6 var changedWidth = 500; 6 <script src="test.js"></script>
7 var changedHeight = 500;
8
9 function checkRestoreWithBounds(theWindow) {
10 chrome.test.assertEq('normal', theWindow.state);
11 if (theWindow.type == 'panel') {
12 // Panels decide their own bounds.
13 chrome.test.assertEq(width, theWindow.width);
14 chrome.test.assertEq(height, theWindow.height);
15 } else {
16 chrome.test.assertEq(changedWidth, theWindow.width);
17 chrome.test.assertEq(changedHeight, theWindow.height);
18 }
19
20 chrome.windows.remove(theWindow.id, pass());
21 }
22
23 function checkMaximized(theWindow) {
24 if (theWindow.type == 'panel') {
25 // Maximize is the same as restore for panels.
26 chrome.test.assertEq('normal', theWindow.state);
27 chrome.test.assertEq(width, theWindow.width);
28 chrome.test.assertEq(height, theWindow.height);
29 } else {
30 chrome.test.assertEq('maximized', theWindow.state);
31 chrome.test.assertTrue(width < theWindow.width ||
32 » » height < theWindow.height);
33 }
34
35 chrome.windows.update(theWindow.id,
36 {'state': 'normal', width: changedWidth, height: changedHeight},
37 pass(checkRestoreWithBounds));
38 }
39
40 function checkRestored(theWindow) {
41 chrome.test.assertEq('normal', theWindow.state);
42 chrome.test.assertEq(width, theWindow.width);
43 chrome.test.assertEq(height, theWindow.height);
44
45 chrome.windows.update(theWindow.id, {'state': 'maximized'}, pass(checkMaximize d));
46 }
47
48 function checkMinimized(theWindow) {
49 chrome.test.assertEq('minimized', theWindow.state);
50 chrome.windows.update(theWindow.id, {'state': 'normal'}, pass(checkRestored));
51 }
52
53 function minimizeWindow(theWindow) {
54 chrome.test.assertEq('normal', theWindow.state);
55 width = theWindow.width;
56 height = theWindow.height;
57 chrome.windows.update(theWindow.id, {'state': 'minimized'}, pass(checkMinimize d));
58 }
59
60 function testWindowState(windowType) {
61 // Specifying size prevents 'panel' windows from computing size asynchronously . It ensures
62 // panel sizes stay fixed through the test.
63 chrome.windows.create({'url': 'hello.html', 'type': windowType, 'width':100, ' height':100 },
64 pass(minimizeWindow));
65 }
66
67 chrome.test.runTests([
68 function changeWindowState() {
69 testWindowState('normal');
70 },
71 function changePopupWindowState() {
72 testWindowState('popup');
73 },
74 function changePanelWindowState() {
75 testWindowState('panel');
76 }
77 ]);
78 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698