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

Unified Diff: chrome/test/data/extensions/platform_apps/windows_api/test.js

Issue 25449002: Add chrome.app.window.[get|set][Min|Max][Width|Height] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase Created 7 years, 2 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
« no previous file with comments | « chrome/renderer/resources/extensions/app_window_custom_bindings.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/platform_apps/windows_api/test.js
diff --git a/chrome/test/data/extensions/platform_apps/windows_api/test.js b/chrome/test/data/extensions/platform_apps/windows_api/test.js
index 442eb20aea5cf97dbaedb2e3392882a67c5e5e88..50c439dff7940b8584a528a37482b42cbe7ae521 100644
--- a/chrome/test/data/extensions/platform_apps/windows_api/test.js
+++ b/chrome/test/data/extensions/platform_apps/windows_api/test.js
@@ -129,6 +129,150 @@ chrome.app.runtime.onLaunched.addListener(function() {
}));
},
+ function testUndefinedMinAndMaxSize() {
+ chrome.app.window.create('test.html', {
+ bounds: { width: 250, height: 250 }
+ }, callbackPass(function(win) {
+ chrome.test.assertEq(undefined, win.getMinWidth());
+ chrome.test.assertEq(undefined, win.getMinHeight());
+ chrome.test.assertEq(undefined, win.getMaxWidth());
+ chrome.test.assertEq(undefined, win.getMaxHeight());
+ win.close();
+ }));
+ },
+
+ function testSetUndefinedMinAndMaxSize() {
+ chrome.app.window.create('test.html', {
+ bounds: { width: 102, height: 103 },
+ minWidth: 100, minHeight: 101,
+ maxWidth: 104, maxHeight: 105
+ }, callbackPass(function(win) {
+ chrome.test.assertEq(100, win.getMinWidth());
+ chrome.test.assertEq(101, win.getMinHeight());
+ chrome.test.assertEq(104, win.getMaxWidth());
+ chrome.test.assertEq(105, win.getMaxHeight());
+ win.setMinWidth(null);
+ win.setMinHeight(null);
+ win.setMaxWidth(null);
+ win.setMaxHeight(null);
+ // We need to wait for an onBoundsChanged to ensure the size has been
+ // updated.
+ win.setBounds({ width: 103, height: 102 });
+ var cb;
+ win.onBoundsChanged.addListener(cb = callbackPass(function() {
+ chrome.test.assertEq(undefined, win.getMinWidth());
+ chrome.test.assertEq(undefined, win.getMinHeight());
+ chrome.test.assertEq(undefined, win.getMaxWidth());
+ chrome.test.assertEq(undefined, win.getMaxHeight());
+ win.close();
+ }));
+ }));
+ },
+
+ function testChangingMinAndMaxSize() {
+ chrome.app.window.create('test.html', {
+ bounds: { width: 102, height: 103 },
+ minWidth: 100, minHeight: 101,
+ maxWidth: 104, maxHeight: 105
+ }, callbackPass(function(win) {
+ chrome.test.assertEq(100, win.getMinWidth());
+ chrome.test.assertEq(101, win.getMinHeight());
+ chrome.test.assertEq(104, win.getMaxWidth());
+ chrome.test.assertEq(105, win.getMaxHeight());
+ win.setMinWidth(98);
+ win.setMinHeight(99);
+ win.setMaxWidth(106);
+ win.setMaxHeight(107);
+ // We need to wait for an onBoundsChanged to ensure the size has been
+ // updated.
+ win.setBounds({ width: 103, height: 102 });
+ var cb;
+ win.onBoundsChanged.addListener(cb = callbackPass(function() {
+ chrome.test.assertEq(98, win.getMinWidth());
+ chrome.test.assertEq(99, win.getMinHeight());
+ chrome.test.assertEq(106, win.getMaxWidth());
+ chrome.test.assertEq(107, win.getMaxHeight());
+ win.close();
+ }));
+ }));
+ },
+
+ function testMinWidthLargerThanMaxWidth() {
+ chrome.app.window.create('test.html', {
+ bounds: { width: 102, height: 103 },
+ minWidth: 100, minHeight: 101,
+ maxWidth: 104, maxHeight: 105
+ }, callbackPass(function(win) {
+ win.setMinWidth(200);
+ // An onBoundsChanged will be fired because this resizes the window.
+ var cb;
+ win.onBoundsChanged.addListener(cb = callbackPass(function() {
+ chrome.test.assertEq(200, win.getMinWidth());
+ chrome.test.assertEq(101, win.getMinHeight());
+ chrome.test.assertEq(200, win.getMaxWidth());
+ chrome.test.assertEq(105, win.getMaxHeight());
+ win.close();
+ }));
+ }));
+ },
+
+ function testMinHeightLargerThanMaxHeight() {
+ chrome.app.window.create('test.html', {
+ bounds: { width: 102, height: 103 },
+ minWidth: 100, minHeight: 101,
+ maxWidth: 104, maxHeight: 105
+ }, callbackPass(function(win) {
+ win.setMinHeight(200);
+ // An onBoundsChanged will be fired because this resizes the window.
+ var cb;
+ win.onBoundsChanged.addListener(cb = callbackPass(function() {
+ chrome.test.assertEq(100, win.getMinWidth());
+ chrome.test.assertEq(200, win.getMinHeight());
+ chrome.test.assertEq(104, win.getMaxWidth());
+ chrome.test.assertEq(200, win.getMaxHeight());
+ win.close();
+ }));
+ }));
+ },
+
+ function testMaxWidthSmallerThanMinWidth() {
+ chrome.app.window.create('test.html', {
+ bounds: { width: 102, height: 103 },
+ minWidth: 100, minHeight: 101,
+ maxWidth: 104, maxHeight: 105
+ }, callbackPass(function(win) {
+ win.setMaxWidth(50);
+ // An onBoundsChanged will be fired because this resizes the window.
+ var cb;
+ win.onBoundsChanged.addListener(cb = callbackPass(function() {
+ chrome.test.assertEq(100, win.getMinWidth());
+ chrome.test.assertEq(101, win.getMinHeight());
+ chrome.test.assertEq(100, win.getMaxWidth());
+ chrome.test.assertEq(105, win.getMaxHeight());
+ win.close();
+ }));
+ }));
+ },
+
+ function testMaxHeightSmallerThanMinHeight() {
+ chrome.app.window.create('test.html', {
+ bounds: { width: 102, height: 103 },
+ minWidth: 100, minHeight: 101,
+ maxWidth: 104, maxHeight: 105
+ }, callbackPass(function(win) {
+ win.setMaxHeight(50);
+ // An onBoundsChanged will be fired because this resizes the window.
+ var cb;
+ win.onBoundsChanged.addListener(cb = callbackPass(function() {
+ chrome.test.assertEq(100, win.getMinWidth());
+ chrome.test.assertEq(101, win.getMinHeight());
+ chrome.test.assertEq(104, win.getMaxWidth());
+ chrome.test.assertEq(101, win.getMaxHeight());
+ win.close();
+ }));
+ }));
+ },
+
function testMinSizeRestore() {
chrome.app.window.create('test.html', {
bounds: { width: 100, height: 150 },
« no previous file with comments | « chrome/renderer/resources/extensions/app_window_custom_bindings.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698