sproutcore 1.11.0.rc3 → 1.11.0
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 +6 -14
- data/CHANGELOG +5 -0
- data/VERSION.yml +1 -1
- data/lib/frameworks/sproutcore/Buildfile +3 -2
- data/lib/frameworks/sproutcore/CHANGELOG.md +59 -10
- data/lib/frameworks/sproutcore/apps/showcase/resources/main_page.js +1 -0
- data/lib/frameworks/sproutcore/apps/showcase/resources/stylesheet.css +9 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/manipulation.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +0 -10
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +10 -45
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/selection_set.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/system/touch.js +76 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/{touch.js → touch_test.js} +64 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/design_mode_test.js +61 -24
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/createChildViews.js +1 -2
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/destroy.js +0 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/{layoutStyle.js → layout_style_test.js} +4 -4
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout_test.js +602 -0
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/viewDidResize.js +0 -23
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +18 -17
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/design_mode.js +64 -24
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +904 -871
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +1 -3
- data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +40 -24
- data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +5 -5
- data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +14 -14
- data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +36 -33
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/autonomous_dataSourceCallbacks.js +6 -6
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitChangesFromNestedStore.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitRecord.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/destroyRecord.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/recordDidChange.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/retrieveRecord.js +4 -4
- data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +11 -11
- data/lib/frameworks/sproutcore/frameworks/designer/coders/object.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +30 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +12 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +5 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroller_view.js +0 -36
- data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/pinch_gesture.js +286 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/swipe_gesture.js +449 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap_gesture.js +259 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/mixins/gesturable.js +218 -30
- data/lib/frameworks/sproutcore/frameworks/foundation/system/gesture.js +259 -158
- data/lib/frameworks/sproutcore/frameworks/foundation/system/string.js +58 -50
- data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/string_measurement.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/gestures/pinch_gesture_test.js +321 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/gestures/swipe_gesture_test.js +154 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/gestures/tap_gesture_test.js +55 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/gesturable_test.js +233 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/staticLayout.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/foundation/tests/system/gesture_test.js +254 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +1 -0
- data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/legacy/object_keys_polyfill.js +51 -0
- data/lib/frameworks/sproutcore/frameworks/{core_foundation/system/req_anim_frame.js → legacy/request_animation_frame_polyfill.js} +10 -3
- data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +19 -25
- data/lib/frameworks/sproutcore/frameworks/media/views/controls.js +7 -7
- data/lib/frameworks/sproutcore/frameworks/media/views/mini_controls.js +3 -3
- data/lib/frameworks/sproutcore/frameworks/media/views/simple_controls.js +9 -9
- data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/insertAt.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/removeAt.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/ext/array.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/freezable.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +66 -5
- data/lib/frameworks/sproutcore/frameworks/runtime/mixins/tree.js +44 -0
- data/lib/frameworks/sproutcore/frameworks/runtime/private/observer_queue.js +4 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +0 -25
- data/lib/frameworks/sproutcore/frameworks/runtime/system/enumerator.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/system/error.js +67 -15
- data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +6 -11
- data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +6 -6
- data/lib/frameworks/sproutcore/frameworks/runtime/system/string.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/{observable.js → observable_test.js} +110 -16
- data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/error.js +21 -0
- data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +2 -2
- data/lib/frameworks/sproutcore/frameworks/template_view/ext/handlebars.js +1 -1
- data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +1 -1
- data/lib/sproutcore/render_engines/haml.rb +1 -1
- metadata +610 -604
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +0 -210
- data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +0 -275
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/pinch.js +0 -119
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/swipe.js +0 -234
- data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap.js +0 -157
@@ -0,0 +1,154 @@
|
|
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.SwipeGesture", {
|
9
|
+
|
10
|
+
setup: function () {
|
11
|
+
gesture = SC.SwipeGesture;
|
12
|
+
},
|
13
|
+
|
14
|
+
teardown: function () {
|
15
|
+
if (gesture.destroy) { gesture.destroy(); }
|
16
|
+
gesture = null;
|
17
|
+
}
|
18
|
+
});
|
19
|
+
|
20
|
+
/* Properties */
|
21
|
+
test("Default Properties:", function () {
|
22
|
+
gesture = gesture.create();
|
23
|
+
equals(gesture.name, 'swipe', "The default value of name is");
|
24
|
+
});
|
25
|
+
|
26
|
+
/* Methods */
|
27
|
+
// This method tests the given angle against an approved angle within tolerance.
|
28
|
+
test("Method: _sc_testAngle", function () {
|
29
|
+
gesture = gesture.create({});
|
30
|
+
|
31
|
+
var testAngle,
|
32
|
+
targetAngle;
|
33
|
+
|
34
|
+
// Test the target angle 0°.
|
35
|
+
targetAngle = 0;
|
36
|
+
testAngle = 6;
|
37
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is outside of the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
38
|
+
|
39
|
+
testAngle = 5;
|
40
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
41
|
+
|
42
|
+
testAngle = 4;
|
43
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is within the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
44
|
+
|
45
|
+
testAngle = 0;
|
46
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the target angle for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
47
|
+
|
48
|
+
testAngle = -4;
|
49
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is within the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
50
|
+
|
51
|
+
testAngle = -5;
|
52
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
53
|
+
|
54
|
+
testAngle = -6;
|
55
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is outside of the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
56
|
+
|
57
|
+
// Test the target angle 180°.
|
58
|
+
targetAngle = 180;
|
59
|
+
testAngle = -174;
|
60
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is outside of the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
61
|
+
|
62
|
+
testAngle = -175;
|
63
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
64
|
+
|
65
|
+
testAngle = -176;
|
66
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is within the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
67
|
+
|
68
|
+
testAngle = 180;
|
69
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the target angle for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
70
|
+
|
71
|
+
testAngle = 176;
|
72
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is within the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
73
|
+
|
74
|
+
testAngle = 175;
|
75
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
76
|
+
|
77
|
+
testAngle = 174;
|
78
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is outside of the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
79
|
+
|
80
|
+
// Test the target angle -180°.
|
81
|
+
targetAngle = -180;
|
82
|
+
testAngle = -174;
|
83
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is outside of the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
84
|
+
|
85
|
+
testAngle = -175;
|
86
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
87
|
+
|
88
|
+
testAngle = -176;
|
89
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is within the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
90
|
+
|
91
|
+
testAngle = 180;
|
92
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the target angle for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
93
|
+
|
94
|
+
testAngle = 176;
|
95
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is within the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
96
|
+
|
97
|
+
testAngle = 175;
|
98
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
99
|
+
|
100
|
+
testAngle = 174;
|
101
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is outside of the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
102
|
+
|
103
|
+
// Test the target angle 90°.
|
104
|
+
targetAngle = 90;
|
105
|
+
testAngle = 96;
|
106
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is outside of the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
107
|
+
|
108
|
+
testAngle = 95;
|
109
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
110
|
+
|
111
|
+
testAngle = 94;
|
112
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is within the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
113
|
+
|
114
|
+
testAngle = 90;
|
115
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the target angle for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
116
|
+
|
117
|
+
testAngle = 86;
|
118
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is within the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
119
|
+
|
120
|
+
testAngle = 85;
|
121
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
122
|
+
|
123
|
+
testAngle = 84;
|
124
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is outside of the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
125
|
+
|
126
|
+
testAngle = -90;
|
127
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is the inverse of the target, %@°, the method returns".fmt(testAngle, targetAngle));
|
128
|
+
|
129
|
+
// Test the target angle -90°.
|
130
|
+
targetAngle = -90;
|
131
|
+
testAngle = -96;
|
132
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is outside of the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
133
|
+
|
134
|
+
testAngle = -95;
|
135
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
136
|
+
|
137
|
+
testAngle = -94;
|
138
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is within the positive tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
139
|
+
|
140
|
+
testAngle = -90;
|
141
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the target angle for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
142
|
+
|
143
|
+
testAngle = -86;
|
144
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is within the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
145
|
+
|
146
|
+
testAngle = -85;
|
147
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), true, "If the angle, %@, is equal to the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
148
|
+
|
149
|
+
testAngle = -84;
|
150
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is outside of the negative tolerance for target, %@°, the method returns".fmt(testAngle, targetAngle));
|
151
|
+
|
152
|
+
testAngle = 90;
|
153
|
+
equals(gesture._sc_testAngle(Math.abs(testAngle), testAngle >= 0, targetAngle, 5), false, "If the angle, %@, is the inverse of the target, %@°, the method returns".fmt(testAngle, targetAngle));
|
154
|
+
});
|
@@ -0,0 +1,55 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: SproutCore
|
3
|
+
// License: Licensed under MIT license
|
4
|
+
// ==========================================================================
|
5
|
+
/*globals CoreTest, module, test, ok, equals, same, expect */
|
6
|
+
|
7
|
+
var gesture;
|
8
|
+
module("SC.TapGesture", {
|
9
|
+
|
10
|
+
setup: function () {
|
11
|
+
gesture = SC.TapGesture;
|
12
|
+
},
|
13
|
+
|
14
|
+
teardown: function () {
|
15
|
+
if (gesture.destroy) { gesture.destroy(); }
|
16
|
+
gesture = null;
|
17
|
+
}
|
18
|
+
});
|
19
|
+
|
20
|
+
/* Properties */
|
21
|
+
test("Default Properties:", function () {
|
22
|
+
gesture = gesture.create();
|
23
|
+
equals(gesture.name, 'tap', "The default value of name is");
|
24
|
+
equals(gesture.touchUnityDelay, 75, "The default value of touchUnityDelay is");
|
25
|
+
equals(gesture.tapLengthDelay, 250, "The default value of tapLengthDelay is");
|
26
|
+
equals(gesture.tapStartDelay, 150, "The default value of tapStartDelay is");
|
27
|
+
equals(gesture.tapWiggle, 10, "The default value of tapWiggle is");
|
28
|
+
});
|
29
|
+
|
30
|
+
/* Methods */
|
31
|
+
|
32
|
+
// This method returns true if the new touch is not too much later than the first touch.
|
33
|
+
test("Method: touchAddedToSession");
|
34
|
+
test("Method: touchCancelledInSession");
|
35
|
+
test("Method: touchEndedInSession");
|
36
|
+
test("Method: touchesMovedInSession");
|
37
|
+
test("Method: touchSessionCancelled");
|
38
|
+
test("Method: touchSessionEnded");
|
39
|
+
|
40
|
+
// This method registers _sc_firstTouchAddedAt & creates the _sc_tapStartTimer.
|
41
|
+
test("Method: touchSessionStarted", function () {
|
42
|
+
gesture = gesture.create({
|
43
|
+
view: {}
|
44
|
+
});
|
45
|
+
equals(gesture.touchSessionStarted(), undefined, "The method returns");
|
46
|
+
|
47
|
+
ok(gesture._sc_firstTouchAddedAt !== null, 'set', 'set', "The value of _sc_firstTouchAddedAt has been");
|
48
|
+
ok(gesture._sc_tapStartTimer !== null, 'created', 'created', "The timer _sc_tapStartTimer has been");
|
49
|
+
equals(gesture._sc_tapStartTimer.interval, gesture.get('tapStartDelay'), "The timer has the interval equal to tapStartDelay of");
|
50
|
+
});
|
51
|
+
|
52
|
+
// This method calls start.
|
53
|
+
test("Method: _sc_triggerTapStart", function () {
|
54
|
+
|
55
|
+
});
|
@@ -0,0 +1,233 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: SproutCore
|
3
|
+
// License: Licensed under MIT license
|
4
|
+
// ==========================================================================
|
5
|
+
/*globals CoreTest, module, test, ok, equals, same, expect */
|
6
|
+
|
7
|
+
var view;
|
8
|
+
module("SC.Gesturable", {
|
9
|
+
|
10
|
+
setup: function () {
|
11
|
+
view = SC.View.extend(SC.Gesturable);
|
12
|
+
},
|
13
|
+
|
14
|
+
teardown: function () {
|
15
|
+
if (view.destroy) { view.destroy(); }
|
16
|
+
view = null;
|
17
|
+
}
|
18
|
+
});
|
19
|
+
|
20
|
+
/* Properties */
|
21
|
+
test("Default Properties:", function () {
|
22
|
+
equals(view.gestures, null, "The default value of gestures is");
|
23
|
+
view = view.create({
|
24
|
+
gestures: [SC.Gesture.extend({
|
25
|
+
name: 'a'
|
26
|
+
})]
|
27
|
+
});
|
28
|
+
|
29
|
+
ok(view.concatenatedProperties.indexOf('gestures') > 0, 'gestures', 'gestures', "The default value of concatenatedProperties includes");
|
30
|
+
});
|
31
|
+
|
32
|
+
/* Methods */
|
33
|
+
|
34
|
+
// This method instantiates all gestures.
|
35
|
+
test("Method: createGestures", function () {
|
36
|
+
// It should be able to handle named gesture classess, given gesture classes and instantiated gestures.
|
37
|
+
view = view.create({
|
38
|
+
// Avoid the auto-call of createGestures.
|
39
|
+
initMixin: null,
|
40
|
+
|
41
|
+
gestures: ['aGesture',
|
42
|
+
SC.Gesture.extend({
|
43
|
+
name: 'b'
|
44
|
+
}),
|
45
|
+
SC.Gesture.create({
|
46
|
+
name: 'c'
|
47
|
+
})],
|
48
|
+
|
49
|
+
// Named.
|
50
|
+
aGesture: SC.Gesture.extend({
|
51
|
+
name: 'a'
|
52
|
+
})
|
53
|
+
});
|
54
|
+
|
55
|
+
view.createGestures();
|
56
|
+
|
57
|
+
equals(view.get('gestures')[0].isClass, undefined, "The first gesture should not be a class. I.e. the value of isClass should be");
|
58
|
+
equals(view.get('gestures')[0].name, 'a', "The first intantiated gesture should be named");
|
59
|
+
equals(view.get('gestures')[1].isClass, undefined, "The second gesture should not be a class. I.e. the value of isClass should be");
|
60
|
+
equals(view.get('gestures')[1].name, 'b', "The second intantiated gesture should be named");
|
61
|
+
equals(view.get('gestures')[2].isClass, undefined, "The third gesture should not be a class. I.e. the value of isClass should be");
|
62
|
+
equals(view.get('gestures')[2].name, 'c', "The third intantiated gesture should be named");
|
63
|
+
});
|
64
|
+
|
65
|
+
// This method calls gestureTouchStart.
|
66
|
+
test("Method: touchStart", function () {
|
67
|
+
view = view.create({
|
68
|
+
gestures: [SC.Gesture.extend({
|
69
|
+
name: 'a'
|
70
|
+
})],
|
71
|
+
|
72
|
+
// Stub out the method we expect to call.
|
73
|
+
gestureTouchStart: CoreTest.stub('gestureTouchStart', SC.Gesturable.gestureTouchStart)
|
74
|
+
});
|
75
|
+
|
76
|
+
var testTouch = SC.Touch.create({ identifier: 'test-touch' }, this);
|
77
|
+
|
78
|
+
view.touchStart(testTouch);
|
79
|
+
view.gestureTouchStart.expect(1);
|
80
|
+
});
|
81
|
+
|
82
|
+
// This method calls gestureTouchesDragged.
|
83
|
+
test("Method: touchesDragged", function () {
|
84
|
+
view = view.create({
|
85
|
+
gestures: [SC.Gesture.extend({
|
86
|
+
name: 'a'
|
87
|
+
})],
|
88
|
+
|
89
|
+
// Stub out the method we expect to call.
|
90
|
+
gestureTouchesDragged: CoreTest.stub('gestureTouchesDragged', SC.Gesturable.gestureTouchesDragged)
|
91
|
+
});
|
92
|
+
|
93
|
+
var testTouch = SC.Touch.create({ identifier: 'test-touch' }, this);
|
94
|
+
|
95
|
+
view.touchStart(testTouch);
|
96
|
+
view.touchesDragged({}, [testTouch]);
|
97
|
+
view.gestureTouchesDragged.expect(1);
|
98
|
+
});
|
99
|
+
|
100
|
+
// This method calls gestureTouchEnd.
|
101
|
+
test("Method: touchEnd", function () {
|
102
|
+
view = view.create({
|
103
|
+
gestures: [SC.Gesture.extend({
|
104
|
+
name: 'a'
|
105
|
+
})],
|
106
|
+
|
107
|
+
// Stub out the method we expect to call.
|
108
|
+
gestureTouchEnd: CoreTest.stub('gestureTouchEnd', SC.Gesturable.gestureTouchEnd)
|
109
|
+
});
|
110
|
+
|
111
|
+
var testTouch = SC.Touch.create({ identifier: 'test-touch' }, this);
|
112
|
+
|
113
|
+
view.touchStart(testTouch);
|
114
|
+
view.touchEnd(testTouch);
|
115
|
+
view.gestureTouchEnd.expect(1);
|
116
|
+
});
|
117
|
+
|
118
|
+
// This method initializes the _sc_interestedGestures & _sc_touchesInSession properties and calls touchSessionStarted
|
119
|
+
// on each gesture.
|
120
|
+
test("Method: gestureTouchStart", function () {
|
121
|
+
var testTouch = SC.Touch.create({ identifier: 'test-touch' }, this);
|
122
|
+
|
123
|
+
testTouch._isSeen = 0;
|
124
|
+
|
125
|
+
view = view.create({
|
126
|
+
gestures: [
|
127
|
+
SC.Gesture.extend({
|
128
|
+
name: 'a',
|
129
|
+
|
130
|
+
touchSessionStarted: function (aTouch) {
|
131
|
+
equals(aTouch, testTouch, "The touch is passed to the gesture. The touch param is");
|
132
|
+
equals(aTouch._isSeen, 0, "The value of _isSeen is set on the touch to");
|
133
|
+
|
134
|
+
// Bump up _isSeen to assert the order of the gestures is correct.
|
135
|
+
aTouch._isSeen = 1;
|
136
|
+
},
|
137
|
+
|
138
|
+
touchAddedToSession: function (aTouch, touchesAlreadyInSession) {
|
139
|
+
equals(aTouch, testTouch2, "The touch is passed to the gesture. The touch param is");
|
140
|
+
same(touchesAlreadyInSession, [testTouch], "The touchesAlreadyInSession is passed to the gesture. The touchesAlreadyInSession param is");
|
141
|
+
}
|
142
|
+
}),
|
143
|
+
SC.Gesture.extend({
|
144
|
+
name: 'b',
|
145
|
+
|
146
|
+
touchSessionStarted: function (aTouch) {
|
147
|
+
equals(aTouch, testTouch, "The touch is passed to the gesture. The touch param is");
|
148
|
+
equals(aTouch._isSeen, 1, "The value of _isSeen is set on the touch to");
|
149
|
+
},
|
150
|
+
|
151
|
+
touchAddedToSession: function (aTouch, touchesAlreadyInSession) {
|
152
|
+
equals(aTouch, testTouch2, "The touch is passed to the gesture. The touch param is");
|
153
|
+
same(touchesAlreadyInSession, [testTouch], "The touchesAlreadyInSession is passed to the gesture. The touchesAlreadyInSession param is");
|
154
|
+
}
|
155
|
+
})]
|
156
|
+
});
|
157
|
+
|
158
|
+
equals(view.gestureTouchStart(testTouch), true, "The method returns");
|
159
|
+
|
160
|
+
same(view._sc_interestedGestures, view.gestures, "The value of view._sc_interestedGestures is");
|
161
|
+
same(view._sc_touchesInSession, [testTouch], "The value of view._sc_touchesInSession is");
|
162
|
+
|
163
|
+
// Ensure 7 tests run.
|
164
|
+
expect(7);
|
165
|
+
|
166
|
+
// Add a second touch.
|
167
|
+
var testTouch2 = SC.Touch.create({ identifier: 'test-touch-2' }, this);
|
168
|
+
view.gestureTouchStart(testTouch2);
|
169
|
+
|
170
|
+
// Ensure 11 tests run.
|
171
|
+
expect(11);
|
172
|
+
});
|
173
|
+
|
174
|
+
// This method calls touchesMovedInSession on each gesture.
|
175
|
+
test("Method: gestureTouchesDragged", function () {
|
176
|
+
var testTouch = SC.Touch.create({ identifier: 'test-touch' }, this);
|
177
|
+
|
178
|
+
view = view.create({
|
179
|
+
gestures: [
|
180
|
+
SC.Gesture.extend({
|
181
|
+
name: 'a',
|
182
|
+
|
183
|
+
touchesMovedInSession: function (touches) {
|
184
|
+
same(touches, [testTouch], "The touches are passed to the gesture. The touches param is");
|
185
|
+
}
|
186
|
+
}),
|
187
|
+
SC.Gesture.extend({
|
188
|
+
name: 'b',
|
189
|
+
|
190
|
+
touchesMovedInSession: function (touches) {
|
191
|
+
same(touches, [testTouch], "The touches are passed to the gesture. The touches param is");
|
192
|
+
}
|
193
|
+
})]
|
194
|
+
});
|
195
|
+
|
196
|
+
view.gestureTouchStart(testTouch);
|
197
|
+
equals(view.gestureTouchesDragged({}, [testTouch]), undefined, "The method returns");
|
198
|
+
|
199
|
+
// Ensure 3 tests run.
|
200
|
+
expect(3);
|
201
|
+
});
|
202
|
+
|
203
|
+
|
204
|
+
// This method calls touchEndedInSession on each gesture.
|
205
|
+
test("Method: gestureTouchEnd", function () {
|
206
|
+
var testTouch = SC.Touch.create({ identifier: 'test-touch' }, this);
|
207
|
+
|
208
|
+
view = view.create({
|
209
|
+
gestures: [
|
210
|
+
SC.Gesture.extend({
|
211
|
+
name: 'a',
|
212
|
+
|
213
|
+
touchEndedInSession: function (touch, touchesStillInSession) {
|
214
|
+
equals(touch, testTouch, "The touch is passed to the gesture. The touch param is");
|
215
|
+
same(touchesStillInSession, [], "The touchesStillInSession is passed to the gesture. The touchesStillInSession param is");
|
216
|
+
}
|
217
|
+
}),
|
218
|
+
SC.Gesture.extend({
|
219
|
+
name: 'b',
|
220
|
+
|
221
|
+
touchEndedInSession: function (touch, touchesStillInSession) {
|
222
|
+
equals(touch, testTouch, "The touch is passed to the gesture. The touch param is");
|
223
|
+
same(touchesStillInSession, [], "The touchesStillInSession is passed to the gesture. The touchesStillInSession param is");
|
224
|
+
}
|
225
|
+
})]
|
226
|
+
});
|
227
|
+
|
228
|
+
view.gestureTouchStart(testTouch);
|
229
|
+
equals(view.gestureTouchEnd(testTouch), undefined, "The method returns");
|
230
|
+
|
231
|
+
// Ensure 5 tests run.
|
232
|
+
expect(5);
|
233
|
+
});
|
@@ -121,9 +121,9 @@ test("Test that an exception is thrown when calling adjust and setting to auto",
|
|
121
121
|
parent.adjust('width', 'auto').adjust('height', 'auto');
|
122
122
|
parent.get('layoutStyle');
|
123
123
|
}catch(e){
|
124
|
-
error=
|
124
|
+
error=true;
|
125
125
|
}
|
126
|
-
|
126
|
+
ok(error,'Layout style functions should throw an error if width/height are set to auto but staticLayout is not enabled' + error );
|
127
127
|
});
|
128
128
|
|
129
129
|
test("Test SC.StaticLayout frame support", function() {
|