OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var callbackPass = chrome.test.callbackPass; | 5 var callbackPass = chrome.test.callbackPass; |
6 | 6 |
7 chrome.app.runtime.onLaunched.addListener(function() { | 7 chrome.app.runtime.onLaunched.addListener(function() { |
8 chrome.test.runTests([ | 8 chrome.test.runTests([ |
9 function testCreateWindow() { | 9 function testCreateWindow() { |
10 chrome.app.window.create('test.html', | 10 chrome.app.window.create('test.html', |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 minWidth: 400, minHeight: 450, | 122 minWidth: 400, minHeight: 450, |
123 maxWidth: 200, maxHeight: 150 | 123 maxWidth: 200, maxHeight: 150 |
124 }, callbackPass(function(win) { | 124 }, callbackPass(function(win) { |
125 var w = win.contentWindow; | 125 var w = win.contentWindow; |
126 chrome.test.assertEq(400, w.innerWidth); | 126 chrome.test.assertEq(400, w.innerWidth); |
127 chrome.test.assertEq(450, w.innerHeight); | 127 chrome.test.assertEq(450, w.innerHeight); |
128 w.close(); | 128 w.close(); |
129 })); | 129 })); |
130 }, | 130 }, |
131 | 131 |
| 132 function testChangingMinAndMaxSize() { |
| 133 chrome.app.window.create('test.html', { |
| 134 bounds: { width: 102, height: 103 }, |
| 135 minWidth: 100, minHeight: 101, |
| 136 maxWidth: 104, maxHeight: 105 |
| 137 }, callbackPass(function(win) { |
| 138 chrome.test.assertEq(100, win.getMinWidth()); |
| 139 chrome.test.assertEq(101, win.getMinHeight()); |
| 140 chrome.test.assertEq(104, win.getMaxWidth()); |
| 141 chrome.test.assertEq(105, win.getMaxHeight()); |
| 142 win.setMinWidth(98); |
| 143 win.setMinHeight(99); |
| 144 win.setMaxWidth(106); |
| 145 win.setMaxHeight(107); |
| 146 // We need to wait for an onBoundsChanged to ensure the size has been |
| 147 // updated. |
| 148 win.setBounds({ width: 103, height: 102 }); |
| 149 var cb; |
| 150 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 151 chrome.test.assertEq(98, win.getMinWidth()); |
| 152 chrome.test.assertEq(99, win.getMinHeight()); |
| 153 chrome.test.assertEq(106, win.getMaxWidth()); |
| 154 chrome.test.assertEq(107, win.getMaxHeight()); |
| 155 win.close(); |
| 156 })); |
| 157 })); |
| 158 }, |
| 159 |
| 160 function testMinWidthLargerThanMaxWidth() { |
| 161 chrome.app.window.create('test.html', { |
| 162 bounds: { width: 102, height: 103 }, |
| 163 minWidth: 100, minHeight: 101, |
| 164 maxWidth: 104, maxHeight: 105 |
| 165 }, callbackPass(function(win) { |
| 166 win.setMinWidth(200); |
| 167 // An onBoundsChanged will be fired because this resizes the window. |
| 168 var cb; |
| 169 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 170 chrome.test.assertEq(200, win.getMinWidth()); |
| 171 chrome.test.assertEq(101, win.getMinHeight()); |
| 172 chrome.test.assertEq(200, win.getMaxWidth()); |
| 173 chrome.test.assertEq(105, win.getMaxHeight()); |
| 174 win.close(); |
| 175 })); |
| 176 })); |
| 177 }, |
| 178 |
| 179 function testMinHeightLargerThanMaxHeight() { |
| 180 chrome.app.window.create('test.html', { |
| 181 bounds: { width: 102, height: 103 }, |
| 182 minWidth: 100, minHeight: 101, |
| 183 maxWidth: 104, maxHeight: 105 |
| 184 }, callbackPass(function(win) { |
| 185 win.setMinHeight(200); |
| 186 // An onBoundsChanged will be fired because this resizes the window. |
| 187 var cb; |
| 188 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 189 chrome.test.assertEq(100, win.getMinWidth()); |
| 190 chrome.test.assertEq(200, win.getMinHeight()); |
| 191 chrome.test.assertEq(104, win.getMaxWidth()); |
| 192 chrome.test.assertEq(200, win.getMaxHeight()); |
| 193 win.close(); |
| 194 })); |
| 195 })); |
| 196 }, |
| 197 |
| 198 function testMaxWidthSmallerThanMinWidth() { |
| 199 chrome.app.window.create('test.html', { |
| 200 bounds: { width: 102, height: 103 }, |
| 201 minWidth: 100, minHeight: 101, |
| 202 maxWidth: 104, maxHeight: 105 |
| 203 }, callbackPass(function(win) { |
| 204 win.setMaxWidth(50); |
| 205 // An onBoundsChanged will be fired because this resizes the window. |
| 206 var cb; |
| 207 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 208 chrome.test.assertEq(100, win.getMinWidth()); |
| 209 chrome.test.assertEq(101, win.getMinHeight()); |
| 210 chrome.test.assertEq(100, win.getMaxWidth()); |
| 211 chrome.test.assertEq(105, win.getMaxHeight()); |
| 212 win.close(); |
| 213 })); |
| 214 })); |
| 215 }, |
| 216 |
| 217 function testMaxHeightSmallerThanMinHeight() { |
| 218 chrome.app.window.create('test.html', { |
| 219 bounds: { width: 102, height: 103 }, |
| 220 minWidth: 100, minHeight: 101, |
| 221 maxWidth: 104, maxHeight: 105 |
| 222 }, callbackPass(function(win) { |
| 223 win.setMaxHeight(50); |
| 224 // An onBoundsChanged will be fired because this resizes the window. |
| 225 var cb; |
| 226 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 227 chrome.test.assertEq(100, win.getMinWidth()); |
| 228 chrome.test.assertEq(101, win.getMinHeight()); |
| 229 chrome.test.assertEq(104, win.getMaxWidth()); |
| 230 chrome.test.assertEq(101, win.getMaxHeight()); |
| 231 win.close(); |
| 232 })); |
| 233 })); |
| 234 }, |
| 235 |
132 function testMinSizeRestore() { | 236 function testMinSizeRestore() { |
133 chrome.app.window.create('test.html', { | 237 chrome.app.window.create('test.html', { |
134 bounds: { width: 100, height: 150 }, | 238 bounds: { width: 100, height: 150 }, |
135 minWidth: 200, minHeight: 250, | 239 minWidth: 200, minHeight: 250, |
136 maxWidth: 200, maxHeight: 250, | 240 maxWidth: 200, maxHeight: 250, |
137 id: 'test-id', singleton: false | 241 id: 'test-id', singleton: false |
138 }, callbackPass(function(win) { | 242 }, callbackPass(function(win) { |
139 var w = win.contentWindow; | 243 var w = win.contentWindow; |
140 chrome.test.assertEq(200, w.innerWidth); | 244 chrome.test.assertEq(200, w.innerWidth); |
141 chrome.test.assertEq(250, w.innerHeight); | 245 chrome.test.assertEq(250, w.innerHeight); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 chrome.test.assertEq(oldHeight, win.innerHeight); | 332 chrome.test.assertEq(oldHeight, win.innerHeight); |
229 }); | 333 }); |
230 }) | 334 }) |
231 win.chrome.app.window.restore(); | 335 win.chrome.app.window.restore(); |
232 }); | 336 }); |
233 win.chrome.app.window.maximize(); | 337 win.chrome.app.window.maximize(); |
234 })); | 338 })); |
235 },*/ | 339 },*/ |
236 ]); | 340 ]); |
237 }); | 341 }); |
OLD | NEW |