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 testUndefinedMinAndMaxSize() { |
| 133 chrome.app.window.create('test.html', { |
| 134 bounds: { width: 250, height: 250 } |
| 135 }, callbackPass(function(win) { |
| 136 chrome.test.assertEq(undefined, win.getMinWidth()); |
| 137 chrome.test.assertEq(undefined, win.getMinHeight()); |
| 138 chrome.test.assertEq(undefined, win.getMaxWidth()); |
| 139 chrome.test.assertEq(undefined, win.getMaxHeight()); |
| 140 win.close(); |
| 141 })); |
| 142 }, |
| 143 |
| 144 function testSetUndefinedMinAndMaxSize() { |
| 145 chrome.app.window.create('test.html', { |
| 146 bounds: { width: 102, height: 103 }, |
| 147 minWidth: 100, minHeight: 101, |
| 148 maxWidth: 104, maxHeight: 105 |
| 149 }, callbackPass(function(win) { |
| 150 chrome.test.assertEq(100, win.getMinWidth()); |
| 151 chrome.test.assertEq(101, win.getMinHeight()); |
| 152 chrome.test.assertEq(104, win.getMaxWidth()); |
| 153 chrome.test.assertEq(105, win.getMaxHeight()); |
| 154 win.setMinWidth(null); |
| 155 win.setMinHeight(null); |
| 156 win.setMaxWidth(null); |
| 157 win.setMaxHeight(null); |
| 158 // We need to wait for an onBoundsChanged to ensure the size has been |
| 159 // updated. |
| 160 win.setBounds({ width: 103, height: 102 }); |
| 161 var cb; |
| 162 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 163 chrome.test.assertEq(undefined, win.getMinWidth()); |
| 164 chrome.test.assertEq(undefined, win.getMinHeight()); |
| 165 chrome.test.assertEq(undefined, win.getMaxWidth()); |
| 166 chrome.test.assertEq(undefined, win.getMaxHeight()); |
| 167 win.close(); |
| 168 })); |
| 169 })); |
| 170 }, |
| 171 |
| 172 function testChangingMinAndMaxSize() { |
| 173 chrome.app.window.create('test.html', { |
| 174 bounds: { width: 102, height: 103 }, |
| 175 minWidth: 100, minHeight: 101, |
| 176 maxWidth: 104, maxHeight: 105 |
| 177 }, callbackPass(function(win) { |
| 178 chrome.test.assertEq(100, win.getMinWidth()); |
| 179 chrome.test.assertEq(101, win.getMinHeight()); |
| 180 chrome.test.assertEq(104, win.getMaxWidth()); |
| 181 chrome.test.assertEq(105, win.getMaxHeight()); |
| 182 win.setMinWidth(98); |
| 183 win.setMinHeight(99); |
| 184 win.setMaxWidth(106); |
| 185 win.setMaxHeight(107); |
| 186 // We need to wait for an onBoundsChanged to ensure the size has been |
| 187 // updated. |
| 188 win.setBounds({ width: 103, height: 102 }); |
| 189 var cb; |
| 190 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 191 chrome.test.assertEq(98, win.getMinWidth()); |
| 192 chrome.test.assertEq(99, win.getMinHeight()); |
| 193 chrome.test.assertEq(106, win.getMaxWidth()); |
| 194 chrome.test.assertEq(107, win.getMaxHeight()); |
| 195 win.close(); |
| 196 })); |
| 197 })); |
| 198 }, |
| 199 |
| 200 function testMinWidthLargerThanMaxWidth() { |
| 201 chrome.app.window.create('test.html', { |
| 202 bounds: { width: 102, height: 103 }, |
| 203 minWidth: 100, minHeight: 101, |
| 204 maxWidth: 104, maxHeight: 105 |
| 205 }, callbackPass(function(win) { |
| 206 win.setMinWidth(200); |
| 207 // An onBoundsChanged will be fired because this resizes the window. |
| 208 var cb; |
| 209 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 210 chrome.test.assertEq(200, win.getMinWidth()); |
| 211 chrome.test.assertEq(101, win.getMinHeight()); |
| 212 chrome.test.assertEq(200, win.getMaxWidth()); |
| 213 chrome.test.assertEq(105, win.getMaxHeight()); |
| 214 win.close(); |
| 215 })); |
| 216 })); |
| 217 }, |
| 218 |
| 219 function testMinHeightLargerThanMaxHeight() { |
| 220 chrome.app.window.create('test.html', { |
| 221 bounds: { width: 102, height: 103 }, |
| 222 minWidth: 100, minHeight: 101, |
| 223 maxWidth: 104, maxHeight: 105 |
| 224 }, callbackPass(function(win) { |
| 225 win.setMinHeight(200); |
| 226 // An onBoundsChanged will be fired because this resizes the window. |
| 227 var cb; |
| 228 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 229 chrome.test.assertEq(100, win.getMinWidth()); |
| 230 chrome.test.assertEq(200, win.getMinHeight()); |
| 231 chrome.test.assertEq(104, win.getMaxWidth()); |
| 232 chrome.test.assertEq(200, win.getMaxHeight()); |
| 233 win.close(); |
| 234 })); |
| 235 })); |
| 236 }, |
| 237 |
| 238 function testMaxWidthSmallerThanMinWidth() { |
| 239 chrome.app.window.create('test.html', { |
| 240 bounds: { width: 102, height: 103 }, |
| 241 minWidth: 100, minHeight: 101, |
| 242 maxWidth: 104, maxHeight: 105 |
| 243 }, callbackPass(function(win) { |
| 244 win.setMaxWidth(50); |
| 245 // An onBoundsChanged will be fired because this resizes the window. |
| 246 var cb; |
| 247 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 248 chrome.test.assertEq(100, win.getMinWidth()); |
| 249 chrome.test.assertEq(101, win.getMinHeight()); |
| 250 chrome.test.assertEq(100, win.getMaxWidth()); |
| 251 chrome.test.assertEq(105, win.getMaxHeight()); |
| 252 win.close(); |
| 253 })); |
| 254 })); |
| 255 }, |
| 256 |
| 257 function testMaxHeightSmallerThanMinHeight() { |
| 258 chrome.app.window.create('test.html', { |
| 259 bounds: { width: 102, height: 103 }, |
| 260 minWidth: 100, minHeight: 101, |
| 261 maxWidth: 104, maxHeight: 105 |
| 262 }, callbackPass(function(win) { |
| 263 win.setMaxHeight(50); |
| 264 // An onBoundsChanged will be fired because this resizes the window. |
| 265 var cb; |
| 266 win.onBoundsChanged.addListener(cb = callbackPass(function() { |
| 267 chrome.test.assertEq(100, win.getMinWidth()); |
| 268 chrome.test.assertEq(101, win.getMinHeight()); |
| 269 chrome.test.assertEq(104, win.getMaxWidth()); |
| 270 chrome.test.assertEq(101, win.getMaxHeight()); |
| 271 win.close(); |
| 272 })); |
| 273 })); |
| 274 }, |
| 275 |
132 function testMinSizeRestore() { | 276 function testMinSizeRestore() { |
133 chrome.app.window.create('test.html', { | 277 chrome.app.window.create('test.html', { |
134 bounds: { width: 100, height: 150 }, | 278 bounds: { width: 100, height: 150 }, |
135 minWidth: 200, minHeight: 250, | 279 minWidth: 200, minHeight: 250, |
136 maxWidth: 200, maxHeight: 250, | 280 maxWidth: 200, maxHeight: 250, |
137 id: 'test-id', singleton: false | 281 id: 'test-id', singleton: false |
138 }, callbackPass(function(win) { | 282 }, callbackPass(function(win) { |
139 var w = win.contentWindow; | 283 var w = win.contentWindow; |
140 chrome.test.assertEq(200, w.innerWidth); | 284 chrome.test.assertEq(200, w.innerWidth); |
141 chrome.test.assertEq(250, w.innerHeight); | 285 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); | 372 chrome.test.assertEq(oldHeight, win.innerHeight); |
229 }); | 373 }); |
230 }) | 374 }) |
231 win.chrome.app.window.restore(); | 375 win.chrome.app.window.restore(); |
232 }); | 376 }); |
233 win.chrome.app.window.maximize(); | 377 win.chrome.app.window.maximize(); |
234 })); | 378 })); |
235 },*/ | 379 },*/ |
236 ]); | 380 ]); |
237 }); | 381 }); |
OLD | NEW |