Debian Codegraph @

dojox/mobile/tests/doh/view/ScrollableView_Programmatic.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
5 <meta name="viewport"
6 content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
7 <meta name="apple-mobile-web-app-capable" content="yes"/>
8 <title>ScrollableView</title>
9
10 <!-- Test for ScrollableView's onFlickAnimationStart/End (Trac #17822) -->
11
12 <script type="text/javascript" src="../../../deviceTheme.js"></script>
13 <script type="text/javascript" src="../../../../../dojo/dojo.js"
14 data-dojo-config="async: true, parseOnLoad: true"></script>
15
16 <script type="text/javascript">
17 var onYearSet, onMonthSet, onDaySet;
18 require([
19 "dojo/ready", "dojo/dom-construct", "dijit/registry", "doh/runner",
20 "dojox/mobile/ScrollableView", "dojox/mobile", "dojox/mobile/compat", "dojox/mobile/parser",
21 "dojo/fx", "dojo/fx/easing" // needed by dojox/mobile/scrollable for browsers non supporting css3 animations
22 ],
23 function(ready, domConstruct, registry, runner, ScrollableView){
24
25 var onFlickAnimationStartCounter, onFlickAnimationEndCounter;
26
27 ready(function(){
28 var installCounters = function(scrollableView){
29 scrollableView.on("flickAnimationStart", function(){
30 onFlickAnimationStartCounter++;
31 });
32 scrollableView.on("flickAnimationEnd", function(){
33 onFlickAnimationEndCounter++;
34 });
35 };
36
37 var initCounters = function(){
38 onFlickAnimationStartCounter = onFlickAnimationEndCounter = 0;
39 };
40
41 var checkCounters = function(scrollType, expectedStartCounter, expectedEndCounter){
42 var msg = "scrollType: " + scrollType;
43 runner.assertEqual(expectedStartCounter, onFlickAnimationStartCounter,
44 msg + " Unexpected onFlickAnimationStartCounter");
45 runner.assertEqual(expectedEndCounter, onFlickAnimationEndCounter,
46 msg + " Unexpected onFlickAnimationEndCounter");
47 };
48
49 var createScrollableView = function(scrollType){
50 var scrollableView = new ScrollableView({scrollType: scrollType});
51 installCounters(scrollableView);
52 document.body.innerHTML = "";
53 document.body.appendChild(scrollableView.domNode);
54 scrollableView.startup();
55 var rect = domConstruct.create("div");
56 // larger than the ScrollableView to ensure actual scroll
57 rect.style.height = "1000px";
58 scrollableView.containerNode.appendChild(rect);
59 scrollableView.style.height = "500px";
60 scrollableView.startup();
61 scrollableView.resize();
62 return scrollableView;
63 };
64
65 var testScrollableView = function(scrollType){
66 var scrollableView = createScrollableView(scrollType);
67 initCounters();
68 scrollableView.slideTo({y: -100}, 0.2/*duration*/); // animated scroll
69 var d = new runner.Deferred();
70 // setTimeout used because onFlickAnimationEnd is called asynchronously
71 setTimeout(d.getTestCallback(function(){
72 checkCounters(scrollType, 1, 1);
73 }), 1000);
74 return d;
75 };
76
77 runner.register("dojox.mobile.test.doh.ScrollableView", [
78 {
79 name: "onFlickAnimationStart/End scrollType 1",
80 timeout: 2000,
81 runTest: function(){
82 return testScrollableView(1);
83 }
84 },
85 {
86 name: "onFlickAnimationStart/End scrollType 2",
87 timeout: 2000,
88 runTest: function(){
89 return testScrollableView(2);
90 }
91 },
92 {
93 name: "onFlickAnimationStart/End scrollType 3",
94 timeout: 2000,
95 runTest: function(){
96 return testScrollableView(3);
97 }
98 }
99 ]);
100
101 runner.run();
102 });
103 });
104 </script>
105 </head>
106 <body style="visibility:hidden;">
107 </body>
108 </html>