blob: 2d34051381e88db24cf9c44f565d2506b0964d15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
89
90
91
92
93
|
'use strict';
var idGen = 0;
function MockApp(opts) {
/* default values */
this.origin = 'https://testapp.gaiamobile.org';
this.manifestURL = 'https://testapp.gaiamobile.org/manifest' +
idGen + '.webapp';
this.manifest = {
name: 'Mock app'
};
this.removable = true;
this.installState = 'installed';
this.downloadAvailable = false;
this.downloadError = null;
this.downloadSize = null;
this.mId = idGen++;
this.mDownloadCalled = false;
this.mCancelCalled = false;
/* overwrite default values with whatever comes in "opts" from the test */
if (opts) {
for (var key in opts) {
this[key] = opts[key];
}
}
}
MockApp.prototype.download = function() {
this.mDownloadCalled = true;
};
MockApp.prototype.cancelDownload = function() {
this.mCancelCalled = true;
};
MockApp.prototype.mTriggerDownloadAvailable = function(size) {
this.downloadAvailable = true;
this.downloadSize = size;
if (this.ondownloadavailable) {
this.ondownloadavailable({
application: this
});
}
};
MockApp.prototype.mTriggerDownloadSuccess = function() {
this.downloadAvailable = false;
this.downloadSize = null;
if (this.ondownloadsuccess) {
this.ondownloadsuccess({
application: this
});
}
};
MockApp.prototype.mTriggerDownloadError = function(error) {
this.downloadAvailable = true;
this.downloadSize = null;
this.downloadError = {
name: error || 'UNKNOWN_ERROR'
};
if (this.ondownloaderror) {
this.ondownloaderror({
application: this
});
}
};
MockApp.prototype.mTriggerDownloadProgress = function(progress) {
this.progress = progress;
if (this.onprogress) {
this.onprogress({
application: this
});
}
};
MockApp.prototype.mTriggerDownloadApplied = function() {
this.downloadAvailable = false;
this.downloadSize = null;
if (this.ondownloadapplied) {
this.ondownloadapplied({
application: this
});
}
};
|