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
166
gaia/apps/system/test/marionette/lib/bookmark.js
Executable file
166
gaia/apps/system/test/marionette/lib/bookmark.js
Executable file
|
|
@ -0,0 +1,166 @@
|
|||
'use strict';
|
||||
/* global module */
|
||||
|
||||
var Rocketbar = require('./rocketbar');
|
||||
|
||||
function Bookmark(client) {
|
||||
this.client = client;
|
||||
this.rocketbar = new Rocketbar(client);
|
||||
this.search = client.loader.getAppClass('search');
|
||||
this.system = client.loader.getAppClass('system');
|
||||
}
|
||||
|
||||
Bookmark.URL = 'app://bookmark.gaiamobile.org';
|
||||
|
||||
Bookmark.prototype = {
|
||||
|
||||
URL: Bookmark.URL,
|
||||
Selectors: {
|
||||
'bookmarkAddButton': '#done-button',
|
||||
'bookmarkTitle': '#bookmark-title',
|
||||
'mozbrowser': '.inline-activity.active iframe[mozbrowser]',
|
||||
'appInstallationSection': '#app-installation',
|
||||
'installAppButton': '#install-app-button',
|
||||
'appName': '#app-name',
|
||||
'appIcon': '#app-icon',
|
||||
'removeButton': '#remove-action'
|
||||
},
|
||||
|
||||
get addButton() {
|
||||
return this.client.helper.waitForElement(
|
||||
this.Selectors.bookmarkAddButton);
|
||||
},
|
||||
|
||||
get currentTabFrame() {
|
||||
return this.client.helper.waitForElement(
|
||||
this.Selectors.mozbrowser);
|
||||
},
|
||||
|
||||
get bookmarkTitle() {
|
||||
return this.client.helper.waitForElement(
|
||||
this.Selectors.bookmarkTitle);
|
||||
},
|
||||
|
||||
get installAppButton() {
|
||||
return this.client.helper.waitForElement(
|
||||
this.Selectors.installAppButton);
|
||||
},
|
||||
|
||||
get appName() {
|
||||
return this.client.helper.waitForElement(
|
||||
this.Selectors.appName);
|
||||
},
|
||||
|
||||
get appIcon() {
|
||||
return this.client.helper.waitForElement(
|
||||
this.Selectors.appIcon);
|
||||
},
|
||||
|
||||
get removeButton() {
|
||||
return this.client.helper.waitForElement(
|
||||
this.Selectors.removeButton);
|
||||
},
|
||||
|
||||
/**
|
||||
* Switches to the bookmark activity and adds the current bookmark.
|
||||
* Switches back to the system app upon completion.
|
||||
*/
|
||||
add: function() {
|
||||
this.client.switchToFrame(this.currentTabFrame);
|
||||
|
||||
var selectors = this.Selectors;
|
||||
var client = this.client.scope({ searchTimeout: 100 });
|
||||
client.waitFor(function() {
|
||||
try {
|
||||
var text = client.findElement(selectors.bookmarkTitle).scriptWith(
|
||||
function(el) { return el.value; });
|
||||
return text.length > 0;
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
}.bind(this));
|
||||
this.addButton.click();
|
||||
|
||||
this.client.switchToFrame();
|
||||
this.client.helper.waitForElementToDisappear(this.currentTabFrame);
|
||||
},
|
||||
|
||||
/**
|
||||
* Navigates to a given url from the homescreen
|
||||
* and saves it as a bookmark.
|
||||
*/
|
||||
openAndSave: function(url) {
|
||||
this.rocketbar.homescreenFocus();
|
||||
this.rocketbar.enterText(url, true);
|
||||
|
||||
this.client.waitFor(function() {
|
||||
this.client.switchToFrame();
|
||||
try {
|
||||
this.client.findElement(
|
||||
this.system.Selector.appChromeContextLink).tap();
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}.bind(this));
|
||||
this.system.appChromeContextMenuBookmark.click();
|
||||
|
||||
this.add();
|
||||
},
|
||||
|
||||
/**
|
||||
* Navigates to a given url from the homescreen
|
||||
* and currently just looks for install section with correct app name.
|
||||
*/
|
||||
openAndInstall: function(url, name, iconURL) {
|
||||
this.rocketbar.homescreenFocus();
|
||||
this.rocketbar.enterText(url, true);
|
||||
|
||||
this.client.waitFor(function() {
|
||||
this.client.switchToFrame();
|
||||
try {
|
||||
this.client.findElement(
|
||||
this.system.Selector.appChromeContextLink).tap();
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}.bind(this));
|
||||
this.system.appChromeContextMenuBookmark.click();
|
||||
|
||||
this.client.switchToFrame(this.currentTabFrame);
|
||||
this.client.waitFor((function() {
|
||||
console.log('BTF ' + this.appIcon.getAttribute('src'));
|
||||
return this.appName.text() == name &&
|
||||
this.appIcon.displayed &&
|
||||
this.appIcon.getAttribute('src').indexOf(iconURL) != -1;
|
||||
}).bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Renames a bookmark and emulates pressing the 'enter' key after doing so.
|
||||
*/
|
||||
renameAndPressEnter: function(newName) {
|
||||
this.client.switchToFrame(this.currentTabFrame);
|
||||
this.bookmarkTitle.clear();
|
||||
this.bookmarkTitle.sendKeys(newName);
|
||||
this.addButton.click();
|
||||
|
||||
this.client.switchToFrame();
|
||||
this.client.helper.waitForElementToDisappear(this.currentTabFrame);
|
||||
},
|
||||
|
||||
/**
|
||||
* Perform action on a pin confirm dialog.
|
||||
*
|
||||
* @param {String} action The action to perform on the pin confirm dialog.
|
||||
*/
|
||||
pinConfirmDialog: function(action) {
|
||||
var selector = 'form[data-type="confirm"]';
|
||||
var dialog = this.client.helper.waitForElement(selector);
|
||||
var actionButton = dialog.findElement('#' + action + '-action');
|
||||
actionButton.tap();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Bookmark;
|
||||
Loading…
Reference in a new issue