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)); |
+ }, |
+]); |