From 821413607a0718156f9d25d895e89b1c3d37aa8b Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Wed, 06 Feb 2013 13:49:14 +0000 Subject: Copy various bits from gaia --- (limited to 'apps/system/test/unit/mock_apps_mgmt.js') diff --git a/apps/system/test/unit/mock_apps_mgmt.js b/apps/system/test/unit/mock_apps_mgmt.js new file mode 100644 index 0000000..948ef02 --- /dev/null +++ b/apps/system/test/unit/mock_apps_mgmt.js @@ -0,0 +1,64 @@ +var MockAppsMgmt = { + getAll: function mam_getAll() { + var request = {}; + + setTimeout((function nextTick() { + if (request.onsuccess) { + var evt = { + target: { + result: this.mApps + } + }; + request.onsuccess(evt); + if (this.mNext) { + this.mNext(); + } + } + }).bind(this)); + + return request; + }, + + applyDownload: function mam_applyDownload(app) { + this.mLastAppApplied = app; + }, + + mApps: [], + mLastAppApplied: null, + mNext: null, + mTeardown: function mam_mTeardown() { + this.mLastAppApplied = null; + this.mApps = []; + this.mNext = null; + }, + + mTriggerOninstall: function mam_mTriggerOninstall(app) { + if (this.oninstall) { + var evt = { + application: app + }; + this.oninstall(evt); + } + + var evt = document.createEvent('CustomEvent'); + evt.initCustomEvent('applicationinstall', + true, false, + { application: app }); + window.dispatchEvent(evt); + }, + + mTriggerOnuninstall: function mam_mTriggerOnuninstall(app) { + if (this.onuninstall) { + var evt = { + application: app + }; + this.onuninstall(evt); + } + + var evt = document.createEvent('CustomEvent'); + evt.initCustomEvent('applicationuninstall', + true, false, + { application: app }); + window.dispatchEvent(evt); + } +}; -- cgit v0.9.1