]> git.proxmox.com Git - extjs.git/blame - extjs/packages/core/test/specs/util/Region.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / core / test / specs / util / Region.js
CommitLineData
6527f429
DM
1Ext.require('Ext.util.Region', function() {\r
2 describe("Ext.util.Region", function() {\r
3 var region,\r
4 region1,\r
5 region2,\r
6 region3,\r
7 region4,\r
8 region5;\r
9\r
10 beforeEach(function() {\r
11 region1 = Ext.create('Ext.util.Region', 2, 5, 6, 1);\r
12 region2 = Ext.create('Ext.util.Region', 1, 6, 3, 4);\r
13 region3 = Ext.create('Ext.util.Region', 0, 2, 2, 0);\r
14 region4 = Ext.create('Ext.util.Region', 3, 4, 5, 2);\r
15 region5 = Ext.create('Ext.util.Region', 7, 3, 9, 1);\r
16 });\r
17\r
18 describe("contains", function() {\r
19 describe("form region 1 point of view", function() {\r
20 it("should not contain region 2", function() {\r
21 expect(region1.contains(region2)).toBe(false);\r
22 });\r
23\r
24 it("should not contain region 3", function() {\r
25 expect(region1.contains(region3)).toBe(false);\r
26 });\r
27\r
28 it("should contain region 4", function() {\r
29 expect(region1.contains(region4)).toBe(true);\r
30 });\r
31\r
32 it("should not contain region 5", function() {\r
33 expect(region1.contains(region5)).toBe(false);\r
34 });\r
35 });\r
36 });\r
37\r
38 describe("intersect", function() {\r
39 describe("form region 1 point of view", function() {\r
40 describe("between region 1 and 2", function() {\r
41 beforeEach(function() {\r
42 region = region1.intersect(region2);\r
43 });\r
44\r
45 it("should not return false", function() {\r
46 expect(region).not.toBe(false);\r
47 });\r
48\r
49 it("should return a region with top property equal to 2", function() {\r
50 expect(region.top).toEqual(2);\r
51 });\r
52\r
53 it("should return a region with left property equal to 4", function() {\r
54 expect(region.left).toEqual(4);\r
55 });\r
56\r
57 it("should return a region with bottom property equal to 3", function() {\r
58 expect(region.bottom).toEqual(3);\r
59 });\r
60\r
61 it("should return a region with right property equal to 5", function() {\r
62 expect(region.right).toEqual(5);\r
63 });\r
64 });\r
65\r
66 describe("between region 2 and 1", function() {\r
67 beforeEach(function() {\r
68 region = region2.intersect(region1);\r
69 });\r
70\r
71 it("should not return false", function() {\r
72 expect(region).not.toBe(false);\r
73 });\r
74\r
75 it("should return a region with top property equal to 2", function() {\r
76 expect(region.top).toEqual(2);\r
77 });\r
78\r
79 it("should return a region with left property equal to 4", function() {\r
80 expect(region.left).toEqual(4);\r
81 });\r
82\r
83 it("should return a region with bottom property equal to 3", function() {\r
84 expect(region.bottom).toEqual(3);\r
85 });\r
86\r
87 it("should return a region with right property equal to 5", function() {\r
88 expect(region.right).toEqual(5);\r
89 });\r
90 });\r
91\r
92 describe("between region 1 and 3", function() {\r
93 it("should have no intersection", function() {\r
94 expect(region1.intersect(region3)).toBe(false);\r
95 });\r
96 });\r
97\r
98 describe("between region 3 and 1", function() {\r
99 it("should have no intersection1", function() {\r
100 expect(region3.intersect(region1)).toBe(false);\r
101 });\r
102 });\r
103\r
104 describe("between region 1 and 4", function() {\r
105 beforeEach(function() {\r
106 region = region1.intersect(region4);\r
107 });\r
108\r
109 it("should not return false", function() {\r
110 expect(region).not.toBe(false);\r
111 });\r
112\r
113 it("should return a region with top property equal to 3", function() {\r
114 expect(region.top).toEqual(3);\r
115 });\r
116\r
117 it("should return a region with left property equal to 2", function() {\r
118 expect(region.left).toEqual(2);\r
119 });\r
120\r
121 it("should return a region with bottom property equal to 5", function() {\r
122 expect(region.bottom).toEqual(5);\r
123 });\r
124\r
125 it("should return a region with right property equal to 4", function() {\r
126 expect(region.right).toEqual(4);\r
127 });\r
128 });\r
129\r
130 describe("between region 4 and 1", function() {\r
131 beforeEach(function() {\r
132 region = region4.intersect(region1);\r
133 });\r
134\r
135 it("should not return false", function() {\r
136 expect(region).not.toBe(false);\r
137 });\r
138\r
139 it("should return a region with top property equal to 3", function() {\r
140 expect(region.top).toEqual(3);\r
141 });\r
142\r
143 it("should return a region with left property equal to 2", function() {\r
144 expect(region.left).toEqual(2);\r
145 });\r
146\r
147 it("should return a region with bottom property equal to 5", function() {\r
148 expect(region.bottom).toEqual(5);\r
149 });\r
150\r
151 it("should return a region with right property equal to 4", function() {\r
152 expect(region.right).toEqual(4);\r
153 });\r
154 });\r
155\r
156 describe("between region 1 and 5", function() {\r
157 it("should have no intersection", function() {\r
158 expect(region1.intersect(region5)).toBe(false);\r
159 });\r
160 });\r
161\r
162 describe("between region 5 and 1", function() {\r
163 it("should have no intersection", function() {\r
164 expect(region5.intersect(region1)).toBe(false);\r
165 });\r
166 });\r
167 });\r
168 });\r
169\r
170 describe("union", function() {\r
171 describe("form region 1 point of view", function() {\r
172 describe("between region 1 and 2", function() {\r
173 beforeEach(function() {\r
174 region = region1.union(region2);\r
175 });\r
176\r
177 it("should return a region with top property equal to 1", function() {\r
178 expect(region.top).toEqual(1);\r
179 });\r
180\r
181 it("should return a region with left property equal to 1", function() {\r
182 expect(region.left).toEqual(1);\r
183 });\r
184\r
185 it("should return a region with bottom property equal to 6", function() {\r
186 expect(region.bottom).toEqual(6);\r
187 });\r
188\r
189 it("should return a region with right property equal to 6", function() {\r
190 expect(region.right).toEqual(6);\r
191 });\r
192 });\r
193\r
194 describe("between region 2 and 1", function() {\r
195 beforeEach(function() {\r
196 region = region2.union(region1);\r
197 });\r
198\r
199 it("should return a region with top property equal to 1", function() {\r
200 expect(region.top).toEqual(1);\r
201 });\r
202\r
203 it("should return a region with left property equal to 1", function() {\r
204 expect(region.left).toEqual(1);\r
205 });\r
206\r
207 it("should return a region with bottom property equal to 6", function() {\r
208 expect(region.bottom).toEqual(6);\r
209 });\r
210\r
211 it("should return a region with right property equal to 6", function() {\r
212 expect(region.right).toEqual(6);\r
213 });\r
214 });\r
215\r
216 describe("between region 1 and 3", function() {\r
217 beforeEach(function() {\r
218 region = region1.union(region3);\r
219 });\r
220\r
221 it("should return a region with top property equal to 0", function() {\r
222 expect(region.top).toEqual(0);\r
223 });\r
224\r
225 it("should return a region with left property equal to 0", function() {\r
226 expect(region.left).toEqual(0);\r
227 });\r
228\r
229 it("should return a region with bottom property equal to 6", function() {\r
230 expect(region.bottom).toEqual(6);\r
231 });\r
232\r
233 it("should return a region with right property equal to 5", function() {\r
234 expect(region.right).toEqual(5);\r
235 });\r
236 });\r
237\r
238 describe("between region 3 and 1", function() {\r
239 beforeEach(function() {\r
240 region = region3.union(region1);\r
241 });\r
242\r
243 it("should return a region with top property equal to 0", function() {\r
244 expect(region.top).toEqual(0);\r
245 });\r
246\r
247 it("should return a region with left property equal to 0", function() {\r
248 expect(region.left).toEqual(0);\r
249 });\r
250\r
251 it("should return a region with bottom property equal to 6", function() {\r
252 expect(region.bottom).toEqual(6);\r
253 });\r
254\r
255 it("should return a region with right property equal to 5", function() {\r
256 expect(region.right).toEqual(5);\r
257 });\r
258 });\r
259\r
260 describe("between region 1 and 4", function() {\r
261 beforeEach(function() {\r
262 region = region1.union(region4);\r
263 });\r
264\r
265 it("should return a region with top property equal to 2", function() {\r
266 expect(region.top).toEqual(2);\r
267 });\r
268\r
269 it("should return a region with left property equal to 1", function() {\r
270 expect(region.left).toEqual(1);\r
271 });\r
272\r
273 it("should return a region with bottom property equal to 6", function() {\r
274 expect(region.bottom).toEqual(6);\r
275 });\r
276\r
277 it("should return a region with right property equal to 5", function() {\r
278 expect(region.right).toEqual(5);\r
279 });\r
280 });\r
281\r
282 describe("between region 4 and 1", function() {\r
283 beforeEach(function() {\r
284 region = region4.union(region1);\r
285 });\r
286\r
287 it("should return a region with top property equal to 2", function() {\r
288 expect(region.top).toEqual(2);\r
289 });\r
290\r
291 it("should return a region with left property equal to 1", function() {\r
292 expect(region.left).toEqual(1);\r
293 });\r
294\r
295 it("should return a region with bottom property equal to 6", function() {\r
296 expect(region.bottom).toEqual(6);\r
297 });\r
298\r
299 it("should return a region with right property equal to 5", function() {\r
300 expect(region.right).toEqual(5);\r
301 });\r
302 });\r
303\r
304 describe("between region 1 and 5", function() {\r
305 beforeEach(function() {\r
306 region = region1.union(region5);\r
307 });\r
308\r
309 it("should return a region with top property equal to 2", function() {\r
310 expect(region.top).toEqual(2);\r
311 });\r
312\r
313 it("should return a region with left property equal to 1", function() {\r
314 expect(region.left).toEqual(1);\r
315 });\r
316\r
317 it("should return a region with bottom property equal to 9", function() {\r
318 expect(region.bottom).toEqual(9);\r
319 });\r
320\r
321 it("should return a region with right property equal to 5", function() {\r
322 expect(region.right).toEqual(5);\r
323 });\r
324 });\r
325\r
326 describe("between region 5 and 1", function() {\r
327 beforeEach(function() {\r
328 region = region5.union(region1);\r
329 });\r
330\r
331 it("should return a region with top property equal to 2", function() {\r
332 expect(region.top).toEqual(2);\r
333 });\r
334\r
335 it("should return a region with left property equal to 1", function() {\r
336 expect(region.left).toEqual(1);\r
337 });\r
338\r
339 it("should return a region with bottom property equal to 9", function() {\r
340 expect(region.bottom).toEqual(9);\r
341 });\r
342\r
343 it("should return a region with right property equal to 5", function() {\r
344 expect(region.right).toEqual(5);\r
345 });\r
346 });\r
347 });\r
348 });\r
349\r
350 describe("constrainTo", function() {\r
351 describe("form region 1 point of view", function() {\r
352 describe("between region 1 and 2", function() {\r
353 beforeEach(function() {\r
354 region1.constrainTo(region2);\r
355 });\r
356\r
357 it("should set region 1 top property equal to 2", function() {\r
358 expect(region1.top).toEqual(2);\r
359 });\r
360\r
361 it("should set region 1 left property equal to 4", function() {\r
362 expect(region1.left).toEqual(4);\r
363 });\r
364\r
365 it("should set region 1 bottom property equal to 3", function() {\r
366 expect(region1.bottom).toEqual(3);\r
367 });\r
368\r
369 it("should set region 1 right property equal to 5", function() {\r
370 expect(region1.right).toEqual(5);\r
371 });\r
372 });\r
373\r
374 describe("between region 1 and 3", function() {\r
375 beforeEach(function() {\r
376 region1.constrainTo(region3);\r
377 });\r
378\r
379 it("should set region 1 top property equal to 2", function() {\r
380 expect(region1.top).toEqual(2);\r
381 });\r
382\r
383 it("should set region 1 left property equal to 1", function() {\r
384 expect(region1.left).toEqual(1);\r
385 });\r
386\r
387 it("should set region 1 bottom property equal to 2", function() {\r
388 expect(region1.bottom).toEqual(2);\r
389 });\r
390\r
391 it("should set region 1 right property equal to 2", function() {\r
392 expect(region1.right).toEqual(2);\r
393 });\r
394 });\r
395\r
396 describe("between region 1 and 4", function() {\r
397 beforeEach(function() {\r
398 region1.constrainTo(region4);\r
399 });\r
400\r
401 it("should set region 1 top property equal to 3", function() {\r
402 expect(region1.top).toEqual(3);\r
403 });\r
404\r
405 it("should set region 1 left property equal to 2", function() {\r
406 expect(region1.left).toEqual(2);\r
407 });\r
408\r
409 it("should set region 1 bottom property equal to 5", function() {\r
410 expect(region1.bottom).toEqual(5);\r
411 });\r
412\r
413 it("should set region 1 right property equal to 4", function() {\r
414 expect(region1.right).toEqual(4);\r
415 });\r
416 });\r
417\r
418 describe("between region 1 and 5", function() {\r
419 beforeEach(function() {\r
420 region1.constrainTo(region5);\r
421 });\r
422\r
423 it("should set region 1 top property equal to 7", function() {\r
424 expect(region1.top).toEqual(7);\r
425 });\r
426\r
427 it("should set region 1 left property equal to 1", function() {\r
428 expect(region1.left).toEqual(1);\r
429 });\r
430\r
431 it("should set region 1 bottom property equal to 7", function() {\r
432 expect(region1.bottom).toEqual(7);\r
433 });\r
434\r
435 it("should set region 1 right property equal to 3", function() {\r
436 expect(region1.right).toEqual(3);\r
437 });\r
438 });\r
439 });\r
440 });\r
441\r
442 describe("adjust", function() {\r
443 describe("modify the current region to be adjusted by offset", function() {\r
444 beforeEach(function() {\r
445 region1.adjust(1, 2, 3, 4);\r
446 });\r
447\r
448 it("should set region 1 top property equal to 3", function() {\r
449 expect(region1.top).toEqual(3);\r
450 });\r
451\r
452 it("should set region 1 left property equal to 5", function() {\r
453 expect(region1.left).toEqual(5);\r
454 });\r
455\r
456 it("should set region 1 bottom property equal to 9", function() {\r
457 expect(region1.bottom).toEqual(9);\r
458 });\r
459\r
460 it("should set region 1 right property equal to 7", function() {\r
461 expect(region1.right).toEqual(7);\r
462 });\r
463 });\r
464 });\r
465 });\r
466\r
467});\r