~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/tests/event/tests/src/event-resize.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
var suite = new Y.Test.Suite("event-resize"),
2
 
    win = Y.one( Y.config.win ),
3
 
    eventKey = 'event:' + Y.stamp(Y.config.win) + 'resizenative',
4
 
    isOldGecko = (Y.UA.gecko && Y.UA.gecko < 1.91);
5
 
 
6
 
function simulateResize() {
7
 
    // IE doesn't allow simulation of window.onresize, so I can't use
8
 
    //Y.Event.simulate(Y.config.win, 'resize');
9
 
    setTimeout(function () {
10
 
        Y.Env.evt.dom_wrappers[eventKey].fire({
11
 
            type: 'resize',
12
 
            srcElement: Y.config.win,
13
 
            target: Y.config.win
14
 
        });
15
 
    }, 10);
16
 
}
17
 
 
18
 
suite.add(new Y.Test.Case({
19
 
    name: 'subscribe',
20
 
 
21
 
    _should: {
22
 
        ignore: {
23
 
            // I can't get this damn test to pass in CI.  It's likely a bad
24
 
            // test, but I'm having a hell of a time divising a good one.
25
 
            "test resize event throttling": true
26
 
        }
27
 
    },
28
 
 
29
 
    "test Y.on('windowresize', fn)": function () {
30
 
        var test = this,
31
 
            handle;
32
 
 
33
 
        function handler(e) {
34
 
            var thisObj = this,
35
 
                argCount = arguments.length;
36
 
 
37
 
            handle.detach();
38
 
 
39
 
            test.resume(function () {
40
 
                Y.Assert.areSame('windowresize', e.type);
41
 
                Y.Assert.areSame(1, argCount);
42
 
                Y.Assert.areSame(win, thisObj, "this should be window");
43
 
                Y.Assert.areSame(win, e.target, "e.target should be window");
44
 
            });
45
 
        }
46
 
 
47
 
        handle = Y.on('windowresize', handler);
48
 
 
49
 
        simulateResize();
50
 
 
51
 
        this.wait();
52
 
    },
53
 
 
54
 
    "test node.on('windowresize', fn)": function () {
55
 
        var test    = this,
56
 
            refNode = Y.Node.create('<div />').appendTo(Y.one('body')),
57
 
            handle;
58
 
 
59
 
        function handler(e) {
60
 
            var thisObj = this,
61
 
                argCount = arguments.length;
62
 
 
63
 
            handle.detach();
64
 
 
65
 
            test.resume(function () {
66
 
                // TODO: is this a bug?
67
 
                Y.Assert.areSame(win, thisObj, "this should be window");
68
 
                Y.Assert.areSame(win, e.target, "e.target should be window");
69
 
                Y.Assert.areSame(1, argCount);
70
 
                Y.Assert.areSame('windowresize', e.type);
71
 
            });
72
 
        }
73
 
 
74
 
        handle = refNode.on('windowresize', handler);
75
 
 
76
 
        simulateResize();
77
 
 
78
 
        this.wait();
79
 
    },
80
 
 
81
 
    "test resize event throttling": function () {
82
 
        var test = this,
83
 
            testThresholds = [40, 100, 300],
84
 
            // This prevents the test from timing out if the browser is
85
 
            // inordinately slow
86
 
            keepAlive = Y.on('resize', function () {
87
 
                test.resume(function () {
88
 
                    test.wait();
89
 
                });
90
 
            }),
91
 
            // Allow for 10ms of leeway from the threshold.  FF is firing a few
92
 
            // milliseconds before the threshold, and I think that's close
93
 
            // enough
94
 
            fudge = 10;
95
 
 
96
 
        function runTest(threshold) {
97
 
            var delay = 10,
98
 
                handle, timer, start;
99
 
 
100
 
            Y.config.windowResizeDelay = threshold;
101
 
 
102
 
            handle = Y.on('windowresize', function (e) {
103
 
                var end = new Date();
104
 
 
105
 
                timer.cancel();
106
 
                handle.detach();
107
 
 
108
 
                test.resume(function () {
109
 
                    Y.assert(isOldGecko || (end - start + fudge >= threshold),
110
 
                        "Fired before threshold (" + threshold + ") - delta: " +
111
 
                        (end - start));
112
 
 
113
 
                    if (testThresholds.length) {
114
 
                        runTest(testThresholds.shift());
115
 
                    } else {
116
 
                        keepAlive.detach();
117
 
                    }
118
 
                });
119
 
            });
120
 
 
121
 
            // recursive async function that fires resize on an incrementing
122
 
            // delay, starting at 10ms, then 20ms, 30ms, and so on.
123
 
            function scheduleResize() {
124
 
                start = new Date();
125
 
 
126
 
                timer = Y.later(delay, Y, function () {
127
 
                    simulateResize();
128
 
                    scheduleResize();
129
 
                });
130
 
 
131
 
                delay += 10;
132
 
            }
133
 
 
134
 
            scheduleResize();
135
 
 
136
 
            test.wait();
137
 
        }
138
 
 
139
 
        runTest(testThresholds.shift());
140
 
    }
141
 
}));
142
 
 
143
 
Y.Test.Runner.add(suite);