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
19
gaia/apps/search/test/marionette/.jshintrc
Executable file
19
gaia/apps/search/test/marionette/.jshintrc
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"extends": "../../../../.jshintrc",
|
||||
"predef": [
|
||||
"__dirname",
|
||||
"module",
|
||||
"suite",
|
||||
"test",
|
||||
"setup",
|
||||
"teardown",
|
||||
"suiteSetup",
|
||||
"suiteTeardown",
|
||||
"marionette",
|
||||
"marionetteScriptFinished",
|
||||
"require",
|
||||
"define",
|
||||
"requireApp",
|
||||
"sinon"
|
||||
]
|
||||
}
|
||||
74
gaia/apps/search/test/marionette/app_installed_test.js
Executable file
74
gaia/apps/search/test/marionette/app_installed_test.js
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
'use strict';
|
||||
|
||||
var AppInstall =
|
||||
require('../../../../apps/system/test/marionette/lib/app_install');
|
||||
var Rocketbar =
|
||||
require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
var createAppServer =
|
||||
require('../../../homescreen/test/marionette/server/parent');
|
||||
|
||||
marionette('Search - Installed Apps Test', function() {
|
||||
var clientOptions = require(__dirname + '/client_options.js');
|
||||
var client = marionette.client({
|
||||
profile: clientOptions,
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var appInstall, home, rocketbar, search, server, system;
|
||||
|
||||
setup(function(done) {
|
||||
appInstall = new AppInstall(client);
|
||||
home = client.loader.getAppClass('homescreen');
|
||||
system = client.loader.getAppClass('system');
|
||||
search = client.loader.getAppClass('search');
|
||||
rocketbar = new Rocketbar(client);
|
||||
system.waitForFullyLoaded();
|
||||
|
||||
var app = __dirname + '/fixtures/installed_app';
|
||||
createAppServer(app, client, function(err, _server) {
|
||||
server = _server;
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
test('app result after install/uninstall', function() {
|
||||
home.waitForLaunch();
|
||||
rocketbar.homescreenFocus();
|
||||
rocketbar.enterText('Calendar');
|
||||
search.goToResults();
|
||||
|
||||
// Should only have the 'stock' calendar app.
|
||||
client.waitFor(function() {
|
||||
return search.countGridResults() === 1;
|
||||
});
|
||||
|
||||
// Exit rocketbar and install the app.
|
||||
client.switchToFrame();
|
||||
system.tapHome();
|
||||
appInstall.installPackage(server.packageManifestURL);
|
||||
|
||||
// Search again for the same term.
|
||||
rocketbar.appTitleFocus();
|
||||
rocketbar.enterText('Calendar');
|
||||
search.goToResults();
|
||||
|
||||
// Should now contain the newly installed app as well.
|
||||
client.waitFor(function() {
|
||||
return search.countGridResults() === 2;
|
||||
});
|
||||
|
||||
// Remove the installed app.
|
||||
client.switchToFrame();
|
||||
system.tapHome();
|
||||
appInstall.uninstall(server.packageManifestURL);
|
||||
home.confirmDialog('remove');
|
||||
|
||||
// Should now contain only a single app.
|
||||
rocketbar.appTitleFocus();
|
||||
rocketbar.enterText('Calendar');
|
||||
search.goToResults();
|
||||
client.waitFor(function() {
|
||||
return search.countGridResults() === 1;
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
48
gaia/apps/search/test/marionette/app_search_test.js
Executable file
48
gaia/apps/search/test/marionette/app_search_test.js
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
'use strict';
|
||||
|
||||
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
|
||||
marionette('Search - App search', function() {
|
||||
var profile = require(__dirname + '/client_options.js');
|
||||
// Causing a crash in this test, so disable apz.
|
||||
profile.prefs = {
|
||||
'layers.async-pan-zoom.enabled': false
|
||||
};
|
||||
var client = marionette.client({
|
||||
profile: profile,
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var home, search, rocketbar, system;
|
||||
|
||||
setup(function() {
|
||||
home = client.loader.getAppClass('homescreen');
|
||||
system = client.loader.getAppClass('system');
|
||||
search = client.loader.getAppClass('search');
|
||||
rocketbar = new Rocketbar(client);
|
||||
system.waitForFullyLoaded();
|
||||
});
|
||||
|
||||
test('Search apps from Rocketbar', function() {
|
||||
home.waitForLaunch();
|
||||
rocketbar.homescreenFocus();
|
||||
rocketbar.enterText('calendar');
|
||||
search.goToResults();
|
||||
var calendarIdentifier = 'app://calendar.gaiamobile.org/manifest.webapp';
|
||||
var result = search.checkResult(calendarIdentifier, 'Calendar');
|
||||
result.tap();
|
||||
search.goToApp('app://calendar.gaiamobile.org');
|
||||
});
|
||||
|
||||
test('Search for app with entry point', function() {
|
||||
home.waitForLaunch();
|
||||
rocketbar.homescreenFocus();
|
||||
rocketbar.enterText('Phone');
|
||||
search.goToResults();
|
||||
var phoneIdentifier =
|
||||
'app://communications.gaiamobile.org/manifest.webapp-dialer';
|
||||
var result = search.checkResult(phoneIdentifier, 'Phone');
|
||||
result.tap();
|
||||
search.goToApp('app://communications.gaiamobile.org', 'dialer');
|
||||
});
|
||||
|
||||
});
|
||||
95
gaia/apps/search/test/marionette/browser_test.js
Executable file
95
gaia/apps/search/test/marionette/browser_test.js
Executable file
|
|
@ -0,0 +1,95 @@
|
|||
'use strict';
|
||||
|
||||
var Server = require('../../../../shared/test/integration/server');
|
||||
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
|
||||
var assert = require('chai').assert;
|
||||
|
||||
marionette('Browser test', function() {
|
||||
|
||||
var client = marionette.client({
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var search, system, server, home, rocketbar;
|
||||
|
||||
suiteSetup(function(done) {
|
||||
Server.create(__dirname + '/fixtures/', function(err, _server) {
|
||||
server = _server;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
suiteTeardown(function() {
|
||||
server.stop();
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
home = client.loader.getAppClass('verticalhome');
|
||||
search = client.loader.getAppClass('search');
|
||||
system = client.loader.getAppClass('system');
|
||||
rocketbar = new Rocketbar(client);
|
||||
system.waitForFullyLoaded();
|
||||
});
|
||||
|
||||
test('Test title injecting html', function() {
|
||||
var url = server.url('xsstitle.html');
|
||||
rocketbar.goToURL(url);
|
||||
client.helper.wait(1500);
|
||||
system.closeBrowserByUrl(url);
|
||||
|
||||
// Open browser app.
|
||||
client.apps.launch(search.URL);
|
||||
client.apps.switchToApp(search.URL);
|
||||
|
||||
client.waitFor(function() {
|
||||
return search.getHistoryResults().length === 1;
|
||||
});
|
||||
|
||||
var title = client.executeScript(function() {
|
||||
return document.querySelector('#history .title').innerHTML;
|
||||
});
|
||||
|
||||
assert.equal(title, '<em>test</em>');
|
||||
});
|
||||
|
||||
test('Large Icon', function() {
|
||||
var url = server.url('largeicon.html');
|
||||
rocketbar.goToURL(url);
|
||||
client.helper.wait(500);
|
||||
system.closeBrowserByUrl(url);
|
||||
|
||||
// Open browser app.
|
||||
client.apps.launch(search.URL);
|
||||
client.apps.switchToApp(search.URL);
|
||||
|
||||
client.waitFor(function() {
|
||||
return search.getHistoryResults().length === 1;
|
||||
});
|
||||
|
||||
var width = client.executeScript(function() {
|
||||
var icon = document.querySelector('#history .icon');
|
||||
return icon.clientWidth;
|
||||
});
|
||||
|
||||
assert.equal(width, 16);
|
||||
});
|
||||
|
||||
test('Ensure fallback to url when no place title', function() {
|
||||
var url = server.url('notitle.html');
|
||||
rocketbar.goToURL(url);
|
||||
client.helper.wait(500);
|
||||
system.closeBrowserByUrl(url);
|
||||
|
||||
// Open browser app.
|
||||
client.apps.launch(search.URL);
|
||||
client.apps.switchToApp(search.URL);
|
||||
|
||||
client.waitFor(function() {
|
||||
return search.getTopSites().length === 1;
|
||||
});
|
||||
|
||||
var topSite = search.getTopSites()[0];
|
||||
|
||||
assert.equal(topSite.text(), url);
|
||||
});
|
||||
});
|
||||
74
gaia/apps/search/test/marionette/change_providers_test.js
Executable file
74
gaia/apps/search/test/marionette/change_providers_test.js
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
'use strict';
|
||||
|
||||
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
var Server = require('../../../../shared/test/integration/server');
|
||||
|
||||
marionette('Search - Switch Providers Test', function() {
|
||||
|
||||
var client = marionette.client({
|
||||
profile: require(__dirname + '/client_options.js'),
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var home, search, rocketbar, system, server;
|
||||
|
||||
var providers;
|
||||
|
||||
suiteSetup(function(done) {
|
||||
Server.create(__dirname + '/fixtures/', function(err, _server) {
|
||||
server = _server;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
home = client.loader.getAppClass('homescreen');
|
||||
system = client.loader.getAppClass('system');
|
||||
search = client.loader.getAppClass('search');
|
||||
rocketbar = new Rocketbar(client);
|
||||
system.waitForFullyLoaded();
|
||||
|
||||
providers = {
|
||||
version: search.searchDataVersion(),
|
||||
providers: {
|
||||
'first': {
|
||||
title: 'first',
|
||||
searchUrl: server.url('sample.html'),
|
||||
suggestUrl: server.url('suggestions_one.json')
|
||||
},
|
||||
'second': {
|
||||
title: 'second',
|
||||
searchUrl: server.url('sample.html'),
|
||||
suggestUrl: server.url('suggestions_two.json')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
client.settings.set('search.suggestions.enabled', true);
|
||||
client.settings.set('search.cache', providers);
|
||||
client.settings.set('search.provider', 'first');
|
||||
});
|
||||
|
||||
test('Test switching suggestion provider', function() {
|
||||
|
||||
home.waitForLaunch();
|
||||
|
||||
rocketbar.homescreenFocus();
|
||||
search.triggerFirstRun(rocketbar);
|
||||
|
||||
rocketbar.enterText('sometext');
|
||||
search.goToResults();
|
||||
client.waitFor(function() {
|
||||
return client.findElements(search.Selectors.suggestions).length === 2;
|
||||
});
|
||||
|
||||
var select = search.switchProvidersSelect;
|
||||
client.helper.tapSelectOption(select, 'second');
|
||||
|
||||
client.switchToFrame();
|
||||
search.goToResults();
|
||||
client.waitFor(function() {
|
||||
return client.findElements(search.Selectors.suggestions).length === 3;
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
6
gaia/apps/search/test/marionette/client_options.js
Executable file
6
gaia/apps/search/test/marionette/client_options.js
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
settings: {
|
||||
'devtools.pseudolocalization.enabled': false,
|
||||
'language.current': 'en-US'
|
||||
}
|
||||
};
|
||||
43
gaia/apps/search/test/marionette/contacts_search_test.js
Executable file
43
gaia/apps/search/test/marionette/contacts_search_test.js
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
'use strict';
|
||||
|
||||
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
var Contacts = require(
|
||||
'../../../communications/contacts/test/marionette/lib/contacts');
|
||||
var assert = require('assert');
|
||||
|
||||
marionette('Search - Contact search', function() {
|
||||
var client = marionette.client();
|
||||
|
||||
var contacts, search, rocketbar;
|
||||
|
||||
setup(function() {
|
||||
rocketbar = new Rocketbar(client);
|
||||
contacts = new Contacts(client);
|
||||
search = client.loader.getAppClass('search');
|
||||
});
|
||||
|
||||
test.skip('able to search contact from rocketbar', function() {
|
||||
var contactTel = 1231231234;
|
||||
contacts.launch();
|
||||
contacts.addContact({
|
||||
givenName: 'HelloWorld',
|
||||
tel: contactTel
|
||||
});
|
||||
client.apps.close(Contacts.URL, 'contacts');
|
||||
|
||||
client.switchToFrame();
|
||||
|
||||
search.doSearch('HelloWorld');
|
||||
|
||||
search.goToResults();
|
||||
|
||||
search.checkResult('firstContact', 'HelloWorld');
|
||||
|
||||
search.goToApp(Contacts.URL, 'contacts');
|
||||
|
||||
var firstTel = client.helper
|
||||
.waitForElement(Contacts.Selectors.detailsTelButtonFirst);
|
||||
assert.equal(firstTel.text(), contactTel);
|
||||
});
|
||||
|
||||
});
|
||||
13
gaia/apps/search/test/marionette/fixtures/favicon.html
Executable file
13
gaia/apps/search/test/marionette/fixtures/favicon.html
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="shortcut icon"
|
||||
href="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
|
||||
<title>Sample page</title>
|
||||
</head>
|
||||
<body>
|
||||
<header><h1>Mozilla</h1></header>
|
||||
<section>We are global community with a common purpose</section>
|
||||
</body>
|
||||
</html>
|
||||
10
gaia/apps/search/test/marionette/fixtures/installed_app/index.html
Executable file
10
gaia/apps/search/test/marionette/fixtures/installed_app/index.html
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title>iwrotethis</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="test-app"></div>
|
||||
</body>
|
||||
</html>
|
||||
15
gaia/apps/search/test/marionette/fixtures/installed_app/manifest.webapp
Executable file
15
gaia/apps/search/test/marionette/fixtures/installed_app/manifest.webapp
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "Calendar2",
|
||||
"description": "Just a dummy app for testing what happens when we install something.",
|
||||
"launch_path": "/index.html",
|
||||
"developer": {
|
||||
"name": "The Gaia Team",
|
||||
"url": "https://github.com/mozilla-b2g/gaia"
|
||||
},
|
||||
"locales": {},
|
||||
"default_locale": "en-US",
|
||||
"icons": {
|
||||
"128": "/style/icons/Blank.png"
|
||||
}
|
||||
}
|
||||
|
||||
BIN
gaia/apps/search/test/marionette/fixtures/installed_app/style/icons/Blank.png
Executable file
BIN
gaia/apps/search/test/marionette/fixtures/installed_app/style/icons/Blank.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
10
gaia/apps/search/test/marionette/fixtures/notitle.html
Executable file
10
gaia/apps/search/test/marionette/fixtures/notitle.html
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<header><h1>Mozilla</h1></header>
|
||||
<section>We are global community with a common purpose</section>
|
||||
</body>
|
||||
</html>
|
||||
11
gaia/apps/search/test/marionette/fixtures/sample.html
Executable file
11
gaia/apps/search/test/marionette/fixtures/sample.html
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Sample page</title>
|
||||
</head>
|
||||
<body>
|
||||
<header><h1>Mozilla</h1></header>
|
||||
<section>We are global community with a common purpose</section>
|
||||
</body>
|
||||
</html>
|
||||
1
gaia/apps/search/test/marionette/fixtures/suggestions_one.json
Executable file
1
gaia/apps/search/test/marionette/fixtures/suggestions_one.json
Executable file
|
|
@ -0,0 +1 @@
|
|||
["foo", ["bar"]]
|
||||
1
gaia/apps/search/test/marionette/fixtures/suggestions_two.json
Executable file
1
gaia/apps/search/test/marionette/fixtures/suggestions_two.json
Executable file
|
|
@ -0,0 +1 @@
|
|||
["foo", ["bar", "baz"]]
|
||||
11
gaia/apps/search/test/marionette/fixtures/xsstitle.html
Executable file
11
gaia/apps/search/test/marionette/fixtures/xsstitle.html
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><em>test</em></title>
|
||||
</head>
|
||||
<body>
|
||||
<header><h1>Mozilla</h1></header>
|
||||
<section>We are global community with a common purpose</section>
|
||||
</body>
|
||||
</html>
|
||||
39
gaia/apps/search/test/marionette/home_button_test.js
Executable file
39
gaia/apps/search/test/marionette/home_button_test.js
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
|
||||
marionette('Search - Home Button Press', function() {
|
||||
var client = marionette.client({
|
||||
profile: require(__dirname + '/client_options.js'),
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var home, search, rocketbar, system;
|
||||
|
||||
setup(function() {
|
||||
home = client.loader.getAppClass('homescreen');
|
||||
system = client.loader.getAppClass('system');
|
||||
search = client.loader.getAppClass('search');
|
||||
rocketbar = new Rocketbar(client);
|
||||
system.waitForFullyLoaded();
|
||||
});
|
||||
|
||||
test('Home button returns to home screen', function() {
|
||||
home.waitForLaunch();
|
||||
rocketbar.homescreenFocus();
|
||||
rocketbar.enterText('calendar');
|
||||
|
||||
// Ensure search results are displayed.
|
||||
search.goToResults();
|
||||
var calendarIdentifier = 'app://calendar.gaiamobile.org/manifest.webapp';
|
||||
search.checkResult(calendarIdentifier, 'Calendar');
|
||||
|
||||
// Emulate the home button and ensure the home screen is displayed.
|
||||
client.switchToFrame();
|
||||
assert.ok(client.findElement(search.Selectors.iframe).displayed());
|
||||
system.tapHome();
|
||||
client.waitFor(function(){
|
||||
return !client.findElement(search.Selectors.iframe).displayed();
|
||||
});
|
||||
});
|
||||
});
|
||||
164
gaia/apps/search/test/marionette/lib/search.js
Executable file
164
gaia/apps/search/test/marionette/lib/search.js
Executable file
|
|
@ -0,0 +1,164 @@
|
|||
'use strict';
|
||||
/* global module */
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
var PROVIDERS_VERSION = 3;
|
||||
/**
|
||||
* Abstraction around search app.
|
||||
* @constructor
|
||||
*/
|
||||
function Search(client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type String Origin of search app
|
||||
*/
|
||||
Search.URL = 'app://search.gaiamobile.org';
|
||||
|
||||
Search.Selectors = {
|
||||
allGridResults: 'gaia-grid .icon',
|
||||
iframe: 'iframe[mozapptype="search"]',
|
||||
firstAppContainer: 'gaia-grid',
|
||||
firstApp: 'gaia-grid .icon',
|
||||
firstContact: '#contacts div',
|
||||
firstContactContainer: '#contacts',
|
||||
firstPlace: '#places div .title',
|
||||
firstPlaceContainer: '#places',
|
||||
firstRunConfirm: '#suggestions-notice-confirm',
|
||||
privateWindow: '#private-window',
|
||||
topSites: '.top-site',
|
||||
topSitesHeader: '#top-sites-header',
|
||||
historyResults: '#history .result',
|
||||
suggestions: '#suggestions li',
|
||||
switchProviders: '#suggestions-select',
|
||||
privateDialog: '#private-window-dialog',
|
||||
privateDialogClose: '#private-window-hide-dialog',
|
||||
privateDialogCheckbox: '#private-window-dialog gaia-checkbox'
|
||||
};
|
||||
|
||||
Search.prototype = {
|
||||
|
||||
URL: Search.URL,
|
||||
NEW_TAB_URL: Search.URL + '/newtab.html',
|
||||
Selectors: Search.Selectors,
|
||||
|
||||
privateBrowserUrl: 'app://search.gaiamobile.org/newtab.html?private=1',
|
||||
nonPrivateBrowserUrl: 'app://search.gaiamobile.org/newtab.html?private=0',
|
||||
|
||||
/**
|
||||
* Navigates to the search results frame.
|
||||
*/
|
||||
goToResults: function() {
|
||||
var frameSelector = Search.Selectors.iframe;
|
||||
var iframe = this.client.helper.waitForElement(frameSelector);
|
||||
this.client.helper.waitForElement(iframe);
|
||||
this.client.switchToFrame(iframe);
|
||||
this.client.helper.waitForElement('body');
|
||||
},
|
||||
|
||||
/**
|
||||
* Return selector for the grid item with a n identifier
|
||||
*/
|
||||
getResultSelector: function(identifier) {
|
||||
return '.icon[data-identifier="' + identifier + '"]';
|
||||
},
|
||||
|
||||
/**
|
||||
* Return selector for the history list item by URL
|
||||
*/
|
||||
getHistoryResultSelector: function(url) {
|
||||
return '.result[data-url="' + url + '"]';
|
||||
},
|
||||
|
||||
/**
|
||||
* Return grid results for a particular identifier
|
||||
*/
|
||||
getResult: function(identifier) {
|
||||
var selector = '.icon[data-identifier="' + identifier + '"]';
|
||||
return this.client.findElements(selector);
|
||||
},
|
||||
|
||||
getHistoryResults: function() {
|
||||
return this.client.findElements(Search.Selectors.historyResults);
|
||||
},
|
||||
|
||||
getTopSites: function() {
|
||||
return this.client.findElements(Search.Selectors.topSites);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks that we have a result for a given app in the results list.
|
||||
*/
|
||||
checkResult: function(identifier, expected) {
|
||||
var selectors = Search.Selectors;
|
||||
var selector = '.icon[data-identifier*="' + identifier + '"]';
|
||||
|
||||
this.client.helper.waitForElement(selectors.firstAppContainer);
|
||||
var result = this.client.helper.waitForElement(selector);
|
||||
assert.equal(expected, result.text());
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Counts all grid search results.
|
||||
*/
|
||||
countGridResults: function() {
|
||||
return this.client.findElements(Search.Selectors.allGridResults).length;
|
||||
},
|
||||
|
||||
/**
|
||||
* On first run a warning is shown to users on Search app configuration
|
||||
* trigger this notice and confirm it.
|
||||
*/
|
||||
triggerFirstRun: function(rocketbar) {
|
||||
rocketbar.enterText('a');
|
||||
this.goToResults();
|
||||
|
||||
this.client.executeScript(function() {
|
||||
window.wrappedJSObject.Search.toShowNotice = false;
|
||||
});
|
||||
|
||||
this.client.switchToFrame();
|
||||
rocketbar.enterText('');
|
||||
},
|
||||
|
||||
/**
|
||||
* Navigates to a specific app/entry point
|
||||
* Waits for the body to be loaded
|
||||
*/
|
||||
goToApp: function() {
|
||||
this.client.switchToFrame();
|
||||
this.client.apps.switchToApp.apply(this.client.apps, arguments);
|
||||
this.client.helper.waitForElement('body');
|
||||
},
|
||||
|
||||
searchDataVersion: function() {
|
||||
return PROVIDERS_VERSION;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets a reference to the provider select using findElement.
|
||||
* This waits for the element to be available, but not visible on the apge.
|
||||
*/
|
||||
get switchProvidersSelect() {
|
||||
// Fail finding elements quickly.
|
||||
var quickly = this.client.scope({
|
||||
searchTimeout: 20
|
||||
});
|
||||
|
||||
var element;
|
||||
|
||||
try {
|
||||
element = quickly.findElement(Search.Selectors.switchProviders);
|
||||
} catch(e) {
|
||||
return this.switchProvidersSelect;
|
||||
}
|
||||
|
||||
return element;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
module.exports = Search;
|
||||
86
gaia/apps/search/test/marionette/notice_test.js
Executable file
86
gaia/apps/search/test/marionette/notice_test.js
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
var Server = require('../../../../shared/test/integration/server');
|
||||
|
||||
marionette('Search - Notice Test', function() {
|
||||
|
||||
var client = marionette.client({
|
||||
profile: require(__dirname + '/client_options.js'),
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var home, search, rocketbar, system, server;
|
||||
|
||||
var providers;
|
||||
|
||||
suiteSetup(function(done) {
|
||||
Server.create(__dirname + '/fixtures/', function(err, _server) {
|
||||
server = _server;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
home = client.loader.getAppClass('homescreen');
|
||||
system = client.loader.getAppClass('system');
|
||||
search = client.loader.getAppClass('search');
|
||||
rocketbar = new Rocketbar(client);
|
||||
system.waitForFullyLoaded();
|
||||
|
||||
providers = {
|
||||
version: search.searchDataVersion(),
|
||||
providers: {
|
||||
'first': {
|
||||
title: 'first',
|
||||
searchUrl: server.url('sample.html'),
|
||||
suggestUrl: server.url('suggestions_one.json')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
client.settings.set('search.suggestions.enabled', true);
|
||||
client.settings.set('search.cache', providers);
|
||||
client.settings.set('search.provider', 'first');
|
||||
});
|
||||
|
||||
test('Search Notice', function() {
|
||||
|
||||
home.waitForLaunch();
|
||||
rocketbar.homescreenFocus();
|
||||
|
||||
var confirmSelector = search.Selectors.firstRunConfirm;
|
||||
// Notice should not be displayed if we type < 3 characters
|
||||
rocketbar.enterText('ab');
|
||||
rocketbar.enterText('cd');
|
||||
search.goToResults();
|
||||
assert.ok(!client.findElement(confirmSelector).displayed());
|
||||
|
||||
// Should not show notice if suggestions are disabled
|
||||
client.settings.set('search.suggestions.enabled', false);
|
||||
client.switchToFrame();
|
||||
rocketbar.enterText('abc');
|
||||
search.goToResults();
|
||||
client.helper.waitForElementToDisappear(confirmSelector);
|
||||
|
||||
// Notice should be displayed if we show > 3 characters
|
||||
client.settings.set('search.suggestions.enabled', true);
|
||||
client.switchToFrame();
|
||||
rocketbar.enterText('abc');
|
||||
search.goToResults();
|
||||
client.helper.waitForElement(confirmSelector);
|
||||
|
||||
// Notice should be dismissed if we press enter
|
||||
client.switchToFrame();
|
||||
var searchText = 'abc';
|
||||
rocketbar.enterText(searchText, true);
|
||||
rocketbar.switchToSearchFrame(server.url('sample.html'), searchText);
|
||||
client.switchToFrame();
|
||||
home.pressHomeButton();
|
||||
rocketbar.homescreenFocus();
|
||||
search.goToResults();
|
||||
assert.ok(!client.findElement(confirmSelector).displayed());
|
||||
});
|
||||
|
||||
});
|
||||
130
gaia/apps/search/test/marionette/places_search_test.js
Executable file
130
gaia/apps/search/test/marionette/places_search_test.js
Executable file
|
|
@ -0,0 +1,130 @@
|
|||
'use strict';
|
||||
|
||||
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
var Server = require('../../../../shared/test/integration/server');
|
||||
var assert = require('assert');
|
||||
|
||||
marionette('Places tests', function() {
|
||||
|
||||
var client = marionette.client({
|
||||
profile: require(__dirname + '/client_options.js'),
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var home, search, server, rocketbar, system;
|
||||
|
||||
suiteSetup(function(done) {
|
||||
Server.create(__dirname + '/fixtures/', function(err, _server) {
|
||||
server = _server;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
suiteTeardown(function() {
|
||||
server.stop();
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
home = client.loader.getAppClass('verticalhome');
|
||||
search = client.loader.getAppClass('search');
|
||||
rocketbar = new Rocketbar(client);
|
||||
system = client.loader.getAppClass('system');
|
||||
system.waitForFullyLoaded();
|
||||
});
|
||||
|
||||
test('Test url searching', function() {
|
||||
|
||||
var url = server.url('sample.html');
|
||||
var url2 = server.url('favicon.html');
|
||||
|
||||
// Lauch the rocketbar and trigger its first run notice
|
||||
home.waitForLaunch();
|
||||
home.focusRocketBar();
|
||||
search.triggerFirstRun(rocketbar);
|
||||
|
||||
// Input a url and press enter to visit
|
||||
rocketbar.enterText(url + '\uE006');
|
||||
rocketbar.switchToBrowserFrame(url);
|
||||
|
||||
// Go home
|
||||
client.switchToFrame();
|
||||
home.pressHomeButton();
|
||||
client.apps.switchToApp(home.URL);
|
||||
|
||||
// Redo search for url
|
||||
home.focusRocketBar();
|
||||
rocketbar.enterText(url);
|
||||
search.goToResults();
|
||||
var id = search.getHistoryResultSelector(url);
|
||||
var result = client.helper.waitForElement(id);
|
||||
|
||||
// Click result and check app loads
|
||||
result.click();
|
||||
client.switchToFrame();
|
||||
rocketbar.switchToBrowserFrame(url);
|
||||
|
||||
// Go home
|
||||
client.switchToFrame();
|
||||
home.pressHomeButton();
|
||||
client.apps.switchToApp(home.URL);
|
||||
|
||||
// Input a different url and press enter to visit
|
||||
home.focusRocketBar();
|
||||
rocketbar.enterText(url2 + '\uE006');
|
||||
rocketbar.switchToBrowserFrame(url2);
|
||||
});
|
||||
|
||||
test.skip('Search for a string that doesnt match visited url', function() {
|
||||
var url = server.url('sample.html');
|
||||
search.triggerFirstRun(rocketbar);
|
||||
rocketbar.focus();
|
||||
rocketbar.enterText(url + '\uE006');
|
||||
rocketbar.waitForBrowserFrame();
|
||||
client.switchToFrame();
|
||||
rocketbar.focus();
|
||||
rocketbar.enterText('non_matching_string');
|
||||
search.goToResults();
|
||||
assert.equal(client.findElements(search.Selectors.firstPlace).length, 0);
|
||||
});
|
||||
|
||||
test.skip('Ensures urls visited twice only show in results once', function() {
|
||||
var url = server.url('sample.html');
|
||||
search.triggerFirstRun(rocketbar);
|
||||
rocketbar.focus();
|
||||
rocketbar.enterText(url + '\uE006');
|
||||
rocketbar.waitForBrowserFrame();
|
||||
rocketbar.focus();
|
||||
rocketbar.enterText(url + '\uE006');
|
||||
rocketbar.waitForBrowserFrame();
|
||||
client.switchToFrame();
|
||||
rocketbar.focus();
|
||||
rocketbar.enterText(url);
|
||||
search.goToResults();
|
||||
|
||||
// Wait to get the correct amount of results
|
||||
client.waitFor(function() {
|
||||
return client.findElements(search.Selectors.firstPlace).length === 1;
|
||||
}.bind(this));
|
||||
|
||||
// Wait for a second and check we dont get extra results
|
||||
client.helper.wait(1000);
|
||||
assert.equal(client.findElements(search.Selectors.firstPlace).length, 1);
|
||||
});
|
||||
|
||||
test.skip('Ensure favicon is loaded', function() {
|
||||
var url = server.url('favicon.html');
|
||||
search.triggerFirstRun(rocketbar);
|
||||
rocketbar.focus();
|
||||
rocketbar.enterText(url + '\uE006');
|
||||
rocketbar.waitForBrowserFrame();
|
||||
|
||||
client.waitFor(function() {
|
||||
client.switchToFrame();
|
||||
rocketbar.focus();
|
||||
rocketbar.enterText(url);
|
||||
search.goToResults();
|
||||
var result = client.helper.waitForElement('#places div .icon');
|
||||
return !result.getAttribute('class').match('empty');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
64
gaia/apps/search/test/marionette/private_browser_dialog_test.js
Executable file
64
gaia/apps/search/test/marionette/private_browser_dialog_test.js
Executable file
|
|
@ -0,0 +1,64 @@
|
|||
'use strict';
|
||||
var assert = require('assert');
|
||||
|
||||
marionette('Private Browser Trigger', function() {
|
||||
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
settings: {
|
||||
'browser.private.default': true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var search, system;
|
||||
|
||||
setup(function() {
|
||||
search = client.loader.getAppClass('search');
|
||||
system = client.loader.getAppClass('system');
|
||||
system.waitForFullyLoaded();
|
||||
});
|
||||
|
||||
function launchPrivateWindow() {
|
||||
var frame = system.waitForLaunch(search.URL);
|
||||
client.switchToFrame(frame);
|
||||
}
|
||||
|
||||
test('launches private window', function() {
|
||||
// Assert that the dialog is visible and is dismissable.
|
||||
launchPrivateWindow();
|
||||
var dialog = client.helper.waitForElement(search.Selectors.privateDialog);
|
||||
client.helper.waitForElement(search.Selectors.privateDialogClose)
|
||||
.scriptWith(function(el) {
|
||||
el.wrappedJSObject.dispatchEvent(new CustomEvent('click'));
|
||||
});
|
||||
client.helper.waitForElementToDisappear(dialog);
|
||||
client.executeScript(function() {
|
||||
window.wrappedJSObject.close();
|
||||
});
|
||||
client.switchToFrame();
|
||||
|
||||
// Assert that the dialog is visible if we relaunch the search app.
|
||||
launchPrivateWindow();
|
||||
dialog = client.helper.waitForElement(search.Selectors.privateDialog);
|
||||
// Tap the checkbox and close the dialog.
|
||||
client.helper.waitForElement(search.Selectors.privateDialogCheckbox)
|
||||
.scriptWith(function(el) {
|
||||
el.wrappedJSObject.checked = true;
|
||||
});
|
||||
client.helper.waitForElement(search.Selectors.privateDialogClose)
|
||||
.scriptWith(function(el) {
|
||||
el.wrappedJSObject.dispatchEvent(new CustomEvent('click'));
|
||||
});
|
||||
client.helper.waitForElementToDisappear(dialog);
|
||||
client.executeScript(function() {
|
||||
window.wrappedJSObject.close();
|
||||
});
|
||||
client.switchToFrame();
|
||||
|
||||
// The next time we re-launch the browser the dialog should not appear.
|
||||
launchPrivateWindow();
|
||||
assert.ok(client.helper.waitForElement(
|
||||
search.Selectors.topSitesHeader).displayed());
|
||||
});
|
||||
});
|
||||
48
gaia/apps/search/test/marionette/private_browsing_events_test.js
Executable file
48
gaia/apps/search/test/marionette/private_browsing_events_test.js
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
'use strict';
|
||||
|
||||
marionette('Private Browsing', function() {
|
||||
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
settings: {
|
||||
'browser.private.default': true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var search, system;
|
||||
|
||||
setup(function() {
|
||||
search = client.loader.getAppClass('search');
|
||||
system = client.loader.getAppClass('system');
|
||||
system.waitForFullyLoaded();
|
||||
});
|
||||
|
||||
test('launches private window', function() {
|
||||
client.executeScript(function () {
|
||||
window.dispatchEvent(new CustomEvent('new-private-window'));
|
||||
});
|
||||
|
||||
client.helper.waitForElement('body');
|
||||
|
||||
var iframe = system.getAppIframe(search.privateBrowserUrl);
|
||||
|
||||
client.waitFor(function() {
|
||||
return iframe.getAttribute('src') === search.privateBrowserUrl;
|
||||
});
|
||||
});
|
||||
|
||||
test('launches non-private window', function() {
|
||||
client.executeScript(function () {
|
||||
window.dispatchEvent(new CustomEvent('new-non-private-window'));
|
||||
});
|
||||
|
||||
client.helper.waitForElement('body');
|
||||
|
||||
var iframe = system.getAppIframe(search.nonPrivateBrowserUrl);
|
||||
|
||||
client.waitFor(function() {
|
||||
return iframe.getAttribute('src') === search.nonPrivateBrowserUrl;
|
||||
});
|
||||
});
|
||||
});
|
||||
126
gaia/apps/search/test/marionette/search_rocketbar_test.js
Executable file
126
gaia/apps/search/test/marionette/search_rocketbar_test.js
Executable file
|
|
@ -0,0 +1,126 @@
|
|||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
var Server = require('../../../../shared/test/integration/server');
|
||||
|
||||
marionette('Search - Rocketbar Test', function() {
|
||||
|
||||
var client = marionette.client({
|
||||
profile: require(__dirname + '/client_options.js'),
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var home, search, rocketbar, system, server;
|
||||
|
||||
var providers, searchTemplate;
|
||||
var phoneIdentifier =
|
||||
'app://communications.gaiamobile.org/manifest.webapp-dialer';
|
||||
|
||||
suiteSetup(function(done) {
|
||||
Server.create(__dirname + '/fixtures/', function(err, _server) {
|
||||
server = _server;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
home = client.loader.getAppClass('homescreen');
|
||||
system = client.loader.getAppClass('system');
|
||||
search = client.loader.getAppClass('search');
|
||||
rocketbar = new Rocketbar(client);
|
||||
system.waitForFullyLoaded();
|
||||
searchTemplate = server.url('sample.html') + '?q=';
|
||||
providers = {
|
||||
version: search.searchDataVersion(),
|
||||
providers: {
|
||||
'first': {
|
||||
title: 'first',
|
||||
searchUrl: searchTemplate + '{searchTerms}',
|
||||
suggestUrl: server.url('suggestions_one.json')
|
||||
}
|
||||
}
|
||||
};
|
||||
mockSearch();
|
||||
home.waitForLaunch();
|
||||
rocketbar.homescreenFocus();
|
||||
});
|
||||
|
||||
function mockSearch() {
|
||||
client.settings.set('search.suggestions.enabled', true);
|
||||
client.settings.set('search.cache', providers);
|
||||
client.settings.set('search.provider', 'first');
|
||||
}
|
||||
|
||||
function assertThatUrlContains(text) {
|
||||
rocketbar.appTitleFocus();
|
||||
client.waitFor(function() {
|
||||
var value = rocketbar.input.getAttribute('value');
|
||||
var searchText = text.replace(' ', '%20');
|
||||
return value === (searchTemplate + searchText);
|
||||
});
|
||||
}
|
||||
|
||||
test('General walkthrough', function() {
|
||||
search.triggerFirstRun(rocketbar);
|
||||
var textToSearch = 'a test';
|
||||
|
||||
// Clear button shouldnt be visible when no text entered
|
||||
assert.ok(!rocketbar.clear.displayed());
|
||||
|
||||
// Search for an app ane make sure it exists
|
||||
rocketbar.enterText('Phone');
|
||||
search.goToResults();
|
||||
search.checkResult(phoneIdentifier, 'Phone');
|
||||
|
||||
// Press rocketbar close button, ensure the homescreen is
|
||||
// now displayed
|
||||
client.switchToFrame();
|
||||
rocketbar.cancel.click();
|
||||
client.apps.switchToApp(home.URL);
|
||||
client.waitFor(function() {
|
||||
return home.visibleIcons.length && home.visibleIcons[0].displayed();
|
||||
});
|
||||
|
||||
// When we previously pressed close, when rocketbar reopens value
|
||||
// should be empty
|
||||
rocketbar.homescreenFocus();
|
||||
assert.equal(rocketbar.input.getAttribute('value'), '');
|
||||
|
||||
// Search for an app again, this time press close after searching
|
||||
rocketbar.enterText('Phone');
|
||||
home.pressHomeButton();
|
||||
|
||||
client.waitFor(function() {
|
||||
return home.visibleIcons.length && home.visibleIcons[0].displayed();
|
||||
});
|
||||
|
||||
// If we press home button during a search, next time we focus the rocketbar
|
||||
// previous result should be displayed
|
||||
rocketbar.homescreenFocus();
|
||||
search.goToResults();
|
||||
search.checkResult(phoneIdentifier, 'Phone');
|
||||
|
||||
// Clear button should be visible when text entered
|
||||
client.switchToFrame();
|
||||
assert.ok(rocketbar.clear.displayed());
|
||||
|
||||
// Press clear button, input
|
||||
rocketbar.clear.click();
|
||||
assert.equal(rocketbar.input.getAttribute('value'), '');
|
||||
assert.ok(!rocketbar.clear.displayed());
|
||||
|
||||
// Perform a search
|
||||
rocketbar.enterText(textToSearch, true);
|
||||
rocketbar.switchToBrowserFrame(searchTemplate);
|
||||
});
|
||||
|
||||
test('Browser search', function() {
|
||||
home.waitForLaunch();
|
||||
rocketbar.homescreenFocus();
|
||||
var textToSearch = 'a test';
|
||||
rocketbar.performSearchInBrowser(textToSearch);
|
||||
assertThatUrlContains(textToSearch);
|
||||
});
|
||||
|
||||
});
|
||||
74
gaia/apps/search/test/marionette/suggestions_disabled_test.js
Executable file
74
gaia/apps/search/test/marionette/suggestions_disabled_test.js
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
'use strict';
|
||||
|
||||
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
var Server = require('../../../../shared/test/integration/server');
|
||||
|
||||
marionette('Search - Suggestions disabled', function() {
|
||||
|
||||
var client = marionette.client({
|
||||
profile: require(__dirname + '/client_options.js'),
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var home, search, rocketbar, system, server;
|
||||
|
||||
var providers;
|
||||
|
||||
suiteSetup(function(done) {
|
||||
Server.create(__dirname + '/fixtures/', function(err, _server) {
|
||||
server = _server;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
home = client.loader.getAppClass('homescreen');
|
||||
system = client.loader.getAppClass('system');
|
||||
search = client.loader.getAppClass('search');
|
||||
rocketbar = new Rocketbar(client);
|
||||
system.waitForFullyLoaded();
|
||||
|
||||
providers = {
|
||||
version: search.searchDataVersion(),
|
||||
providers: {
|
||||
'first': {
|
||||
title: 'first',
|
||||
searchUrl: server.url('sample.html'),
|
||||
suggestUrl: server.url('suggestions_one.json')
|
||||
},
|
||||
'second': {
|
||||
title: 'second',
|
||||
searchUrl: server.url('sample.html'),
|
||||
suggestUrl: server.url('suggestions_two.json')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
client.settings.set('search.suggestions.enabled', false);
|
||||
client.settings.set('search.cache', providers);
|
||||
client.settings.set('search.provider', 'first');
|
||||
});
|
||||
|
||||
test('Test switching suggestion provider', function() {
|
||||
|
||||
home.waitForLaunch();
|
||||
|
||||
rocketbar.homescreenFocus();
|
||||
search.triggerFirstRun(rocketbar);
|
||||
|
||||
rocketbar.enterText('sometext');
|
||||
search.goToResults();
|
||||
client.waitFor(function() {
|
||||
return client.findElements(search.Selectors.suggestions).length === 1;
|
||||
});
|
||||
|
||||
var select = search.switchProvidersSelect;
|
||||
client.helper.tapSelectOption(select, 'second');
|
||||
|
||||
client.switchToFrame();
|
||||
search.goToResults();
|
||||
client.waitFor(function() {
|
||||
return client.findElements(search.Selectors.suggestions).length === 1;
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
68
gaia/apps/search/test/marionette/suggestions_test.js
Executable file
68
gaia/apps/search/test/marionette/suggestions_test.js
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
'use strict';
|
||||
|
||||
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
|
||||
var Server = require('../../../../shared/test/integration/server');
|
||||
|
||||
marionette('Search - Suggestions Test', function() {
|
||||
|
||||
var client = marionette.client({
|
||||
profile: require(__dirname + '/client_options.js'),
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
var home, search, rocketbar, system, server;
|
||||
|
||||
var providers;
|
||||
|
||||
suiteSetup(function(done) {
|
||||
Server.create(__dirname + '/fixtures/', function(err, _server) {
|
||||
server = _server;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
home = client.loader.getAppClass('homescreen');
|
||||
system = client.loader.getAppClass('system');
|
||||
search = client.loader.getAppClass('search');
|
||||
rocketbar = new Rocketbar(client);
|
||||
system.waitForFullyLoaded();
|
||||
|
||||
providers = {
|
||||
version: search.searchDataVersion(),
|
||||
providers: {
|
||||
'first': {
|
||||
title: 'first',
|
||||
searchUrl: server.url('sample.html'),
|
||||
suggestUrl: server.url('suggestions_one.json')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
client.settings.set('search.suggestions.enabled', true);
|
||||
client.settings.set('search.cache', providers);
|
||||
client.settings.set('search.provider', 'first');
|
||||
});
|
||||
|
||||
test('Test suggestions', function() {
|
||||
|
||||
home.waitForLaunch();
|
||||
rocketbar.homescreenFocus();
|
||||
|
||||
search.triggerFirstRun(rocketbar);
|
||||
rocketbar.enterText('sometext');
|
||||
search.goToResults();
|
||||
|
||||
// Ensure we get 2 results (hardcoded in the provider results)
|
||||
client.waitFor(function() {
|
||||
return client.findElements(search.Selectors.suggestions).length === 2;
|
||||
});
|
||||
|
||||
// Ensure clicking on a result opens the browser correctly
|
||||
var first = client.helper.waitForElement('#suggestions li');
|
||||
first.click();
|
||||
|
||||
client.switchToFrame();
|
||||
rocketbar.switchToBrowserFrame(providers.providers.first.searchUrl);
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue