Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
14
gaia/tv_apps/smart-system/test/marionette/.jshintrc
Executable file
14
gaia/tv_apps/smart-system/test/marionette/.jshintrc
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"extends": "../../../../.jshintrc",
|
||||
"node": true,
|
||||
"predef": [
|
||||
"suite",
|
||||
"test",
|
||||
"setup",
|
||||
"teardown",
|
||||
"suiteSetup",
|
||||
"suiteTeardown",
|
||||
"marionette",
|
||||
"marionetteScriptFinished"
|
||||
]
|
||||
}
|
||||
151
gaia/tv_apps/smart-system/test/marionette/app_install_dialog_test.js
Executable file
151
gaia/tv_apps/smart-system/test/marionette/app_install_dialog_test.js
Executable file
|
|
@ -0,0 +1,151 @@
|
|||
'use strict';
|
||||
|
||||
var Keys = {
|
||||
'enter': '\ue006',
|
||||
'left': '\ue012',
|
||||
'right': '\ue014'
|
||||
};
|
||||
|
||||
var assert = require('chai').assert;
|
||||
var AppInstaller = require('./lib/app_install');
|
||||
var Server = require('../../../../shared/test/integration/server');
|
||||
|
||||
// Bug 1207453 - Skip the test due to unknown test enviroment issue for now.
|
||||
// We should investigate the issue and re-enable the test later.
|
||||
marionette.skip('app install manager tests', function() {
|
||||
|
||||
var opts = {
|
||||
apps: {},
|
||||
hostOptions: {
|
||||
screen: {
|
||||
width: 1920,
|
||||
height: 1080
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var client = marionette.client({
|
||||
profile: opts,
|
||||
// XXX: Set this to true once Accessibility is implemented in TV
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var system;
|
||||
var appInstaller;
|
||||
var server;
|
||||
var serverManifestURL;
|
||||
var serverIMEURL;
|
||||
|
||||
suiteSetup(function(done) {
|
||||
Server.create(__dirname + '/../apps/hosted-app', function(err, _server) {
|
||||
server = _server;
|
||||
serverManifestURL = server.url('manifest.webapp');
|
||||
serverIMEURL = server.url('ime_manifest.webapp');
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
suiteTeardown(function() {
|
||||
server.stop();
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
system = client.loader.getAppClass('smart-system', 'system', 'tv_apps');
|
||||
appInstaller = new AppInstaller(client);
|
||||
// Once the os-logo is disappeared, the first app is shown and focused. It
|
||||
// implies system is ready to go.
|
||||
client.helper.waitForElementToDisappear('#os-logo');
|
||||
});
|
||||
|
||||
test('install app', { devices: ['tv'] }, function() {
|
||||
// install app
|
||||
appInstaller.install(serverManifestURL);
|
||||
// press install button
|
||||
var installButton = client.helper.waitForElement(
|
||||
system.Selector.appInstallInstallButton);
|
||||
installButton.sendKeys(Keys.enter);
|
||||
// check app installed
|
||||
system.waitForAppInstalled(serverManifestURL);
|
||||
});
|
||||
|
||||
test('install app and cancel it', { devices: ['tv'] }, function() {
|
||||
// install app
|
||||
appInstaller.install(serverManifestURL);
|
||||
// press install button
|
||||
var cancelInstallButton = client.helper.waitForElement(
|
||||
system.Selector.appInstallCancelButton);
|
||||
|
||||
cancelInstallButton.sendKeys(Keys.left);
|
||||
assert.isTrue(cancelInstallButton.scriptWith(function(el) {
|
||||
return document.activeElement === el;
|
||||
}), 'cancel button should be focused.');
|
||||
|
||||
cancelInstallButton.sendKeys(Keys.enter);
|
||||
var cancelConfirmButton = client.helper.waitForElement(
|
||||
system.Selector.appCancelInstallConfirmButton);
|
||||
|
||||
system.waitForEvent('modal-dialog-opened');
|
||||
assert.isTrue(cancelConfirmButton.scriptWith(function(el) {
|
||||
return document.activeElement === el;
|
||||
}), 'confirm button should be focused.');
|
||||
cancelConfirmButton.sendKeys(Keys.enter);
|
||||
|
||||
assert.isFalse(system.isAppInstalled(serverManifestURL),
|
||||
'app should not be installed');
|
||||
});
|
||||
|
||||
test('install app and uninstall it', { devices: ['tv'] }, function() {
|
||||
// install app
|
||||
appInstaller.install(serverManifestURL);
|
||||
var installButton = client.helper.waitForElement(
|
||||
system.Selector.appInstallInstallButton);
|
||||
installButton.sendKeys(Keys.enter);
|
||||
system.waitForAppInstalled(serverManifestURL);
|
||||
|
||||
// uninstall app
|
||||
appInstaller.uninstall(serverManifestURL);
|
||||
|
||||
// wait for dialog
|
||||
var confirmButton = client.helper.waitForElement(
|
||||
system.Selector.appUninstallConfirmButton);
|
||||
confirmButton.sendKeys(Keys.right);
|
||||
assert.isTrue(confirmButton.scriptWith(function(el) {
|
||||
return document.activeElement === el;
|
||||
}), 'confirm button should be focused.');
|
||||
// uninstall it
|
||||
confirmButton.sendKeys(Keys.enter);
|
||||
system.waitForAppUninstalled(serverManifestURL);
|
||||
});
|
||||
|
||||
test('uninstall and cancel it', { devices: ['tv'] }, function() {
|
||||
// install app
|
||||
appInstaller.install(serverManifestURL);
|
||||
var installButton = client.helper.waitForElement(
|
||||
system.Selector.appInstallInstallButton);
|
||||
installButton.sendKeys(Keys.enter);
|
||||
system.waitForAppInstalled(serverManifestURL);
|
||||
|
||||
appInstaller.uninstall(serverManifestURL);
|
||||
|
||||
var cancelButton = client.helper.waitForElement(
|
||||
system.Selector.appUninstallCancelButton);
|
||||
cancelButton.sendKeys(Keys.enter);
|
||||
|
||||
assert.isTrue(system.isAppInstalled(serverManifestURL),
|
||||
'app should be installed');
|
||||
});
|
||||
|
||||
test('install keyboard app and test setup', { devices: ['tv'] }, function() {
|
||||
// install app
|
||||
appInstaller.install(serverIMEURL);
|
||||
var installButton = client.helper.waitForElement(
|
||||
system.Selector.appInstallInstallButton);
|
||||
installButton.sendKeys(Keys.enter);
|
||||
system.waitForAppInstalled(serverIMEURL);
|
||||
|
||||
var laterButton = client.helper.waitForElement(
|
||||
system.Selector.appInstallSetupLaterButton);
|
||||
laterButton.sendKeys(Keys.enter);
|
||||
client.helper.waitForElementToDisappear(
|
||||
system.Selector.appInstallSetupLaterButton);
|
||||
});
|
||||
});
|
||||
212
gaia/tv_apps/smart-system/test/marionette/app_modal_dialog_test.js
Executable file
212
gaia/tv_apps/smart-system/test/marionette/app_modal_dialog_test.js
Executable file
|
|
@ -0,0 +1,212 @@
|
|||
'use strict';
|
||||
|
||||
var APP_NAME = 'modaldialogapp';
|
||||
var APP_HOST = APP_NAME + '.gaiamobile.org';
|
||||
var APP_URL = 'app://' + APP_HOST;
|
||||
|
||||
var Keys = {
|
||||
'enter': '\ue006',
|
||||
'right': '\ue014',
|
||||
'esc': '\ue00c'
|
||||
};
|
||||
|
||||
var assert = require('chai').assert;
|
||||
var AppModalDialog = require('./lib/app_modal_dialog');
|
||||
|
||||
// Bug 1207453 - Skip the test due to unknown test enviroment issue for now.
|
||||
// We should investigate the issue and re-enable the test later.
|
||||
marionette.skip('Test Modal Dialog Events', function() {
|
||||
|
||||
var opts = {
|
||||
apps: {},
|
||||
hostOptions: {
|
||||
screen: {
|
||||
width: 1920,
|
||||
height: 1080
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
opts.apps[APP_HOST] = __dirname + '/../apps/' + APP_NAME;
|
||||
|
||||
var client = marionette.client({
|
||||
profile: opts,
|
||||
// XXX: Set this to true once Accessibility is implemented in TV
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var testOptions = { devices: ['tv'] };
|
||||
var actions;
|
||||
var system;
|
||||
var appModalDialog;
|
||||
var options = {
|
||||
// App name should be the same name in modaldialogapp/manifest.webapp,
|
||||
// appName will show on alert/prompt/confirm title and we will verify it
|
||||
// shows un-escaped message on it.
|
||||
appName: '>>> Modal Dialog <<<',
|
||||
// We are going to pass message with special characters to modal dialog
|
||||
// and verify it shows un-escaped message as expected.
|
||||
alert: {
|
||||
message: '<b>Alert message</b>'
|
||||
},
|
||||
prompt: {
|
||||
message: '<u>Prompt message</u>'
|
||||
},
|
||||
confirm: {
|
||||
message: '<i>Confrim message</i>'
|
||||
}
|
||||
};
|
||||
|
||||
setup(function() {
|
||||
actions = client.loader.getActions();
|
||||
system = client.loader.getAppClass('smart-system', 'system', 'tv_apps');
|
||||
appModalDialog = new AppModalDialog(client);
|
||||
});
|
||||
|
||||
function launchModalDialogApp() {
|
||||
// Launch test app
|
||||
client.apps.launch(APP_URL);
|
||||
client.apps.switchToApp(APP_URL);
|
||||
}
|
||||
|
||||
test('alert modal dialog should disappear', testOptions, function() {
|
||||
launchModalDialogApp();
|
||||
client.executeAsyncScript(function(options) {
|
||||
window.wrappedJSObject.showDialog('alert', options.alert.message);
|
||||
marionetteScriptFinished();
|
||||
}, [options]);
|
||||
client.switchToFrame();
|
||||
|
||||
appModalDialog.waitForDialogOpened(appModalDialog.alertDialog);
|
||||
|
||||
assert.equal(appModalDialog.alertMessage.scriptWith(function(el) {
|
||||
return el.textContent;
|
||||
}), options.alert.message);
|
||||
|
||||
appModalDialog.sendKeyToElement(appModalDialog.alertOk, Keys.enter);
|
||||
appModalDialog.waitForDialogClosed(appModalDialog.alertDialog);
|
||||
});
|
||||
|
||||
test('alert modal dialog should focus on ok when opened', testOptions,
|
||||
function() {
|
||||
launchModalDialogApp();
|
||||
client.executeAsyncScript(function(options) {
|
||||
window.wrappedJSObject.showDialog('alert', options.alert.message);
|
||||
marionetteScriptFinished();
|
||||
}, [options]);
|
||||
client.switchToFrame();
|
||||
|
||||
appModalDialog.waitForDialogOpened(appModalDialog.alertDialog);
|
||||
assert.ok(appModalDialog.alertOk.scriptWith(function(el) {
|
||||
return document.activeElement === el;
|
||||
}));
|
||||
});
|
||||
|
||||
test('prompt modal dialog should disappear - ok', testOptions,
|
||||
function() {
|
||||
launchModalDialogApp();
|
||||
client.executeAsyncScript(function(options) {
|
||||
window.wrappedJSObject.showDialog('prompt', options.prompt.message);
|
||||
marionetteScriptFinished();
|
||||
}, [options]);
|
||||
client.switchToFrame();
|
||||
|
||||
appModalDialog.waitForDialogOpened(appModalDialog.promptDialog);
|
||||
|
||||
assert.equal(appModalDialog.promptMessage.scriptWith(function(el) {
|
||||
return el.textContent;
|
||||
}), options.prompt.message);
|
||||
|
||||
appModalDialog.sendKeyToElement(appModalDialog.promptOk, Keys.enter);
|
||||
appModalDialog.waitForDialogClosed(appModalDialog.promptDialog);
|
||||
});
|
||||
|
||||
test('prompt modal dialog should disappear - cancel', testOptions,
|
||||
function() {
|
||||
launchModalDialogApp();
|
||||
client.executeAsyncScript(function(options) {
|
||||
window.wrappedJSObject.showDialog('prompt', options.prompt.message);
|
||||
marionetteScriptFinished();
|
||||
}, [options]);
|
||||
client.switchToFrame();
|
||||
|
||||
appModalDialog.waitForDialogOpened(appModalDialog.promptDialog);
|
||||
|
||||
assert.equal(appModalDialog.promptMessage.scriptWith(function(el) {
|
||||
return el.textContent;
|
||||
}), options.prompt.message);
|
||||
|
||||
appModalDialog.sendKeyToElement(appModalDialog.promptCancel, Keys.enter);
|
||||
appModalDialog.waitForDialogClosed(appModalDialog.promptDialog);
|
||||
});
|
||||
|
||||
test('prompt modal dialog should focus on input when opened', testOptions,
|
||||
function() {
|
||||
launchModalDialogApp();
|
||||
client.executeAsyncScript(function(options) {
|
||||
window.wrappedJSObject.showDialog('prompt', options.prompt.message);
|
||||
marionetteScriptFinished();
|
||||
}, [options]);
|
||||
client.switchToFrame();
|
||||
|
||||
appModalDialog.waitForDialogOpened(appModalDialog.promptDialog);
|
||||
|
||||
assert.ok(appModalDialog.promptInput.scriptWith(function(el) {
|
||||
return document.activeElement === el;
|
||||
}));
|
||||
});
|
||||
|
||||
test('confirm modal dialog should disappear - ok', testOptions,
|
||||
function() {
|
||||
launchModalDialogApp();
|
||||
client.executeAsyncScript(function(options) {
|
||||
window.wrappedJSObject.showDialog('confirm', options.confirm.message);
|
||||
marionetteScriptFinished();
|
||||
}, [options]);
|
||||
client.switchToFrame();
|
||||
|
||||
appModalDialog.waitForDialogOpened(appModalDialog.confirmDialog);
|
||||
|
||||
assert.equal(appModalDialog.confirmMessage.scriptWith(function(el) {
|
||||
return el.textContent;
|
||||
}), options.confirm.message);
|
||||
|
||||
appModalDialog.sendKeyToElement(appModalDialog.confirmOk, Keys.enter);
|
||||
appModalDialog.waitForDialogClosed(appModalDialog.confirmDialog);
|
||||
});
|
||||
|
||||
test('confirm modal dialog should disappear - cancel', testOptions,
|
||||
function() {
|
||||
launchModalDialogApp();
|
||||
client.executeAsyncScript(function(options) {
|
||||
window.wrappedJSObject.showDialog('confirm', options.confirm.message);
|
||||
marionetteScriptFinished();
|
||||
}, [options]);
|
||||
client.switchToFrame();
|
||||
|
||||
appModalDialog.waitForDialogOpened(appModalDialog.confirmDialog);
|
||||
|
||||
assert.equal(appModalDialog.confirmMessage.scriptWith(function(el) {
|
||||
return el.textContent;
|
||||
}), options.confirm.message);
|
||||
|
||||
appModalDialog.sendKeyToElement(appModalDialog.confirmCancel, Keys.enter);
|
||||
appModalDialog.waitForDialogClosed(appModalDialog.confirmDialog);
|
||||
});
|
||||
|
||||
test('confirm modal dialog should focus on ok when opened', testOptions,
|
||||
function() {
|
||||
launchModalDialogApp();
|
||||
client.executeAsyncScript(function(options) {
|
||||
window.wrappedJSObject.showDialog('confirm', options.confirm.message);
|
||||
marionetteScriptFinished();
|
||||
}, [options]);
|
||||
client.switchToFrame();
|
||||
|
||||
appModalDialog.waitForDialogOpened(appModalDialog.confirmDialog);
|
||||
|
||||
assert.ok(appModalDialog.confirmOk.scriptWith(function(el) {
|
||||
return document.activeElement === el;
|
||||
}));
|
||||
});
|
||||
|
||||
});
|
||||
122
gaia/tv_apps/smart-system/test/marionette/browser_context_menu_test.js
Executable file
122
gaia/tv_apps/smart-system/test/marionette/browser_context_menu_test.js
Executable file
|
|
@ -0,0 +1,122 @@
|
|||
'use strict';
|
||||
|
||||
var APP_NAME = 'contextmenuapp';
|
||||
var APP_HOST = APP_NAME + '.gaiamobile.org';
|
||||
var APP_URL = 'app://' + APP_HOST;
|
||||
|
||||
var Keys = {
|
||||
'enter': '\ue006',
|
||||
'right': '\ue014',
|
||||
'esc': '\ue00c'
|
||||
};
|
||||
|
||||
var assert = require('chai').assert;
|
||||
|
||||
// Bug 1207453 - Skip the test due to unknown test enviroment issue for now.
|
||||
// We should investigate the issue and re-enable the test later.
|
||||
marionette.skip('Test Context Menu Events', function() {
|
||||
|
||||
var opts = {
|
||||
apps: {},
|
||||
hostOptions: {
|
||||
screen: {
|
||||
width: 1920,
|
||||
height: 1080
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
opts.apps[APP_HOST] = __dirname + '/../apps/' + APP_NAME;
|
||||
|
||||
var client = marionette.client({
|
||||
profile: opts,
|
||||
// XXX: Set this to true once Accessibility is implemented in TV
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var actions;
|
||||
var system;
|
||||
var menuSelectors = [
|
||||
'.appWindow.active .modal-dialog-button-group smart-button:nth-child(1)',
|
||||
'.appWindow.active .modal-dialog-button-group smart-button:nth-child(2)'
|
||||
];
|
||||
|
||||
setup(function() {
|
||||
actions = client.loader.getActions();
|
||||
system = client.loader.getAppClass('smart-system', 'system', 'tv_apps');
|
||||
});
|
||||
|
||||
function launchContextMenu() {
|
||||
// Launch test app
|
||||
client.apps.launch(APP_URL);
|
||||
client.apps.switchToApp(APP_URL);
|
||||
|
||||
// Long press on a link
|
||||
var link = client.helper.waitForElement('#link');
|
||||
actions.longPress(link, 1.5).perform();
|
||||
|
||||
}
|
||||
|
||||
test('press enter on first menu', { 'devices': ['tv'] }, function() {
|
||||
launchContextMenu();
|
||||
client.switchToFrame();
|
||||
|
||||
system.waitForEvent('appcontextmenu-shown');
|
||||
|
||||
var container = system.appChromeContextMenuContainer;
|
||||
// find the first context menu
|
||||
var firstMenu = client.helper.waitForElement(menuSelectors[0]);
|
||||
// check focus
|
||||
assert.isTrue(firstMenu.scriptWith(function(el) {
|
||||
return document.activeElement === el;
|
||||
}), 'first smart button should be focused.');
|
||||
// press enter and close it
|
||||
firstMenu.sendKeys(Keys.enter);
|
||||
|
||||
system.waitForEvent('appcontextmenu-hidden');
|
||||
assert.isFalse(firstMenu.displayed());
|
||||
assert.isFalse(container.displayed());
|
||||
});
|
||||
|
||||
test('press enter on second menu', { 'devices': ['tv'] }, function() {
|
||||
launchContextMenu();
|
||||
client.switchToFrame();
|
||||
|
||||
system.waitForEvent('appcontextmenu-shown');
|
||||
|
||||
var container = system.appChromeContextMenuContainer;
|
||||
|
||||
// wait for second menu
|
||||
var secondMenu = client.helper.waitForElement(menuSelectors[1]);
|
||||
// move focus to second one
|
||||
var menu = system.appChromeContextMenu;
|
||||
menu.sendKeys(Keys.right);
|
||||
|
||||
assert.isTrue(secondMenu.scriptWith(function(el) {
|
||||
return document.activeElement === el;
|
||||
}), 'second smart button should be focused.');
|
||||
// press enter and close it
|
||||
secondMenu.sendKeys(Keys.enter);
|
||||
|
||||
system.waitForEvent('appcontextmenu-hidden');
|
||||
assert.isFalse(menu.displayed());
|
||||
assert.isFalse(container.displayed());
|
||||
});
|
||||
|
||||
test('press esc after menu shown', { 'devices': ['tv'] }, function() {
|
||||
launchContextMenu();
|
||||
client.switchToFrame();
|
||||
|
||||
system.waitForEvent('appcontextmenu-shown');
|
||||
|
||||
var container = system.appChromeContextMenuContainer;
|
||||
|
||||
// move focus to second one
|
||||
var menu = system.appChromeContextMenu;
|
||||
menu.sendKeys(Keys.esc);
|
||||
|
||||
system.waitForEvent('appcontextmenu-hidden');
|
||||
assert.isFalse(menu.displayed());
|
||||
assert.isFalse(container.displayed());
|
||||
});
|
||||
|
||||
});
|
||||
112
gaia/tv_apps/smart-system/test/marionette/lib/app_install.js
Executable file
112
gaia/tv_apps/smart-system/test/marionette/lib/app_install.js
Executable file
|
|
@ -0,0 +1,112 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* A Marionette test helper for app installation flow.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Marionette.Client} client Marionette client to use.
|
||||
*/
|
||||
function AppInstall(client) {
|
||||
this.client = client.scope({ searchTimeout: 200000 });
|
||||
}
|
||||
|
||||
module.exports = AppInstall;
|
||||
|
||||
AppInstall.prototype = {
|
||||
|
||||
_install: function(type, manifestURL) {
|
||||
this.client.executeScript(function install(type, url) {
|
||||
window.wrappedJSObject.navigator.mozApps[type](url);
|
||||
}, [type, manifestURL]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Install an app.
|
||||
* @param {string} manifestURL The manifestURL of the app to be installed.
|
||||
* @param {Object} [options] The options for installation.
|
||||
*/
|
||||
installPackage: function install(manifestURL) {
|
||||
return this._install('installPackage', manifestURL);
|
||||
},
|
||||
|
||||
/**
|
||||
* Install an app.
|
||||
* @param {string} manifestURL The manifestURL of the app to be installed.
|
||||
* @param {Object} [options] The options for installation.
|
||||
*/
|
||||
install: function install(manifestURL) {
|
||||
return this._install('install', manifestURL);
|
||||
},
|
||||
|
||||
/**
|
||||
* Uninstall an app.
|
||||
* @param {string} [manifestURL] The manifestURL of the app.
|
||||
*/
|
||||
uninstall: function(manifestURL) {
|
||||
this.client.switchToFrame();
|
||||
|
||||
this.client.executeAsyncScript(function uninstall(url) {
|
||||
var win = window.wrappedJSObject;
|
||||
var mgmt = win.navigator.mozApps.mgmt;
|
||||
|
||||
mgmt.getAll().onsuccess = function(e) {
|
||||
var app = e.target.result.find(function(app) {
|
||||
return app.manifestURL === url;
|
||||
});
|
||||
|
||||
mgmt.uninstall(app);
|
||||
marionetteScriptFinished();
|
||||
};
|
||||
}, [manifestURL]);
|
||||
},
|
||||
|
||||
/**
|
||||
Checks for downloads without applying them.
|
||||
*/
|
||||
stageUpdate: function(manifestURL) {
|
||||
// do it in chrome so we don't need to switch contexts...
|
||||
var client = this.client.scope({ context: 'chrome' });
|
||||
return client.executeAsyncScript(function(manifestURL) {
|
||||
navigator.mozApps.mgmt.getAll().onsuccess = function(e) {
|
||||
var list = e.target.result;
|
||||
var app = list.find(function(app) {
|
||||
return app.manifestURL === manifestURL;
|
||||
});
|
||||
var req = app.checkForUpdate();
|
||||
req.onsuccess = req.onerror = function() {
|
||||
marionetteScriptFinished();
|
||||
};
|
||||
};
|
||||
}, [manifestURL]);
|
||||
},
|
||||
|
||||
/**
|
||||
Updates an installed app by it's manifest url.
|
||||
|
||||
@param {String} manifestURL for the application.
|
||||
*/
|
||||
update: function(manifestURL) {
|
||||
// do it in chrome so we don't need to switch contexts...
|
||||
var client = this.client.scope({ context: 'chrome' });
|
||||
return client.executeAsyncScript(function(manifestURL) {
|
||||
navigator.mozApps.mgmt.getAll().onsuccess = function(e) {
|
||||
var list = e.target.result;
|
||||
var app = list.find(function(app) {
|
||||
return app.manifestURL === manifestURL;
|
||||
});
|
||||
|
||||
var req = app.checkForUpdate();
|
||||
req.onsuccess = function() {
|
||||
app.download();
|
||||
marionetteScriptFinished();
|
||||
};
|
||||
|
||||
req.onerror = function() {
|
||||
marionetteScriptFinished();
|
||||
};
|
||||
};
|
||||
}, [manifestURL]);
|
||||
}
|
||||
};
|
||||
136
gaia/tv_apps/smart-system/test/marionette/lib/app_modal_dialog.js
Executable file
136
gaia/tv_apps/smart-system/test/marionette/lib/app_modal_dialog.js
Executable file
|
|
@ -0,0 +1,136 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* A Marionette test helper for modal dialog flow.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Marionette.Client} client Marionette client to use.
|
||||
*/
|
||||
function ModalDialog(client) {
|
||||
this.client = client.scope({ searchTimeout: 200000 });
|
||||
this.client.helper = client.helper;
|
||||
}
|
||||
|
||||
module.exports = ModalDialog;
|
||||
|
||||
ModalDialog.Selector = Object.freeze({
|
||||
alert: {
|
||||
dialog: '.appWindow.active .smart-modal-dialog-container' +
|
||||
' .modal-dialog-opened',
|
||||
ok: '.appWindow.active .modal-dialog-opened' +
|
||||
' .modal-dialog-button-group smart-button:nth-child(1)',
|
||||
message: '.appWindow.active .modal-dialog-opened .modal-dialog-message'
|
||||
},
|
||||
prompt: {
|
||||
dialog: '.appWindow.active .smart-modal-dialog-container' +
|
||||
' .modal-dialog-opened',
|
||||
ok: '.appWindow.active .modal-dialog-opened' +
|
||||
' .modal-dialog-button-group smart-button:nth-child(2)',
|
||||
cancel: '.appWindow.active .modal-dialog-opened' +
|
||||
' .modal-dialog-button-group smart-button:nth-child(1)',
|
||||
message: '.appWindow.active .modal-dialog-opened .modal-dialog-message',
|
||||
input: '.appWindow.active .modal-dialog-opened' +
|
||||
' .modal-dialog-input-group input'
|
||||
},
|
||||
confirm: {
|
||||
dialog: '.appWindow.active .smart-modal-dialog-container' +
|
||||
' .modal-dialog-opened',
|
||||
ok: '.appWindow.active .modal-dialog-opened' +
|
||||
' .modal-dialog-button-group smart-button:nth-child(2)',
|
||||
cancel: '.appWindow.active' +
|
||||
' .modal-dialog-button-group smart-button:nth-child(1)',
|
||||
message: '.appWindow.active .modal-dialog-opened .modal-dialog-message'
|
||||
}
|
||||
});
|
||||
|
||||
ModalDialog.prototype = {
|
||||
|
||||
get alertDialog() {
|
||||
return this.client.findElement(ModalDialog.Selector.alert.dialog);
|
||||
},
|
||||
|
||||
get alertOk() {
|
||||
return this.client.findElement(ModalDialog.Selector.alert.ok);
|
||||
},
|
||||
|
||||
get alertMessage() {
|
||||
return this.client.findElement(ModalDialog.Selector.alert.message);
|
||||
},
|
||||
|
||||
get promptDialog() {
|
||||
return this.client.findElement(ModalDialog.Selector.prompt.dialog);
|
||||
},
|
||||
|
||||
get promptOk() {
|
||||
return this.client.findElement(ModalDialog.Selector.prompt.ok);
|
||||
},
|
||||
|
||||
get promptCancel() {
|
||||
return this.client.findElement(ModalDialog.Selector.prompt.cancel);
|
||||
},
|
||||
|
||||
get promptTitle() {
|
||||
return this.client.findElement(ModalDialog.Selector.prompt.title);
|
||||
},
|
||||
|
||||
get promptMessage() {
|
||||
return this.client.findElement(ModalDialog.Selector.prompt.message);
|
||||
},
|
||||
|
||||
get promptInput() {
|
||||
return this.client.findElement(ModalDialog.Selector.prompt.input);
|
||||
},
|
||||
|
||||
get confirmDialog() {
|
||||
return this.client.findElement(ModalDialog.Selector.confirm.dialog);
|
||||
},
|
||||
|
||||
get confirmOk() {
|
||||
return this.client.findElement(ModalDialog.Selector.confirm.ok);
|
||||
},
|
||||
|
||||
get confirmCancel() {
|
||||
return this.client.findElement(ModalDialog.Selector.confirm.cancel);
|
||||
},
|
||||
|
||||
get confirmMessage() {
|
||||
return this.client.findElement(ModalDialog.Selector.confirm.message);
|
||||
},
|
||||
|
||||
/**
|
||||
* Wait for the specified element to show and send key to it
|
||||
* @param {Marionette.Element} element The element to wait for.
|
||||
* @param {String} key The desired key to send to element.
|
||||
*/
|
||||
sendKeyToElement: function(element, key) {
|
||||
this.client.waitFor(function() {
|
||||
return element.displayed();
|
||||
}, function() {
|
||||
element.sendKeys(key);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Wait for the specified dialog to open.
|
||||
* @param {Marionette.Element} element The dialog element to wait for.
|
||||
*/
|
||||
waitForDialogOpened: function(element) {
|
||||
this.client.waitFor(function() {
|
||||
var dialogClass = element.getAttribute('class');
|
||||
return dialogClass.indexOf('visible') != -1;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Wait for the specified dialog to close.
|
||||
* @param {Marionette.Element} element The dialog element to wait for.
|
||||
*/
|
||||
waitForDialogClosed: function(element) {
|
||||
this.client.waitFor(function() {
|
||||
var dialogClass = element.getAttribute('class');
|
||||
return dialogClass.indexOf('visible') == -1;
|
||||
});
|
||||
}
|
||||
};
|
||||
116
gaia/tv_apps/smart-system/test/marionette/lib/system.js
Executable file
116
gaia/tv_apps/smart-system/test/marionette/lib/system.js
Executable file
|
|
@ -0,0 +1,116 @@
|
|||
'use strict';
|
||||
|
||||
function System(client) {
|
||||
this.client = client.scope({
|
||||
searchTimeout: 20000
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = System;
|
||||
|
||||
System.URL = 'app://smart-system.gaiamobile.org/manifest.webapp';
|
||||
|
||||
System.Selector = Object.freeze({
|
||||
appChromeContextMenuContainer: '.appWindow.active .modal-dialog',
|
||||
appChromeContextMenuDialog: '.appWindow.active .contextmenu .modal-dialog',
|
||||
appInstallCancelButton: '.app-install-dialog smart-button:nth-child(1)',
|
||||
appInstallInstallButton: '.app-install-dialog smart-button:nth-child(2)',
|
||||
appCancelInstallConfirmButton:
|
||||
'.app-install-cancel-dialog smart-button:nth-child(1)',
|
||||
appCanelInstallResumeButton:
|
||||
'.app-install-cancel-dialog smart-button:nth-child(2)',
|
||||
appUninstallCancelButton: '.app-uninstall-dialog smart-button:nth-child(1)',
|
||||
appUninstallConfirmButton: '.app-uninstall-dialog smart-button:nth-child(2)',
|
||||
appInstallSetupLaterButton: '.setup-app-dialog smart-button:nth-child(1)',
|
||||
appInstallSetupNowButton: '.setup-app-dialog smart-button:nth-child(2)'
|
||||
});
|
||||
|
||||
System.prototype = {
|
||||
client: null,
|
||||
|
||||
URL: System.URL,
|
||||
|
||||
Selector: System.Selector,
|
||||
|
||||
get appChromeContextMenuContainer() {
|
||||
return this.client.helper.waitForElement(
|
||||
System.Selector.appChromeContextMenuContainer);
|
||||
},
|
||||
|
||||
get appChromeContextMenu() {
|
||||
return this.client.helper.waitForElement(
|
||||
System.Selector.appChromeContextMenuDialog);
|
||||
},
|
||||
|
||||
getAppIframe: function(url) {
|
||||
return this.client.findElement('iframe[src*="' + url + '"]');
|
||||
},
|
||||
|
||||
getHomescreenIframe: function() {
|
||||
return this.client.findElement('#homescreen iframe');
|
||||
},
|
||||
|
||||
waitForLaunch: function(url) {
|
||||
this.client.apps.launch(url);
|
||||
var iframe = this.getAppIframe(url);
|
||||
this.client.waitFor(function() {
|
||||
return iframe.displayed();
|
||||
});
|
||||
|
||||
return iframe;
|
||||
},
|
||||
|
||||
waitForEvent: function(evt) {
|
||||
this.client.switchToFrame();
|
||||
this.client.executeAsyncScript(function(evt) {
|
||||
var win = window.wrappedJSObject;
|
||||
win.addEventListener(evt, function trWait() {
|
||||
win.removeEventListener(evt, trWait);
|
||||
marionetteScriptFinished();
|
||||
});
|
||||
}, [evt]);
|
||||
},
|
||||
|
||||
_waitForAppState: function(manifestURL, installed) {
|
||||
this.client.waitFor(function() {
|
||||
return this.client.executeScript(function(manifestURL, installed) {
|
||||
var apps = window.wrappedJSObject.applications;
|
||||
var hasApp = !!apps.installedApps[manifestURL];
|
||||
return hasApp === installed;
|
||||
}, [manifestURL, installed]);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
waitForAppInstalled: function(manifestURL) {
|
||||
return this._waitForAppState(manifestURL, true);
|
||||
},
|
||||
|
||||
waitForAppUninstalled: function(manifestURL) {
|
||||
return this._waitForAppState(manifestURL, false);
|
||||
},
|
||||
|
||||
isAppInstalled: function(manifestURL) {
|
||||
return this.client.executeScript(function(manifestURL) {
|
||||
return !!window.wrappedJSObject.applications.installedApps[manifestURL];
|
||||
}, [manifestURL]);
|
||||
},
|
||||
|
||||
goHome: function() {
|
||||
this.client.switchToFrame();
|
||||
this.client.executeAsyncScript(function() {
|
||||
var win = window.wrappedJSObject;
|
||||
win.addEventListener('homescreenopened', function trWait() {
|
||||
win.removeEventListener('homescreenopened', trWait);
|
||||
marionetteScriptFinished();
|
||||
});
|
||||
win.dispatchEvent(new CustomEvent('home'));
|
||||
});
|
||||
},
|
||||
|
||||
tapHome: function() {
|
||||
this.client.switchToFrame();
|
||||
this.client.executeScript(function() {
|
||||
window.wrappedJSObject.dispatchEvent(new CustomEvent('home'));
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Reference in a new issue