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

Unified Diff: chrome/test/data/extensions/api_test/window_update/resize/test.js

Issue 9181005: Allow resizing a panel using chrome.windows.update() extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 months 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/resize/test.js
diff --git a/chrome/test/data/extensions/api_test/window_update/resize/test.js b/chrome/test/data/extensions/api_test/window_update/resize/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..a8f34ef4c0cb476a379531f64e16648a7b91430b
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/window_update/resize/test.js
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 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 widthDelta = 50;
jianli 2012/01/11 00:29:13 Perhaps we also want to add the test cases to cove
jennb 2012/01/11 00:36:26 Code path is the same regardless if the delta is p
+var heightDelta = 100;
+
+var expectedWidth;
+var expectedHeight;
+
+var chromeWindow = null;
+
+function checkWidthAndHeight(currentWindow) {
+ chrome.test.assertEq(expectedWidth, currentWindow.width);
+ chrome.test.assertEq(expectedHeight, currentWindow.height);
+ chrome.windows.remove(currentWindow.id);
+}
+
+function checkHeightAndContinue(currentWindow) {
+ chrome.test.assertEq(expectedHeight, currentWindow.height);
+ expectedWidth = currentWindow.width + widthDelta;
+ expectedHeight = currentWindow.height + heightDelta;
+ chrome.windows.update(
+ currentWindow.id, { 'width': expectedWidth , 'height': expectedHeight},
+ pass(checkWidthAndHeight)
+ );
+}
+
+function checkWidthAndContinue(currentWindow) {
jianli 2012/01/11 00:29:13 This function also updates the height in addition
jennb 2012/01/11 00:36:26 The test code follows the pattern in window_update
+ chrome.test.assertEq(expectedWidth, currentWindow.width);
+ expectedHeight = currentWindow.height + heightDelta;
+ chrome.windows.update(
+ currentWindow.id, { 'height': expectedHeight },
+ pass(checkHeightAndContinue)
+ );
+}
+
+function updateWidthAndContinue(currentWindow) {
+ expectedWidth = currentWindow.width + widthDelta;
+ chrome.windows.update(
+ currentWindow.id, { 'width': expectedWidth },
+ pass(checkWidthAndContinue)
+ );
+}
+
+chrome.test.runTests([
+ function testResizeNormal() {
+ chrome.windows.create(
+ { 'url': 'blank.html', 'width': 500, 'height': 600, 'type': 'normal' },
+ pass(updateWidthAndContinue));
+ },
+ function testResizePopup() {
+ chrome.windows.create(
+ { 'url': 'blank.html', 'width': 300, 'height': 500, 'type': 'popup' },
+ pass(updateWidthAndContinue));
+ },
+ function testResizePanel() {
+ chrome.windows.create(
+ { 'url': 'blank.html', 'width': 150, 'height': 200, 'type': 'panel' },
+ pass(updateWidthAndContinue));
+ },
+]);

Powered by Google App Engine
This is Rietveld 408576698