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

Unified Diff: chrome/test/data/extensions/platform_apps/windows_api_bounds/main.js

Issue 11369039: Add setBounds method and browsertest for get/set bounds to app window API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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/platform_apps/windows_api_bounds/main.js
diff --git a/chrome/test/data/extensions/platform_apps/windows_api_bounds/main.js b/chrome/test/data/extensions/platform_apps/windows_api_bounds/main.js
new file mode 100644
index 0000000000000000000000000000000000000000..c69beb88f306ab5a98f1f94b9bc611c0dc4bd054
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/windows_api_bounds/main.js
@@ -0,0 +1,35 @@
+// 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.
+
+function closeEnough(actual, expected, maxAllowedDifference) {
+ return Math.abs(actual - expected) < maxAllowedDifference;
+}
+
+function waitForBounds(expectedBounds, callback) {
+ function checkBounds() {
+ var bounds = chrome.app.window.current().getBounds();
+ if (closeEnough(bounds.left, expectedBounds.left, slop) &&
+ closeEnough(bounds.top, expectedBounds.top, slop) &&
+ closeEnough(bounds.width, expectedBounds.width, slop) &&
+ closeEnough(bounds.height, expectedBounds.height, slop)) {
+ callback();
+ } else {
+ setTimeout(checkBounds, 50);
jeremya 2012/11/02 05:06:41 Can you add a TODO here to rewrite when bounds cha
asargent_no_longer_on_chrome 2012/11/09 20:25:35 Done.
+ }
+ }
+ checkBounds();
+}
+
+var slop = 0;
+
+chrome.test.sendMessage("ready", function(response) {
+ slop = parseInt(response);
+ waitForBounds({left:100, top:200, width:300, height:400}, function() {
+ var newBounds = {left:50, top:100, width:150, height:200};
+ chrome.app.window.current().setBounds(newBounds);
+ waitForBounds(newBounds, function(){
+ chrome.test.sendMessage("success");
+ });
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698