sproutcore 1.11.0.rc3 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +6 -14
  2. data/CHANGELOG +5 -0
  3. data/VERSION.yml +1 -1
  4. data/lib/frameworks/sproutcore/Buildfile +3 -2
  5. data/lib/frameworks/sproutcore/CHANGELOG.md +59 -10
  6. data/lib/frameworks/sproutcore/apps/showcase/resources/main_page.js +1 -0
  7. data/lib/frameworks/sproutcore/apps/showcase/resources/stylesheet.css +9 -4
  8. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/manipulation.js +1 -1
  9. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +0 -10
  10. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +1 -1
  11. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +10 -45
  12. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/selection_set.js +3 -3
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/touch.js +76 -0
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/{touch.js → touch_test.js} +64 -0
  15. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +1 -1
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/design_mode_test.js +61 -24
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/createChildViews.js +1 -2
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/destroy.js +0 -3
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/{layoutStyle.js → layout_style_test.js} +4 -4
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout_test.js +602 -0
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/viewDidResize.js +0 -23
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +18 -17
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +5 -5
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/design_mode.js +64 -24
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +904 -871
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +1 -3
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +40 -24
  28. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +2 -2
  29. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +5 -5
  30. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +14 -14
  31. data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +1 -1
  32. data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +2 -2
  33. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +36 -33
  34. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +1 -1
  35. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/autonomous_dataSourceCallbacks.js +6 -6
  36. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +1 -1
  37. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitRecord.js +1 -1
  38. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +7 -7
  39. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/destroyRecord.js +2 -2
  40. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/recordDidChange.js +2 -2
  41. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/retrieveRecord.js +4 -4
  42. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +11 -11
  43. data/lib/frameworks/sproutcore/frameworks/designer/coders/object.js +1 -1
  44. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +30 -1
  45. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +12 -1
  46. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +5 -3
  47. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroller_view.js +0 -36
  48. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +3 -3
  49. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +1 -1
  50. data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +1 -1
  51. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/pinch_gesture.js +286 -0
  52. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/swipe_gesture.js +449 -0
  53. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap_gesture.js +259 -0
  54. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/gesturable.js +218 -30
  55. data/lib/frameworks/sproutcore/frameworks/foundation/system/gesture.js +259 -158
  56. data/lib/frameworks/sproutcore/frameworks/foundation/system/string.js +58 -50
  57. data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +1 -1
  58. data/lib/frameworks/sproutcore/frameworks/foundation/tests/gestures/pinch_gesture_test.js +321 -0
  59. data/lib/frameworks/sproutcore/frameworks/foundation/tests/gestures/swipe_gesture_test.js +154 -0
  60. data/lib/frameworks/sproutcore/frameworks/foundation/tests/gestures/tap_gesture_test.js +55 -0
  61. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/gesturable_test.js +233 -0
  62. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/staticLayout.js +2 -2
  63. data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/gesture_test.js +254 -0
  64. data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +1 -0
  65. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +1 -1
  66. data/lib/frameworks/sproutcore/frameworks/legacy/object_keys_polyfill.js +51 -0
  67. data/lib/frameworks/sproutcore/frameworks/{core_foundation/system/req_anim_frame.js → legacy/request_animation_frame_polyfill.js} +10 -3
  68. data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +19 -25
  69. data/lib/frameworks/sproutcore/frameworks/media/views/controls.js +7 -7
  70. data/lib/frameworks/sproutcore/frameworks/media/views/mini_controls.js +3 -3
  71. data/lib/frameworks/sproutcore/frameworks/media/views/simple_controls.js +9 -9
  72. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
  73. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/insertAt.js +2 -2
  74. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/removeAt.js +1 -1
  75. data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +1 -1
  76. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +2 -2
  77. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/freezable.js +2 -2
  78. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +66 -5
  79. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/tree.js +44 -0
  80. data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_queue.js +4 -1
  81. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +0 -25
  82. data/lib/frameworks/sproutcore/frameworks/runtime/system/enumerator.js +1 -1
  83. data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +67 -15
  84. data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +6 -11
  85. data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +6 -6
  86. data/lib/frameworks/sproutcore/frameworks/runtime/system/string.js +1 -1
  87. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/{observable.js → observable_test.js} +110 -16
  88. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/error.js +21 -0
  89. data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +2 -2
  90. data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars.js +1 -1
  91. data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +1 -1
  92. data/lib/sproutcore/render_engines/haml.rb +1 -1
  93. metadata +610 -604
  94. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +0 -210
  95. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +0 -275
  96. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/pinch.js +0 -119
  97. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/swipe.js +0 -234
  98. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap.js +0 -157
@@ -232,34 +232,38 @@ SC.mixin(SC.String, {
232
232
  @returns {String} the plural form of the string
233
233
  */
234
234
  pluralize: function(str) {
235
- var idx, len,
236
- compare = str.split(/\s/).pop(), //check only the last word of a string
237
- restOfString = str.replace(compare,''),
238
- isCapitalized = compare.charAt(0).match(/[A-Z]/) ? true : false,
239
- inflectionConstants = SC.Locale.currentLocale.inflectionConstants;
240
-
241
- compare = compare.toLowerCase();
242
- for (idx=0, len=inflectionConstants.UNCOUNTABLE.length; idx < len; idx++) {
243
- var uncountable = inflectionConstants.UNCOUNTABLE[idx];
244
- if (compare == uncountable) {
245
- return str.toString();
246
- }
235
+ var inflectionConstants = SC.Locale.currentLocale.inflectionConstants;
236
+
237
+ // Fast path if there is no inflection constants for a locale
238
+ if (!inflectionConstants) return str.toString();
239
+
240
+ var idx, len,
241
+ compare = str.split(/\s/).pop(), //check only the last word of a string
242
+ restOfString = str.replace(compare,''),
243
+ isCapitalized = compare.charAt(0).match(/[A-Z]/) ? true : false;
244
+
245
+ compare = compare.toLowerCase();
246
+ for (idx=0, len=inflectionConstants.UNCOUNTABLE.length; idx < len; idx++) {
247
+ var uncountable = inflectionConstants.UNCOUNTABLE[idx];
248
+ if (compare == uncountable) {
249
+ return str.toString();
247
250
  }
248
- for (idx=0, len=inflectionConstants.IRREGULAR.length; idx < len; idx++) {
249
- var singular = inflectionConstants.IRREGULAR[idx][0],
250
- plural = inflectionConstants.IRREGULAR[idx][1];
251
- if ((compare == singular) || (compare == plural)) {
252
- if(isCapitalized) plural = plural.capitalize();
253
- return restOfString + plural;
254
- }
251
+ }
252
+ for (idx=0, len=inflectionConstants.IRREGULAR.length; idx < len; idx++) {
253
+ var singular = inflectionConstants.IRREGULAR[idx][0],
254
+ plural = inflectionConstants.IRREGULAR[idx][1];
255
+ if ((compare == singular) || (compare == plural)) {
256
+ if(isCapitalized) plural = plural.capitalize();
257
+ return restOfString + plural;
255
258
  }
256
- for (idx=0, len=inflectionConstants.PLURAL.length; idx < len; idx++) {
257
- var regex = inflectionConstants.PLURAL[idx][0],
258
- replace_string = inflectionConstants.PLURAL[idx][1];
259
- if (regex.test(compare)) {
260
- return str.replace(regex, replace_string);
261
- }
259
+ }
260
+ for (idx=0, len=inflectionConstants.PLURAL.length; idx < len; idx++) {
261
+ var regex = inflectionConstants.PLURAL[idx][0],
262
+ replace_string = inflectionConstants.PLURAL[idx][1];
263
+ if (regex.test(compare)) {
264
+ return str.replace(regex, replace_string);
262
265
  }
266
+ }
263
267
  },
264
268
 
265
269
  /**
@@ -269,34 +273,38 @@ SC.mixin(SC.String, {
269
273
  @returns {String} the singular form of the string
270
274
  */
271
275
  singularize: function(str) {
272
- var idx, len,
273
- compare = str.split(/\s/).pop(), //check only the last word of a string
274
- restOfString = str.replace(compare,''),
275
- isCapitalized = compare.charAt(0).match(/[A-Z]/) ? true : false,
276
- inflectionConstants = SC.Locale.currentLocale.inflectionConstants;
277
-
278
- compare = compare.toLowerCase();
279
- for (idx=0, len=inflectionConstants.UNCOUNTABLE.length; idx < len; idx++) {
280
- var uncountable = inflectionConstants.UNCOUNTABLE[idx];
281
- if (compare == uncountable) {
282
- return str.toString();
283
- }
276
+ var inflectionConstants = SC.Locale.currentLocale.inflectionConstants;
277
+
278
+ // Fast path if there is no inflection constants for a locale
279
+ if (!inflectionConstants) return str.toString();
280
+
281
+ var idx, len,
282
+ compare = str.split(/\s/).pop(), //check only the last word of a string
283
+ restOfString = str.replace(compare,''),
284
+ isCapitalized = compare.charAt(0).match(/[A-Z]/) ? true : false;
285
+
286
+ compare = compare.toLowerCase();
287
+ for (idx=0, len=inflectionConstants.UNCOUNTABLE.length; idx < len; idx++) {
288
+ var uncountable = inflectionConstants.UNCOUNTABLE[idx];
289
+ if (compare == uncountable) {
290
+ return str.toString();
284
291
  }
285
- for (idx=0, len=inflectionConstants.IRREGULAR.length; idx < len; idx++) {
286
- var singular = inflectionConstants.IRREGULAR[idx][0],
287
- plural = inflectionConstants.IRREGULAR[idx][1];
288
- if ((compare == singular) || (compare == plural)) {
289
- if(isCapitalized) singular = singular.capitalize();
290
- return restOfString + singular;
291
- }
292
+ }
293
+ for (idx=0, len=inflectionConstants.IRREGULAR.length; idx < len; idx++) {
294
+ var singular = inflectionConstants.IRREGULAR[idx][0],
295
+ plural = inflectionConstants.IRREGULAR[idx][1];
296
+ if ((compare == singular) || (compare == plural)) {
297
+ if(isCapitalized) singular = singular.capitalize();
298
+ return restOfString + singular;
292
299
  }
293
- for (idx=0, len=inflectionConstants.SINGULAR.length; idx < len; idx++) {
294
- var regex = inflectionConstants.SINGULAR[idx][0],
295
- replace_string = inflectionConstants.SINGULAR[idx][1];
296
- if (regex.test(compare)) {
297
- return str.replace(regex, replace_string);
298
- }
300
+ }
301
+ for (idx=0, len=inflectionConstants.SINGULAR.length; idx < len; idx++) {
302
+ var regex = inflectionConstants.SINGULAR[idx][0],
303
+ replace_string = inflectionConstants.SINGULAR[idx][1];
304
+ if (regex.test(compare)) {
305
+ return str.replace(regex, replace_string);
299
306
  }
307
+ }
300
308
  }
301
309
 
302
310
  });
@@ -114,7 +114,7 @@ SC.mixin( /** @scope SC */ {
114
114
  @param classNames {String} (Optional) Class names to add to the test element.
115
115
  */
116
116
  prepareStringMeasurement: function(exampleElement, classNames) {
117
- var element = this._metricsCalculationElement, classes, styles, style,
117
+ var element = this._metricsCalculationElement, classes, style,
118
118
  cqElem;
119
119
 
120
120
  // collect the class names
@@ -0,0 +1,321 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore
3
+ // License: Licensed under MIT license
4
+ // ==========================================================================
5
+ /*globals CoreTest, module, test, ok, equals, same, expect, start, stop */
6
+
7
+ var gesture;
8
+ module("SC.PinchGesture", {
9
+
10
+ setup: function () {
11
+ gesture = SC.PinchGesture;
12
+ },
13
+
14
+ teardown: function () {
15
+ if (gesture.destroy) { gesture.destroy(); }
16
+ gesture = null;
17
+ }
18
+ });
19
+
20
+ /* Properties */
21
+
22
+ test("Default Properties:", function () {
23
+ gesture = gesture.create();
24
+ equals(gesture.name, 'pinch', "The default value of name is");
25
+ });
26
+
27
+ /* Methods */
28
+
29
+ // This method registers _sc_pinchAnchorScale to the value of the view's scale.
30
+ test("Method: touchSessionStarted", function () {
31
+ gesture = gesture.create({
32
+ view: SC.View.create({ layout: { scale: 1.5 } })
33
+ });
34
+ equals(gesture.touchSessionStarted(), undefined, "The method returns");
35
+
36
+ equals(gesture._sc_pinchAnchorScale, 1.5, "The value of _sc_pinchAnchorScale has been set to");
37
+ });
38
+
39
+ // This method registers _sc_pinchAnchorD as the average distance between all touches.
40
+ test("Method: touchAddedToSession", function () {
41
+ var view = SC.View.create({ });
42
+
43
+ gesture = gesture.create({
44
+ view: view
45
+ });
46
+
47
+ var testTouch1 = SC.Touch.create({
48
+ identifier: 'test-touch-1',
49
+ pageX: 0,
50
+ pageY: 0
51
+ }, SC.RootResponder.responder),
52
+
53
+ testTouch2 = SC.Touch.create({
54
+ identifier: 'test-touch-2',
55
+ pageX: 100,
56
+ pageY: 100
57
+ }, SC.RootResponder.responder),
58
+
59
+ testTouch3 = SC.Touch.create({
60
+ identifier: 'test-touch-3',
61
+ pageX: 200,
62
+ pageY: 200
63
+ }, SC.RootResponder.responder);
64
+
65
+ // Set up root responder nonsense.
66
+ SC.RootResponder.responder._touchedViews[SC.guidFor(view)] = {
67
+ touches: SC.CoreSet.create([testTouch1])
68
+ };
69
+
70
+ equals(gesture.touchAddedToSession(testTouch2, [testTouch1]), true, "The method returns");
71
+ equals(gesture._sc_pinchAnchorD.toFixed(1), '70.7', "The variable _sc_pinchAnchorD is");
72
+
73
+ gesture.touchAddedToSession(testTouch3, [testTouch2, testTouch1]);
74
+ equals(gesture._sc_pinchAnchorD.toFixed(1), '141.4', "The variable _sc_pinchAnchorD is now");
75
+ });
76
+
77
+ // This method updates the anchors to the new fewer number of touches. If only one touch remains it nulls out the anchors.
78
+ test("Method: touchCancelledInSession", function () {
79
+ var view = SC.View.create({});
80
+
81
+ gesture = gesture.create({
82
+ view: view
83
+ });
84
+
85
+ var testTouch1 = SC.Touch.create({
86
+ identifier: 'test-touch-1',
87
+ pageX: 0,
88
+ pageY: 0
89
+ }, SC.RootResponder.responder),
90
+
91
+ testTouch2 = SC.Touch.create({
92
+ identifier: 'test-touch-2',
93
+ pageX: 100,
94
+ pageY: 100
95
+ }, SC.RootResponder.responder),
96
+
97
+ testTouch3 = SC.Touch.create({
98
+ identifier: 'test-touch-3',
99
+ pageX: 200,
100
+ pageY: 200
101
+ }, SC.RootResponder.responder);
102
+
103
+ // Set up root responder nonsense.
104
+ SC.RootResponder.responder._touchedViews[SC.guidFor(view)] = {
105
+ touches: SC.CoreSet.create([testTouch1, testTouch2])
106
+ };
107
+
108
+ equals(gesture.touchCancelledInSession(testTouch3, [testTouch1, testTouch2]), true, "The method returns");
109
+ equals(gesture._sc_pinchAnchorD.toFixed(1), '70.7', "The variable _sc_pinchAnchorD is now");
110
+
111
+ // Also check that an active pinch is killed. Fake out an active pinch.
112
+ gesture._sc_isPinching = true;
113
+ gesture._sc_pinchingTimer = SC.Timer.schedule({
114
+ interval: 100
115
+ });
116
+
117
+ gesture.touchCancelledInSession(testTouch2, [testTouch1]);
118
+ equals(gesture._sc_pinchAnchorD, null, "The variable _sc_pinchAnchorD is finally");
119
+ equals(gesture._sc_isPinching, false, "The variable _sc_isPinching is now");
120
+
121
+ gesture.touchCancelledInSession(testTouch1, []);
122
+ equals(gesture._sc_pinchAnchorD, null, "The variable _sc_pinchAnchorD is still");
123
+ });
124
+
125
+ // This method updates the anchors to the new fewer number of touches. If only one touch remains it nulls out the anchors and cancels any active pinch.
126
+ test("Method: touchEndedInSession", function () {
127
+ var view = SC.View.create(SC.Gesturable, {
128
+ gestures: [SC.PinchGesture],
129
+
130
+ pinchEnd: function () {
131
+ ok(true, 'called', 'called', "The pinchEnd method was");
132
+ }
133
+ });
134
+
135
+ gesture = gesture.create({
136
+ view: view
137
+ });
138
+
139
+ var testTouch1 = SC.Touch.create({
140
+ identifier: 'test-touch-1',
141
+ pageX: 0,
142
+ pageY: 0
143
+ }, SC.RootResponder.responder),
144
+
145
+ testTouch2 = SC.Touch.create({
146
+ identifier: 'test-touch-2',
147
+ pageX: 100,
148
+ pageY: 100
149
+ }, SC.RootResponder.responder),
150
+
151
+ testTouch3 = SC.Touch.create({
152
+ identifier: 'test-touch-3',
153
+ pageX: 200,
154
+ pageY: 200
155
+ }, SC.RootResponder.responder);
156
+
157
+ // Set up root responder nonsense.
158
+ SC.RootResponder.responder._touchedViews[SC.guidFor(view)] = {
159
+ touches: SC.CoreSet.create([testTouch1, testTouch2])
160
+ };
161
+
162
+ equals(gesture.touchEndedInSession(testTouch3, [testTouch1, testTouch2]), true, "The method returns");
163
+ equals(gesture._sc_pinchAnchorD.toFixed(1), '70.7', "The variable _sc_pinchAnchorD is now");
164
+
165
+ // Also check that an active pinch is killed. Fake out an active pinch.
166
+ gesture._sc_isPinching = true;
167
+ gesture._sc_pinchingTimer = SC.Timer.schedule({
168
+ interval: 100
169
+ });
170
+
171
+ gesture.touchEndedInSession(testTouch2, [testTouch1]);
172
+ equals(gesture._sc_pinchAnchorD, null, "The variable _sc_pinchAnchorD is finally");
173
+ equals(gesture._sc_isPinching, false, "The variable _sc_isPinching is now");
174
+
175
+ gesture.touchCancelledInSession(testTouch1, []);
176
+ equals(gesture._sc_pinchAnchorD, null, "The variable _sc_pinchAnchorD is still");
177
+ });
178
+
179
+ // This method calls `pinchStart` once as long as still moving. It also calls `pinch` with the scale each time the average touch distance changes. Once enough time has passed, calls `pinchEnd` (via timer).
180
+ test("Method: touchesMovedInSession", function () {
181
+ var lastScale = 1,
182
+ view = SC.View.create(SC.Gesturable, {
183
+ gestures: [SC.PinchGesture],
184
+
185
+ pinchStart: function () {
186
+ ok(true, 'called', 'called', "The pinchStart method was");
187
+ },
188
+
189
+ pinch: function (scale) {
190
+ ok(true, 'called', 'called', "The pinch method was");
191
+ ok(scale < lastScale, 'changed', 'changed', "The scale (%@) has".fmt(scale));
192
+ lastScale = scale;
193
+ },
194
+
195
+ pinchEnd: function () {
196
+ ok(true, 'called', 'called', "The pinchEnd method was");
197
+ }
198
+ });
199
+
200
+ gesture = gesture.create({
201
+ view: view
202
+ });
203
+
204
+ var testTouch1 = SC.Touch.create({
205
+ identifier: 'test-touch-1',
206
+ pageX: 0,
207
+ pageY: 0
208
+ }, SC.RootResponder.responder),
209
+
210
+ testTouch2 = SC.Touch.create({
211
+ identifier: 'test-touch-2',
212
+ pageX: 100,
213
+ pageY: 100
214
+ }, SC.RootResponder.responder);
215
+
216
+ // Set up root responder nonsense.
217
+ SC.RootResponder.responder._touchedViews[SC.guidFor(view)] = {
218
+ touches: SC.CoreSet.create([testTouch1, testTouch2])
219
+ };
220
+
221
+ // Set up the initial touch distance and view scale.
222
+ gesture._sc_pinchAnchorD = 70.7;
223
+ gesture._sc_pinchAnchorScale = 1;
224
+
225
+ // Move a touch.
226
+ testTouch2.pageX = 99;
227
+ testTouch2.pageY = 99;
228
+
229
+ equals(gesture.touchesMovedInSession([testTouch1, testTouch2]), true, "The method returns");
230
+
231
+ // Should include the pinchStart ok().
232
+ expect(4);
233
+
234
+ // Move a touch.
235
+ testTouch2.pageX = 98;
236
+ testTouch2.pageY = 98;
237
+ gesture.touchesMovedInSession([testTouch1, testTouch2]);
238
+
239
+ // Should only include the pinch ok's.
240
+ expect(6);
241
+
242
+ setTimeout(function () {
243
+ expect(7);
244
+ start();
245
+ }, gesture.get('pinchDelay') + 200);
246
+
247
+ // Don't continue to the next test.
248
+ stop();
249
+ });
250
+
251
+ // This method clears out all variables and cancels an active pinch.
252
+ test("Method: touchSessionCancelled", function () {
253
+ var view = SC.View.create({});
254
+
255
+ gesture = gesture.create({
256
+ view: view
257
+ });
258
+
259
+ var testTouch1 = SC.Touch.create({
260
+ identifier: 'test-touch-1',
261
+ pageX: 0,
262
+ pageY: 0
263
+ }, SC.RootResponder.responder),
264
+
265
+ testTouch2 = SC.Touch.create({
266
+ identifier: 'test-touch-2',
267
+ pageX: 100,
268
+ pageY: 100
269
+ }, SC.RootResponder.responder);
270
+
271
+ // Set up root responder nonsense.
272
+ SC.RootResponder.responder._touchedViews[SC.guidFor(view)] = {
273
+ touches: SC.CoreSet.create([testTouch1, testTouch2])
274
+ };
275
+
276
+ // Also check that an active pinch is killed. Fake out an active pinch.
277
+ gesture._sc_isPinching = true;
278
+ gesture._sc_pinchingTimer = SC.Timer.schedule({
279
+ interval: 100
280
+ });
281
+
282
+ equals(gesture.touchSessionCancelled(), undefined, "The method returns");
283
+ equals(gesture._sc_pinchAnchorD, null, "The variable _sc_pinchAnchorD is now");
284
+ equals(gesture._sc_isPinching, false, "The variable _sc_isPinching is now");
285
+ });
286
+
287
+ // This method clears out all variables and cancels an active pinch.
288
+ test("Method: touchSessionEnded", function () {
289
+ var view = SC.View.create({});
290
+
291
+ gesture = gesture.create({
292
+ view: view
293
+ });
294
+
295
+ var testTouch1 = SC.Touch.create({
296
+ identifier: 'test-touch-1',
297
+ pageX: 0,
298
+ pageY: 0
299
+ }, SC.RootResponder.responder),
300
+
301
+ testTouch2 = SC.Touch.create({
302
+ identifier: 'test-touch-2',
303
+ pageX: 100,
304
+ pageY: 100
305
+ }, SC.RootResponder.responder);
306
+
307
+ // Set up root responder nonsense.
308
+ SC.RootResponder.responder._touchedViews[SC.guidFor(view)] = {
309
+ touches: SC.CoreSet.create([testTouch1, testTouch2])
310
+ };
311
+
312
+ // Also check that an active pinch is killed. Fake out an active pinch.
313
+ gesture._sc_isPinching = true;
314
+ gesture._sc_pinchingTimer = SC.Timer.schedule({
315
+ interval: 100
316
+ });
317
+
318
+ equals(gesture.touchSessionCancelled(), undefined, "The method returns");
319
+ equals(gesture._sc_pinchAnchorD, null, "The variable _sc_pinchAnchorD is now");
320
+ equals(gesture._sc_isPinching, false, "The variable _sc_isPinching is now");
321
+ });