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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/window_update/show_state/test.js
===================================================================
--- chrome/test/data/extensions/api_test/window_update/show_state/test.js (revision 0)
+++ chrome/test/data/extensions/api_test/window_update/show_state/test.js (revision 0)
@@ -0,0 +1,80 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var pass = chrome.test.callbackPass;
+
+var width = 0;
+var height = 0;
+var changedWidth = 500;
+var changedHeight = 500;
+
+function checkRestoreWithBounds(theWindow) {
+ chrome.test.assertEq('normal', theWindow.state);
+ if (theWindow.type == 'panel') {
+ // Panels decide their own bounds.
+ chrome.test.assertEq(width, theWindow.width);
+ chrome.test.assertEq(height, theWindow.height);
+ } else {
+ chrome.test.assertEq(changedWidth, theWindow.width);
+ chrome.test.assertEq(changedHeight, theWindow.height);
+ }
+
+ chrome.windows.remove(theWindow.id, pass());
+}
+
+function checkMaximized(theWindow) {
+ if (theWindow.type == 'panel') {
+ // Maximize is the same as restore for panels.
+ chrome.test.assertEq('normal', theWindow.state);
+ chrome.test.assertEq(width, theWindow.width);
+ chrome.test.assertEq(height, theWindow.height);
+ } else {
+ chrome.test.assertEq('maximized', theWindow.state);
+ chrome.test.assertTrue(width < theWindow.width ||
+ height < theWindow.height);
+ }
+
+ chrome.windows.update(theWindow.id,
+ {'state': 'normal', width: changedWidth, height: changedHeight},
+ pass(checkRestoreWithBounds));
+}
+
+function checkRestored(theWindow) {
+ chrome.test.assertEq('normal', theWindow.state);
+ chrome.test.assertEq(width, theWindow.width);
+ chrome.test.assertEq(height, theWindow.height);
+
+ chrome.windows.update(theWindow.id, {'state': 'maximized'}, pass(checkMaximized));
+}
+
+function checkMinimized(theWindow) {
+ chrome.test.assertEq('minimized', theWindow.state);
+ chrome.windows.update(theWindow.id, {'state': 'normal'}, pass(checkRestored));
+}
+
+function minimizeWindow(theWindow) {
+ chrome.test.assertEq('normal', theWindow.state);
+ width = theWindow.width;
+ height = theWindow.height;
+ chrome.windows.update(theWindow.id, {'state': 'minimized'}, pass(checkMinimized));
+}
+
+function testWindowState(windowType) {
+ // Specifying size prevents 'panel' windows from computing size asynchronously. It ensures
+ // panel sizes stay fixed through the test.
+ chrome.windows.create({'url': 'hello.html', 'type': windowType, 'width':100, 'height':100 },
+ pass(minimizeWindow));
+}
+
+chrome.test.runTests([
+ function changeWindowState() {
+ testWindowState('normal');
+ },
+ function changePopupWindowState() {
+ testWindowState('popup');
+ },
+ function changePanelWindowState() {
+ testWindowState('panel');
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698