sproutcore 1.10.0.rc.2 → 1.10.0.rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/VERSION.yml +1 -1
- data/lib/frameworks/sproutcore/CHANGELOG.md +14 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +9 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane_statechart.js +7 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +14 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +103 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutChildViews.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +4 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/viewDidResize.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +17 -6
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +62 -8
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +14 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +26 -5
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/integration/many_array.js +9 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/data_store.js +6 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/mixins/split_child.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +0 -2
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/render.js +56 -54
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/methods.js +221 -171
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/methods.js +261 -315
- data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/split_child.js +137 -122
- data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +10 -7
- data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +5 -4
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_display.js +14 -14
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +123 -98
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js +18 -6
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/api.js +9 -11
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/transition_test.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +15 -16
- data/lib/frameworks/sproutcore/frameworks/foundation/views/inline_text_field.js +11 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +170 -153
- data/lib/frameworks/sproutcore/frameworks/table/views/table.js +105 -101
- data/lib/frameworks/sproutcore/frameworks/table/views/table_head.js +0 -7
- data/lib/frameworks/sproutcore/frameworks/table/views/table_header.js +46 -56
- data/lib/frameworks/sproutcore/frameworks/table/views/table_row.js +0 -6
- data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/collection.js +12 -4
- data/lib/frameworks/sproutcore/frameworks/template_view/views/bindable_span.js +3 -2
- data/lib/frameworks/sproutcore/frameworks/template_view/views/template_collection.js +11 -8
- data/lib/frameworks/sproutcore/tests/phantomjs_runner.phantomjs +0 -1
- metadata +3 -3
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/beginEditing.js +0 -235
@@ -4,6 +4,7 @@
|
|
4
4
|
// portions copyright ©2011 Apple Inc.
|
5
5
|
// License: Licensed under MIT license (see license.js)
|
6
6
|
// ==========================================================================
|
7
|
+
/*global equals, module, test */
|
7
8
|
|
8
9
|
/*
|
9
10
|
Tests SplitView methods; specifically, the API that users of SplitView use
|
@@ -23,344 +24,289 @@
|
|
23
24
|
|
24
25
|
function setupTestSuite(layoutDirection) {
|
25
26
|
|
26
|
-
var splitView, left, right, middleLeft, middleRight;
|
27
|
+
var splitView, left, right, middleLeft, middleRight;
|
27
28
|
|
28
|
-
module(
|
29
|
-
|
30
|
-
SC.
|
31
|
-
|
32
|
-
|
29
|
+
module(
|
30
|
+
"SplitView " +
|
31
|
+
(layoutDirection === SC.HORIZONTAL_LAYOUT ? "Horizontal" : "Vertical") +
|
32
|
+
" - Methods",
|
33
|
+
{
|
34
|
+
setup: function () {
|
35
|
+
SC.RunLoop.begin();
|
36
|
+
// we test with no split divider because we want to easily calculate layout.
|
37
|
+
splitView = SC.SplitView.create({
|
38
|
+
childViews: [
|
39
|
+
SC.View.create(SC.SplitChild, { canCollapse: YES, collapseAtSize: 50 }),
|
40
|
+
SC.View.create(SC.SplitChild, { canCollapse: YES, collapseAtSize: 50 })
|
41
|
+
],
|
42
|
+
|
43
|
+
layout: { left: 0, top: 0, width: 500, height: 500 },
|
44
|
+
|
45
|
+
layoutDirection: layoutDirection,
|
46
|
+
|
47
|
+
splitDividerView: null
|
48
|
+
});
|
49
|
+
|
50
|
+
SC.RunLoop.end();
|
51
|
+
|
52
|
+
left = splitView.childViews[0];
|
53
|
+
right = splitView.childViews[1];
|
54
|
+
},
|
55
|
+
|
56
|
+
teardown: function () {
|
57
|
+
|
58
|
+
}
|
59
|
+
});
|
60
|
+
|
61
|
+
test("Initial positions are correct", function () {
|
62
|
+
equals(splitView.childViews.length, 2, "SplitView has 2 children");
|
63
|
+
equals(splitView.getPositionForChild(left), 0, "Left should always be at 0");
|
64
|
+
equals(splitView.getPositionForChild(right), 250, "Right should be at 1/2: 50");
|
65
|
+
});
|
66
|
+
|
67
|
+
test("Can adjust position for a child", function () {
|
68
|
+
var result = splitView.adjustPositionForChild(right, 100);
|
69
|
+
equals(result, 100, "Result of adjustPositionForChild(right, 100)");
|
70
|
+
equals(left.get('position'), 0, "Left position (should always be 0)");
|
71
|
+
equals(left.get('size'), 100, "Left size");
|
72
|
+
equals(right.get('position'), 100, "Right position");
|
73
|
+
equals(right.get('size'), 400, "Right size");
|
74
|
+
});
|
75
|
+
|
76
|
+
|
77
|
+
test("SplitView - Methods: Minimum and Maximum widths and heights", function () {
|
78
|
+
// first, test with the built-in minimum size
|
79
|
+
var result = splitView.adjustPositionForChild(right, 80);
|
80
|
+
equals(result, 100, "Result of adjustPositionForChild(right, 80)");
|
81
|
+
equals(left.get('position'), 0, "Left position (should always be 0)");
|
82
|
+
equals(left.get('size'), 100, "Left size");
|
83
|
+
equals(right.get('position'), 100, "Right position");
|
84
|
+
equals(right.get('size'), 400, "Right size");
|
85
|
+
|
86
|
+
// now, add a max and test that
|
87
|
+
left.set('maximumSize', 150);
|
88
|
+
|
89
|
+
result = splitView.adjustPositionForChild(right, 180);
|
90
|
+
equals(result, 150, "Result of adjustPositionForChild(right, 180) when left's max size = 150");
|
91
|
+
equals(left.get('position'), 0, "Left position (should always be 0)");
|
92
|
+
equals(left.get('size'), 150, "Left size");
|
93
|
+
equals(right.get('position'), 150, "Right position");
|
94
|
+
equals(right.get('size'), 350, "Right size");
|
95
|
+
|
96
|
+
// and now go back to middle
|
97
|
+
result = splitView.adjustPositionForChild(right, 130);
|
98
|
+
equals(result, 130, "Result of adjustPositionForChild(right, 130) when left's max size = 150");
|
99
|
+
equals(left.get('position'), 0, "Left position (should always be 0)");
|
100
|
+
equals(left.get('size'), 130, "Left size");
|
101
|
+
equals(right.get('position'), 130, "Right position");
|
102
|
+
equals(right.get('size'), 370, "Right size");
|
103
|
+
});
|
104
|
+
|
105
|
+
test("SplitView - Methods: Collapsing a child", function () {
|
106
|
+
var result = splitView.adjustPositionForChild(right, 40);
|
107
|
+
|
108
|
+
// first was collapsed, so position of seconds is now at 0.
|
109
|
+
equals(result, 0, "Result of adjustPositionForChild(right, 40)");
|
110
|
+
equals(left.get('position'), 0, "Left position (should always be 0)");
|
111
|
+
equals(left.get('size'), 0, "Left size after collapsing");
|
112
|
+
equals(right.get('position'), 0, "Right position");
|
113
|
+
equals(right.get('size'), 500, "Right size");
|
33
114
|
});
|
34
|
-
pane.append(); // make sure there is a layer...
|
35
|
-
SC.RunLoop.end();
|
36
115
|
|
37
|
-
splitView = pane.childViews[0];
|
38
|
-
},
|
39
116
|
|
40
|
-
|
41
|
-
pane
|
42
|
-
|
43
|
-
|
117
|
+
module(
|
118
|
+
"SplitView 4-pane " +
|
119
|
+
(layoutDirection === SC.HORIZONTAL_LAYOUT ? "Horizontal" : "Vertical") +
|
120
|
+
" - Methods",
|
121
|
+
{
|
122
|
+
setup: function () {
|
123
|
+
SC.RunLoop.begin();
|
124
|
+
// we test with no split divider because we want to easily calculate layout.
|
125
|
+
splitView = SC.SplitView.create({
|
126
|
+
childViews: [
|
127
|
+
SC.View.create(SC.SplitChild, { canCollapse: YES, collapseAtSize: 50, autoResizeStyle: SC.RESIZE_MANUAL }),
|
128
|
+
SC.View.create(SC.SplitChild, { autoResizeStyle: SC.RESIZE_AUTOMATIC }),
|
129
|
+
SC.View.create(SC.SplitChild, { autoResizeStyle: SC.RESIZE_AUTOMATIC }),
|
130
|
+
SC.View.create(SC.SplitChild, { autoResizeStyle: SC.FIXED_SIZE, canCollapse: YES, collapseAtSize: 50 })
|
131
|
+
],
|
132
|
+
|
133
|
+
layout: { left: 0, top: 0, width: 800, height: 800 },
|
134
|
+
|
135
|
+
layoutDirection: layoutDirection,
|
136
|
+
|
137
|
+
splitDividerView: null
|
138
|
+
});
|
139
|
+
|
140
|
+
SC.RunLoop.end();
|
141
|
+
|
142
|
+
left = splitView.childViews[0];
|
143
|
+
middleLeft = splitView.childViews[1];
|
144
|
+
middleRight = splitView.childViews[2];
|
145
|
+
right = splitView.childViews[3];
|
146
|
+
}
|
147
|
+
});
|
148
|
+
|
149
|
+
function confirmPositions() {
|
150
|
+
for (var i = 0; i < arguments.length; i++) {
|
151
|
+
equals(splitView.childViews[i].get('position'), arguments[i]);
|
152
|
+
}
|
44
153
|
}
|
45
|
-
|
46
|
-
|
47
|
-
//
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
{
|
88
|
-
|
154
|
+
|
155
|
+
test("Initial positions are correct", function () {
|
156
|
+
// the left and right sides do not resize unless forced to; as such, they
|
157
|
+
// stay at 100.
|
158
|
+
confirmPositions(0, 100, 400, 700);
|
159
|
+
});
|
160
|
+
|
161
|
+
test("Repositioning handles indirectness", function () {
|
162
|
+
var result;
|
163
|
+
|
164
|
+
// moving within available space works
|
165
|
+
result = splitView.adjustPositionForChild(middleLeft, 200);
|
166
|
+
equals(result, 200, "Moved to target position successfully.");
|
167
|
+
confirmPositions(0, 200, 400, 700);
|
168
|
+
|
169
|
+
// indirect being turned off for the next view, moving past min size
|
170
|
+
// for middleLeft should still work because it is an immediate sibling
|
171
|
+
result = splitView.adjustPositionForChild(middleLeft, 400);
|
172
|
+
equals(result, 400, "Moved to 400");
|
173
|
+
confirmPositions(0, 400, 500, 700);
|
174
|
+
|
175
|
+
// moving so far as to move the fourth view, however, should not work (it is fixed size)
|
176
|
+
result = splitView.adjustPositionForChild(middleLeft, 700);
|
177
|
+
equals(result, 500, "Limited to 500 due to minimum sizes and because last cannot move.");
|
178
|
+
confirmPositions(0, 500, 600, 700);
|
179
|
+
|
180
|
+
// changing last from fixed should not allow it through if indirect is not allowed
|
181
|
+
right.set('autoResizeStyle', SC.RESIZE_AUTOMATIC);
|
182
|
+
right.set('allowsIndirectAdjustments', NO);
|
183
|
+
|
184
|
+
result = splitView.adjustPositionForChild(middleLeft, 700);
|
185
|
+
equals(result, 500, "Limited to 500 due to minimum sizes and because last cannot move.");
|
186
|
+
confirmPositions(0, 500, 600, 700);
|
187
|
+
|
188
|
+
// but it should work if indirect _is_ allowed (rightmost should collapse)
|
189
|
+
right.set('allowsIndirectAdjustments', YES);
|
190
|
+
|
191
|
+
result = splitView.adjustPositionForChild(middleLeft, 700);
|
192
|
+
equals(result, 600, "Limited to 600 due to minimum sizes and because last collapses.");
|
193
|
+
confirmPositions(0, 600, 700, 800);
|
194
|
+
});
|
195
|
+
|
196
|
+
test("Repositioning without compensation", function () {
|
197
|
+
// first, disable all compensation
|
198
|
+
left.set('compensatesForMovement', NO);
|
199
|
+
middleLeft.set('compensatesForMovement', NO);
|
200
|
+
middleRight.set('compensatesForMovement', NO);
|
201
|
+
right.set('compensatesForMovement', NO);
|
202
|
+
|
203
|
+
var result;
|
204
|
+
|
205
|
+
// repositioning middle-left should fail because rightmost can't move.
|
206
|
+
result = splitView.adjustPositionForChild(middleLeft, 800);
|
207
|
+
equals(result, 100, "Failed to move to target because compensation is off.");
|
208
|
+
confirmPositions(0, 100, 400, 700);
|
209
|
+
|
210
|
+
// turning compensation on for second-to-right makes _it_ move to max
|
211
|
+
middleRight.set('compensatesForMovement', YES);
|
212
|
+
result = splitView.adjustPositionForChild(middleLeft, 800);
|
213
|
+
equals(result, 300, "Moved to min width of middleRight");
|
214
|
+
confirmPositions(0, 300, 600, 700);
|
215
|
+
});
|
216
|
+
|
217
|
+
test("Resizing split view", function () {
|
89
218
|
SC.RunLoop.begin();
|
90
|
-
// we test
|
91
|
-
splitView
|
92
|
-
|
93
|
-
|
94
|
-
SC.View.create(SC.SplitChild, { canCollapse: YES, collapseAtSize: 50 })
|
95
|
-
],
|
219
|
+
// note: we test both horizontal and vertical
|
220
|
+
splitView.adjust('width', 1600);
|
221
|
+
splitView.adjust('height', 1600);
|
222
|
+
SC.RunLoop.end();
|
96
223
|
|
97
|
-
|
224
|
+
// should have resized the auto resizable parts
|
225
|
+
confirmPositions(0, 100, 800, 1500);
|
98
226
|
|
99
|
-
|
227
|
+
// manually resize left part; we're going to test that, when it gets small enough,
|
228
|
+
// even the RESIZE_MANUAL will change sizes
|
229
|
+
splitView.adjustPositionForChild(middleLeft, 300);
|
100
230
|
|
101
|
-
|
102
|
-
|
231
|
+
// so now, just to be clear, the positions should be:
|
232
|
+
confirmPositions(0, 300, 800, 1500);
|
103
233
|
|
234
|
+
// so, if we now resize to _really really tiny_
|
235
|
+
SC.RunLoop.begin();
|
236
|
+
splitView.adjust('width', 400);
|
237
|
+
splitView.adjust('height', 400);
|
104
238
|
SC.RunLoop.end();
|
105
239
|
|
106
|
-
|
107
|
-
|
108
|
-
},
|
240
|
+
// we should see that even the RESIZE_MANUAL has resized.
|
241
|
+
confirmPositions(0, 100, 200, 300);
|
109
242
|
|
110
|
-
|
243
|
+
// and if we shrink further still...
|
244
|
+
SC.RunLoop.begin();
|
245
|
+
splitView.adjust('width', 300);
|
246
|
+
splitView.adjust('height', 300);
|
247
|
+
SC.RunLoop.end();
|
111
248
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
equals(splitView.childViews.length, 2, "SplitView has 2 children");
|
117
|
-
equals(splitView.getPositionForChild(left), 0, "Left should always be at 0");
|
118
|
-
equals(splitView.getPositionForChild(right), 250, "Right should be at 1/2: 50");
|
119
|
-
});
|
120
|
-
|
121
|
-
test("Can adjust position for a child", function() {
|
122
|
-
var result = splitView.adjustPositionForChild(right, 100);
|
123
|
-
equals(result, 100, "Result of adjustPositionForChild(right, 100)");
|
124
|
-
equals(left.get('position'), 0, "Left position (should always be 0)");
|
125
|
-
equals(left.get('size'), 100, "Left size");
|
126
|
-
equals(right.get('position'), 100, "Right position");
|
127
|
-
equals(right.get('size'), 400, "Right size");
|
128
|
-
});
|
129
|
-
|
130
|
-
|
131
|
-
test("SplitView - Methods: Minimum and Maximum widths and heights", function() {
|
132
|
-
// first, test with the built-in minimum size
|
133
|
-
var result = splitView.adjustPositionForChild(right, 80);
|
134
|
-
equals(result, 100, "Result of adjustPositionForChild(right, 80)");
|
135
|
-
equals(left.get('position'), 0, "Left position (should always be 0)");
|
136
|
-
equals(left.get('size'), 100, "Left size");
|
137
|
-
equals(right.get('position'), 100, "Right position");
|
138
|
-
equals(right.get('size'), 400, "Right size");
|
139
|
-
|
140
|
-
// now, add a max and test that
|
141
|
-
left.set('maximumSize', 150);
|
142
|
-
|
143
|
-
result = splitView.adjustPositionForChild(right, 180);
|
144
|
-
equals(result, 150, "Result of adjustPositionForChild(right, 180) when left's max size = 150");
|
145
|
-
equals(left.get('position'), 0, "Left position (should always be 0)");
|
146
|
-
equals(left.get('size'), 150, "Left size");
|
147
|
-
equals(right.get('position'), 150, "Right position");
|
148
|
-
equals(right.get('size'), 350, "Right size");
|
149
|
-
|
150
|
-
// and now go back to middle
|
151
|
-
result = splitView.adjustPositionForChild(right, 130);
|
152
|
-
equals(result, 130, "Result of adjustPositionForChild(right, 130) when left's max size = 150");
|
153
|
-
equals(left.get('position'), 0, "Left position (should always be 0)");
|
154
|
-
equals(left.get('size'), 130, "Left size");
|
155
|
-
equals(right.get('position'), 130, "Right position");
|
156
|
-
equals(right.get('size'), 370, "Right size");
|
157
|
-
});
|
158
|
-
|
159
|
-
test("SplitView - Methods: Collapsing a child", function() {
|
160
|
-
var result = splitView.adjustPositionForChild(right, 40);
|
161
|
-
|
162
|
-
// first was collapsed, so position of seconds is now at 0.
|
163
|
-
equals(result, 0, "Result of adjustPositionForChild(right, 40)");
|
164
|
-
equals(left.get('position'), 0, "Left position (should always be 0)");
|
165
|
-
equals(left.get('size'), 0, "Left size after collapsing");
|
166
|
-
equals(right.get('position'), 0, "Right position");
|
167
|
-
equals(right.get('size'), 500, "Right size");
|
168
|
-
});
|
169
|
-
|
170
|
-
|
171
|
-
module(
|
172
|
-
"SplitView 4-pane " +
|
173
|
-
(layoutDirection === SC.HORIZONTAL_LAYOUT ? "Horizontal" : "Vertical") +
|
174
|
-
" - Methods",
|
175
|
-
{
|
176
|
-
setup: function() {
|
249
|
+
// there should be change, because the left side collapses.
|
250
|
+
confirmPositions(0, 0, 100, 200);
|
251
|
+
|
252
|
+
// and if we shrink further still...
|
177
253
|
SC.RunLoop.begin();
|
178
|
-
|
179
|
-
splitView
|
180
|
-
|
181
|
-
SC.View.create(SC.SplitChild, { canCollapse: YES, collapseAtSize: 50, autoResizeStyle: SC.RESIZE_MANUAL }),
|
182
|
-
SC.View.create(SC.SplitChild, { autoResizeStyle: SC.RESIZE_AUTOMATIC }),
|
183
|
-
SC.View.create(SC.SplitChild, { autoResizeStyle: SC.RESIZE_AUTOMATIC }),
|
184
|
-
SC.View.create(SC.SplitChild, { autoResizeStyle: SC.FIXED_SIZE, canCollapse: YES, collapseAtSize: 50 })
|
185
|
-
],
|
254
|
+
splitView.adjust('width', 200);
|
255
|
+
splitView.adjust('height', 200);
|
256
|
+
SC.RunLoop.end();
|
186
257
|
|
187
|
-
|
258
|
+
// there should be no change
|
259
|
+
confirmPositions(0, 0, 100, 200);
|
188
260
|
|
189
|
-
|
261
|
+
// and if we shrink further still, way beyond the smallest it can get...
|
262
|
+
SC.RunLoop.begin();
|
263
|
+
splitView.adjust('width', 100);
|
264
|
+
splitView.adjust('height', 100);
|
265
|
+
SC.RunLoop.end();
|
266
|
+
|
267
|
+
// there should be no change
|
268
|
+
confirmPositions(0, 0, 100, 200);
|
269
|
+
});
|
190
270
|
|
191
|
-
|
192
|
-
|
271
|
+
test("Fitting to fill disabled", function () {
|
272
|
+
splitView.set('shouldResizeChildrenToFit', NO);
|
193
273
|
|
274
|
+
// so, first thing: Resize, and ensure things are where they started.
|
275
|
+
SC.RunLoop.begin();
|
276
|
+
// note: we test both horizontal and vertical
|
277
|
+
splitView.adjust('width', 1600);
|
278
|
+
splitView.adjust('height', 1600);
|
194
279
|
SC.RunLoop.end();
|
195
280
|
|
196
|
-
|
197
|
-
middleLeft = splitView.childViews[1];
|
198
|
-
middleRight = splitView.childViews[2];
|
199
|
-
right = splitView.childViews[3];
|
200
|
-
}
|
201
|
-
});
|
281
|
+
confirmPositions(0, 100, 400, 700);
|
202
282
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
}
|
207
|
-
}
|
283
|
+
// now, move one, and see that compensation, etc. still works properly
|
284
|
+
splitView.adjustPositionForChild(middleLeft, 500);
|
285
|
+
confirmPositions(0, 500, 600, 700);
|
208
286
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
confirmPositions(0, 500, 600, 700);
|
233
|
-
|
234
|
-
// changing last from fixed should not allow it through if indirect is not allowed
|
235
|
-
right.set('autoResizeStyle', SC.RESIZE_AUTOMATIC);
|
236
|
-
right.set('allowsIndirectAdjustments', NO);
|
237
|
-
|
238
|
-
result = splitView.adjustPositionForChild(middleLeft, 700);
|
239
|
-
equals(result, 500, "Limited to 500 due to minimum sizes and because last cannot move.");
|
240
|
-
confirmPositions(0, 500, 600, 700);
|
241
|
-
|
242
|
-
// but it should work if indirect _is_ allowed (rightmost should collapse)
|
243
|
-
right.set('allowsIndirectAdjustments', YES);
|
244
|
-
|
245
|
-
result = splitView.adjustPositionForChild(middleLeft, 700);
|
246
|
-
equals(result, 600, "Limited to 600 due to minimum sizes and because last collapses.");
|
247
|
-
confirmPositions(0, 600, 700, 800);
|
248
|
-
});
|
249
|
-
|
250
|
-
test("Repositioning without compensation", function() {
|
251
|
-
// first, disable all compensation
|
252
|
-
left.set('compensatesForMovement', NO);
|
253
|
-
middleLeft.set('compensatesForMovement', NO);
|
254
|
-
middleRight.set('compensatesForMovement', NO);
|
255
|
-
right.set('compensatesForMovement', NO);
|
256
|
-
|
257
|
-
var result;
|
258
|
-
|
259
|
-
// repositioning middle-left should fail because rightmost can't move.
|
260
|
-
result = splitView.adjustPositionForChild(middleLeft, 800);
|
261
|
-
equals(result, 100, "Failed to move to target because compensation is off.");
|
262
|
-
confirmPositions(0, 100, 400, 700);
|
263
|
-
|
264
|
-
// turning compensation on for second-to-right makes _it_ move to max
|
265
|
-
middleRight.set('compensatesForMovement', YES);
|
266
|
-
result = splitView.adjustPositionForChild(middleLeft, 800);
|
267
|
-
equals(result, 300, "Moved to min width of middleRight");
|
268
|
-
confirmPositions(0, 300, 600, 700);
|
269
|
-
});
|
270
|
-
|
271
|
-
test("Resizing split view", function() {
|
272
|
-
SC.RunLoop.begin();
|
273
|
-
// note: we test both horizontal and vertical
|
274
|
-
splitView.adjust('width', 1600);
|
275
|
-
splitView.adjust('height', 1600);
|
276
|
-
SC.RunLoop.end();
|
277
|
-
|
278
|
-
// should have resized the auto resizable parts
|
279
|
-
confirmPositions(0, 100, 800, 1500);
|
280
|
-
|
281
|
-
// manually resize left part; we're going to test that, when it gets small enough,
|
282
|
-
// even the RESIZE_MANUAL will change sizes
|
283
|
-
splitView.adjustPositionForChild(middleLeft, 300);
|
284
|
-
|
285
|
-
// so now, just to be clear, the positions should be:
|
286
|
-
confirmPositions(0, 300, 800, 1500);
|
287
|
-
|
288
|
-
// so, if we now resize to _really really tiny_
|
289
|
-
SC.RunLoop.begin();
|
290
|
-
splitView.adjust('width', 400);
|
291
|
-
splitView.adjust('height', 400);
|
292
|
-
SC.RunLoop.end();
|
293
|
-
|
294
|
-
// we should see that even the RESIZE_MANUAL has resized.
|
295
|
-
confirmPositions(0, 100, 200, 300);
|
296
|
-
|
297
|
-
// and if we shrink further still...
|
298
|
-
SC.RunLoop.begin();
|
299
|
-
splitView.adjust('width', 300);
|
300
|
-
splitView.adjust('height', 300);
|
301
|
-
SC.RunLoop.end();
|
302
|
-
|
303
|
-
// there should be change, because the left side collapses.
|
304
|
-
confirmPositions(0, 0, 100, 200);
|
305
|
-
|
306
|
-
// and if we shrink further still...
|
307
|
-
SC.RunLoop.begin();
|
308
|
-
splitView.adjust('width', 200);
|
309
|
-
splitView.adjust('height', 200);
|
310
|
-
SC.RunLoop.end();
|
311
|
-
|
312
|
-
// there should be no change
|
313
|
-
confirmPositions(0, 0, 100, 200);
|
314
|
-
|
315
|
-
// and if we shrink further still, way beyond the smallest it can get...
|
316
|
-
SC.RunLoop.begin();
|
317
|
-
splitView.adjust('width', 100);
|
318
|
-
splitView.adjust('height', 100);
|
319
|
-
SC.RunLoop.end();
|
320
|
-
|
321
|
-
// there should be no change
|
322
|
-
confirmPositions(0, 0, 100, 200);
|
323
|
-
});
|
324
|
-
|
325
|
-
test("Fitting to fill disabled", function() {
|
326
|
-
splitView.set('shouldResizeChildrenToFit', NO);
|
327
|
-
|
328
|
-
// so, first thing: Resize, and ensure things are where they started.
|
329
|
-
SC.RunLoop.begin();
|
330
|
-
// note: we test both horizontal and vertical
|
331
|
-
splitView.adjust('width', 1600);
|
332
|
-
splitView.adjust('height', 1600);
|
333
|
-
SC.RunLoop.end();
|
334
|
-
|
335
|
-
confirmPositions(0, 100, 400, 700);
|
336
|
-
|
337
|
-
// now, move one, and see that compensation, etc. still works properly
|
338
|
-
splitView.adjustPositionForChild(middleLeft, 500);
|
339
|
-
confirmPositions(0, 500, 600, 700);
|
340
|
-
|
341
|
-
// move back, and make sure compensation still took effect
|
342
|
-
splitView.adjustPositionForChild(middleLeft, 100);
|
343
|
-
confirmPositions(0, 100, 600, 700);
|
344
|
-
|
345
|
-
// disable compensation and move again
|
346
|
-
middleLeft.set('compensatesForMovement', NO);
|
347
|
-
middleRight.set('compensatesForMovement', NO);
|
348
|
-
right.set('compensatesForMovement', NO);
|
349
|
-
|
350
|
-
splitView.adjustPositionForChild(middleLeft, 500);
|
351
|
-
confirmPositions(0, 500, 1000, 1100);
|
352
|
-
|
353
|
-
// disable indirect for last item and check that movement cannot occur
|
354
|
-
right.set('allowsIndirectAdjustments', NO);
|
355
|
-
|
356
|
-
var result = splitView.adjustPositionForChild(middleLeft, 700);
|
357
|
-
equals(result, 500, "Should not be able to move (last does not allow indirect adjustments)");
|
358
|
-
confirmPositions(0, 500, 1000, 1100);
|
359
|
-
|
360
|
-
result = splitView.adjustPositionForChild(middleLeft, 200);
|
361
|
-
equals(result, 500, "Should not be able to move (last does not allow indirect adjustments)");
|
362
|
-
confirmPositions(0, 500, 1000, 1100);
|
363
|
-
});
|
287
|
+
// move back, and make sure compensation still took effect
|
288
|
+
splitView.adjustPositionForChild(middleLeft, 100);
|
289
|
+
confirmPositions(0, 100, 600, 700);
|
290
|
+
|
291
|
+
// disable compensation and move again
|
292
|
+
middleLeft.set('compensatesForMovement', NO);
|
293
|
+
middleRight.set('compensatesForMovement', NO);
|
294
|
+
right.set('compensatesForMovement', NO);
|
295
|
+
|
296
|
+
splitView.adjustPositionForChild(middleLeft, 500);
|
297
|
+
confirmPositions(0, 500, 1000, 1100);
|
298
|
+
|
299
|
+
// disable indirect for last item and check that movement cannot occur
|
300
|
+
right.set('allowsIndirectAdjustments', NO);
|
301
|
+
|
302
|
+
var result = splitView.adjustPositionForChild(middleLeft, 700);
|
303
|
+
equals(result, 500, "Should not be able to move (last does not allow indirect adjustments)");
|
304
|
+
confirmPositions(0, 500, 1000, 1100);
|
305
|
+
|
306
|
+
result = splitView.adjustPositionForChild(middleLeft, 200);
|
307
|
+
equals(result, 500, "Should not be able to move (last does not allow indirect adjustments)");
|
308
|
+
confirmPositions(0, 500, 1000, 1100);
|
309
|
+
});
|
364
310
|
|
365
311
|
}
|
366
312
|
|