]>
git.proxmox.com Git - extjs.git/blob - extjs/packages/core/test/specs/util/Region.js
1 Ext
.require('Ext.util.Region', function() {
2 describe("Ext.util.Region", function() {
10 beforeEach(function() {
11 region1
= Ext
.create('Ext.util.Region', 2, 5, 6, 1);
12 region2
= Ext
.create('Ext.util.Region', 1, 6, 3, 4);
13 region3
= Ext
.create('Ext.util.Region', 0, 2, 2, 0);
14 region4
= Ext
.create('Ext.util.Region', 3, 4, 5, 2);
15 region5
= Ext
.create('Ext.util.Region', 7, 3, 9, 1);
18 describe("contains", function() {
19 describe("form region 1 point of view", function() {
20 it("should not contain region 2", function() {
21 expect(region1
.contains(region2
)).toBe(false);
24 it("should not contain region 3", function() {
25 expect(region1
.contains(region3
)).toBe(false);
28 it("should contain region 4", function() {
29 expect(region1
.contains(region4
)).toBe(true);
32 it("should not contain region 5", function() {
33 expect(region1
.contains(region5
)).toBe(false);
38 describe("intersect", function() {
39 describe("form region 1 point of view", function() {
40 describe("between region 1 and 2", function() {
41 beforeEach(function() {
42 region
= region1
.intersect(region2
);
45 it("should not return false", function() {
46 expect(region
).not
.toBe(false);
49 it("should return a region with top property equal to 2", function() {
50 expect(region
.top
).toEqual(2);
53 it("should return a region with left property equal to 4", function() {
54 expect(region
.left
).toEqual(4);
57 it("should return a region with bottom property equal to 3", function() {
58 expect(region
.bottom
).toEqual(3);
61 it("should return a region with right property equal to 5", function() {
62 expect(region
.right
).toEqual(5);
66 describe("between region 2 and 1", function() {
67 beforeEach(function() {
68 region
= region2
.intersect(region1
);
71 it("should not return false", function() {
72 expect(region
).not
.toBe(false);
75 it("should return a region with top property equal to 2", function() {
76 expect(region
.top
).toEqual(2);
79 it("should return a region with left property equal to 4", function() {
80 expect(region
.left
).toEqual(4);
83 it("should return a region with bottom property equal to 3", function() {
84 expect(region
.bottom
).toEqual(3);
87 it("should return a region with right property equal to 5", function() {
88 expect(region
.right
).toEqual(5);
92 describe("between region 1 and 3", function() {
93 it("should have no intersection", function() {
94 expect(region1
.intersect(region3
)).toBe(false);
98 describe("between region 3 and 1", function() {
99 it("should have no intersection1", function() {
100 expect(region3
.intersect(region1
)).toBe(false);
104 describe("between region 1 and 4", function() {
105 beforeEach(function() {
106 region
= region1
.intersect(region4
);
109 it("should not return false", function() {
110 expect(region
).not
.toBe(false);
113 it("should return a region with top property equal to 3", function() {
114 expect(region
.top
).toEqual(3);
117 it("should return a region with left property equal to 2", function() {
118 expect(region
.left
).toEqual(2);
121 it("should return a region with bottom property equal to 5", function() {
122 expect(region
.bottom
).toEqual(5);
125 it("should return a region with right property equal to 4", function() {
126 expect(region
.right
).toEqual(4);
130 describe("between region 4 and 1", function() {
131 beforeEach(function() {
132 region
= region4
.intersect(region1
);
135 it("should not return false", function() {
136 expect(region
).not
.toBe(false);
139 it("should return a region with top property equal to 3", function() {
140 expect(region
.top
).toEqual(3);
143 it("should return a region with left property equal to 2", function() {
144 expect(region
.left
).toEqual(2);
147 it("should return a region with bottom property equal to 5", function() {
148 expect(region
.bottom
).toEqual(5);
151 it("should return a region with right property equal to 4", function() {
152 expect(region
.right
).toEqual(4);
156 describe("between region 1 and 5", function() {
157 it("should have no intersection", function() {
158 expect(region1
.intersect(region5
)).toBe(false);
162 describe("between region 5 and 1", function() {
163 it("should have no intersection", function() {
164 expect(region5
.intersect(region1
)).toBe(false);
170 describe("union", function() {
171 describe("form region 1 point of view", function() {
172 describe("between region 1 and 2", function() {
173 beforeEach(function() {
174 region
= region1
.union(region2
);
177 it("should return a region with top property equal to 1", function() {
178 expect(region
.top
).toEqual(1);
181 it("should return a region with left property equal to 1", function() {
182 expect(region
.left
).toEqual(1);
185 it("should return a region with bottom property equal to 6", function() {
186 expect(region
.bottom
).toEqual(6);
189 it("should return a region with right property equal to 6", function() {
190 expect(region
.right
).toEqual(6);
194 describe("between region 2 and 1", function() {
195 beforeEach(function() {
196 region
= region2
.union(region1
);
199 it("should return a region with top property equal to 1", function() {
200 expect(region
.top
).toEqual(1);
203 it("should return a region with left property equal to 1", function() {
204 expect(region
.left
).toEqual(1);
207 it("should return a region with bottom property equal to 6", function() {
208 expect(region
.bottom
).toEqual(6);
211 it("should return a region with right property equal to 6", function() {
212 expect(region
.right
).toEqual(6);
216 describe("between region 1 and 3", function() {
217 beforeEach(function() {
218 region
= region1
.union(region3
);
221 it("should return a region with top property equal to 0", function() {
222 expect(region
.top
).toEqual(0);
225 it("should return a region with left property equal to 0", function() {
226 expect(region
.left
).toEqual(0);
229 it("should return a region with bottom property equal to 6", function() {
230 expect(region
.bottom
).toEqual(6);
233 it("should return a region with right property equal to 5", function() {
234 expect(region
.right
).toEqual(5);
238 describe("between region 3 and 1", function() {
239 beforeEach(function() {
240 region
= region3
.union(region1
);
243 it("should return a region with top property equal to 0", function() {
244 expect(region
.top
).toEqual(0);
247 it("should return a region with left property equal to 0", function() {
248 expect(region
.left
).toEqual(0);
251 it("should return a region with bottom property equal to 6", function() {
252 expect(region
.bottom
).toEqual(6);
255 it("should return a region with right property equal to 5", function() {
256 expect(region
.right
).toEqual(5);
260 describe("between region 1 and 4", function() {
261 beforeEach(function() {
262 region
= region1
.union(region4
);
265 it("should return a region with top property equal to 2", function() {
266 expect(region
.top
).toEqual(2);
269 it("should return a region with left property equal to 1", function() {
270 expect(region
.left
).toEqual(1);
273 it("should return a region with bottom property equal to 6", function() {
274 expect(region
.bottom
).toEqual(6);
277 it("should return a region with right property equal to 5", function() {
278 expect(region
.right
).toEqual(5);
282 describe("between region 4 and 1", function() {
283 beforeEach(function() {
284 region
= region4
.union(region1
);
287 it("should return a region with top property equal to 2", function() {
288 expect(region
.top
).toEqual(2);
291 it("should return a region with left property equal to 1", function() {
292 expect(region
.left
).toEqual(1);
295 it("should return a region with bottom property equal to 6", function() {
296 expect(region
.bottom
).toEqual(6);
299 it("should return a region with right property equal to 5", function() {
300 expect(region
.right
).toEqual(5);
304 describe("between region 1 and 5", function() {
305 beforeEach(function() {
306 region
= region1
.union(region5
);
309 it("should return a region with top property equal to 2", function() {
310 expect(region
.top
).toEqual(2);
313 it("should return a region with left property equal to 1", function() {
314 expect(region
.left
).toEqual(1);
317 it("should return a region with bottom property equal to 9", function() {
318 expect(region
.bottom
).toEqual(9);
321 it("should return a region with right property equal to 5", function() {
322 expect(region
.right
).toEqual(5);
326 describe("between region 5 and 1", function() {
327 beforeEach(function() {
328 region
= region5
.union(region1
);
331 it("should return a region with top property equal to 2", function() {
332 expect(region
.top
).toEqual(2);
335 it("should return a region with left property equal to 1", function() {
336 expect(region
.left
).toEqual(1);
339 it("should return a region with bottom property equal to 9", function() {
340 expect(region
.bottom
).toEqual(9);
343 it("should return a region with right property equal to 5", function() {
344 expect(region
.right
).toEqual(5);
350 describe("constrainTo", function() {
351 describe("form region 1 point of view", function() {
352 describe("between region 1 and 2", function() {
353 beforeEach(function() {
354 region1
.constrainTo(region2
);
357 it("should set region 1 top property equal to 2", function() {
358 expect(region1
.top
).toEqual(2);
361 it("should set region 1 left property equal to 4", function() {
362 expect(region1
.left
).toEqual(4);
365 it("should set region 1 bottom property equal to 3", function() {
366 expect(region1
.bottom
).toEqual(3);
369 it("should set region 1 right property equal to 5", function() {
370 expect(region1
.right
).toEqual(5);
374 describe("between region 1 and 3", function() {
375 beforeEach(function() {
376 region1
.constrainTo(region3
);
379 it("should set region 1 top property equal to 2", function() {
380 expect(region1
.top
).toEqual(2);
383 it("should set region 1 left property equal to 1", function() {
384 expect(region1
.left
).toEqual(1);
387 it("should set region 1 bottom property equal to 2", function() {
388 expect(region1
.bottom
).toEqual(2);
391 it("should set region 1 right property equal to 2", function() {
392 expect(region1
.right
).toEqual(2);
396 describe("between region 1 and 4", function() {
397 beforeEach(function() {
398 region1
.constrainTo(region4
);
401 it("should set region 1 top property equal to 3", function() {
402 expect(region1
.top
).toEqual(3);
405 it("should set region 1 left property equal to 2", function() {
406 expect(region1
.left
).toEqual(2);
409 it("should set region 1 bottom property equal to 5", function() {
410 expect(region1
.bottom
).toEqual(5);
413 it("should set region 1 right property equal to 4", function() {
414 expect(region1
.right
).toEqual(4);
418 describe("between region 1 and 5", function() {
419 beforeEach(function() {
420 region1
.constrainTo(region5
);
423 it("should set region 1 top property equal to 7", function() {
424 expect(region1
.top
).toEqual(7);
427 it("should set region 1 left property equal to 1", function() {
428 expect(region1
.left
).toEqual(1);
431 it("should set region 1 bottom property equal to 7", function() {
432 expect(region1
.bottom
).toEqual(7);
435 it("should set region 1 right property equal to 3", function() {
436 expect(region1
.right
).toEqual(3);
442 describe("adjust", function() {
443 describe("modify the current region to be adjusted by offset", function() {
444 beforeEach(function() {
445 region1
.adjust(1, 2, 3, 4);
448 it("should set region 1 top property equal to 3", function() {
449 expect(region1
.top
).toEqual(3);
452 it("should set region 1 left property equal to 5", function() {
453 expect(region1
.left
).toEqual(5);
456 it("should set region 1 bottom property equal to 9", function() {
457 expect(region1
.bottom
).toEqual(9);
460 it("should set region 1 right property equal to 7", function() {
461 expect(region1
.right
).toEqual(7);