Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 959694 - Combine Rocketbar and statusbar r=alive r=kgrandon
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrancis committed Apr 8, 2014
1 parent 836c896 commit 2ff5aa0
Show file tree
Hide file tree
Showing 42 changed files with 1,437 additions and 1,420 deletions.
28 changes: 14 additions & 14 deletions apps/search/test/marionette/app_search_test.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
'use strict';

var System = require('../../../system/test/marionette/lib/system');
var Search = require('./lib/search');
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
var Calendar = require('../../../calendar/test/marionette/calendar');

marionette('app search', function() {
var client = marionette.client(Search.ClientOptions);

var search;
marionette('Search - App search', function() {
var client = marionette.client(Rocketbar.clientOptions);
var search, rocketbar, system;

setup(function() {
system = new System(client);
search = new Search(client);
rocketbar = new Rocketbar(client);
system.waitForStartup();
});

test('able to search apps from rocketbar', function() {
search.doSearch('calendar');

test('Search apps from Rocketbar', function() {
rocketbar.focus();
rocketbar.enterText('calendar');
search.goToResults();

search.checkResult('firstApp', 'Calendar');

search.goToApp(Calendar.ORIGIN);
});

test('search app with entry point', function() {
search.doSearch('phone');

test('Search for app with entry point', function() {
rocketbar.focus();
rocketbar.enterText('Phone');
search.goToResults();

search.checkResult('firstApp', 'Phone');

search.goToApp('app://communications.gaiamobile.org', 'dialer');
});

Expand Down
9 changes: 5 additions & 4 deletions apps/search/test/marionette/contacts_search_test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
'use strict';

var Search = require('./lib/search');
var Rocketbar = require('../../../system/test/marionette/lib/rocketbar.js');
var Contacts = require(
'../../../communications/contacts/test/marionette/lib/contacts');
var assert = require('assert');

marionette('contact search', function() {
var client = marionette.client(Search.ClientOptions);
marionette('Search - Contact search', function() {
var client = marionette.client(Rocketbar.clientOptions);

var contacts;
var search;
var contacts, search, rocketbar;

setup(function() {
rocketbar = new Rocketbar(client);
contacts = new Contacts(client);
search = new Search(client);
});
Expand Down
125 changes: 7 additions & 118 deletions apps/search/test/marionette/lib/search.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,23 @@
'use strict';
/* global module */

var Actions = require('marionette-client').Actions;
var assert = require('assert');

/**
* Abstraction around search app.
* @constructor
* @param {Marionette.Client} client for operations.
*/
function Search(client) {
this.actions = new Actions(client);
this.client = client;
this.client.setSearchTimeout(10000);
}

/**
* @type String Origin of search app
*/
Search.URL = 'app://search.gaiamobile.org';

Search.ClientOptions = {
prefs: {
// This is true on Gonk, but false on desktop, so override.
'dom.inter-app-communication-api.enabled': true,
'dom.w3c_touch_events.enabled': 1
},
settings: {
'ftu.manifestURL': null,
'keyboard.ftu.enabled': false,
'lockscreen.enabled': false,
'rocketbar.enabled': true
}
};

Search.Selectors = {
homescreen: '#homescreen',
searchBar: '#search-bar',
searchCancel: '#search-cancel',
searchInput: '#search-input',
searchResults: 'iframe[mozapptype="mozsearch"]',
statusBar: '#statusbar',
iframe: '#rocketbar-results-frame',
firstAppContainer: '#localapps',
firstApp: '#localapps div',
firstContact: '#contacts div',
Expand All @@ -52,11 +29,12 @@ Search.Selectors = {
Search.prototype = {

/**
* Launches search app and focuses on frame.
* Navigates to the search results frame.
*/
launch: function() {
this.client.apps.launch(Search.URL);
this.client.apps.switchToApp(Search.URL);
goToResults: function() {
var iframe = this.client.findElement(Search.Selectors.iframe);
this.client.helper.waitForElement(iframe);
this.client.switchToFrame(iframe);
this.client.helper.waitForElement('body');
},

Expand All @@ -76,21 +54,6 @@ Search.prototype = {
result.click();
},

/**
* Opens the rocketbar and enters text
*/
doSearch: function(input) {
this.client.switchToFrame();
this.openRocketbar();
this.client.helper
.waitForElement(Search.Selectors.searchInput)
.clear();

this.client.helper
.waitForElement(Search.Selectors.searchInput)
.sendKeys(input);
},

/**
* Navigates to a specific app/entry point
* Waits for the body to be loaded
Expand All @@ -99,82 +62,8 @@ Search.prototype = {
this.client.switchToFrame();
this.client.apps.switchToApp.apply(this.client.apps, arguments);
this.client.helper.waitForElement('body');
},

/**
* Navigates to the search results frame
*/
goToResults: function() {
var resultsFrame = this.client.helper
.waitForElement(Search.Selectors.searchResults);
this.client.switchToFrame(resultsFrame);
},

/**
* Navigates to a browser by finding the iframe
* which matches the given url.
*/
goToBrowser: function(url) {
var browserFrame = this.client.helper
.waitForElement('iframe[src="' + url + '"]');
this.client.switchToFrame(browserFrame);
},

/**
* Opens the rocketbar
*/
openRocketbar: function() {
var selectors = Search.Selectors;

this.client.helper.waitForElement(selectors.homescreen);
this.client.executeScript(function() {
window.wrappedJSObject.Rocketbar.render();
});

// https://bugzilla.mozilla.org/show_bug.cgi?id=960098
// Renable and write a dedicated test for opening the rocketbar
// be swiping from the statusbar down, this is currently broken.
//
// this.client.helper.waitForElement(selectors.homescreen);
// var statusbar = this.client.helper.waitForElement(
// selectors.statusBar);
// this.actions.flick(statusbar, 1, 1, 20, 200).perform();

this.client.waitFor(function() {
var location = this.client
.findElement(Search.Selectors.searchInput).location();
return location.y >= 20;
}.bind(this));
},

/**
* Wait for an opened browser frame to complete showing, then
* return to the homescreen
*/
waitForBrowserFrame: function() {
this.client.switchToFrame();
this.client.waitFor((function() {
var size = this.client.findElement('.appWindow.active').size();
return size.width === 320 && size.height === 460;
}).bind(this));
return this.client.executeScript(function() {
window.wrappedJSObject.dispatchEvent(new CustomEvent('home'));
});
},

/**
* Closes the rocketbar by pressing the cancel button
*/
cancelRocketbar: function() {
this.client.helper.waitForElement(Search.Selectors.searchCancel)
.click();

this.client.waitFor(function() {
var el = this.client
.findElement(Search.Selectors.searchBar);
return el.location().y + el.size().height === 0;
}.bind(this));
}

};

module.exports = Search;
82 changes: 0 additions & 82 deletions apps/search/test/marionette/navigation_test.js

This file was deleted.

0 comments on commit 2ff5aa0

Please sign in to comment.