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

Commit

Permalink
Merge pull request #16097 from qdot/969587-variant-with-no-icc
Browse files Browse the repository at this point in the history
Bug 969587 - Run variant customization with no icc
  • Loading branch information
qdot committed Feb 12, 2014
2 parents fdc7a7e + 8afc652 commit 3999923
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 41 deletions.
2 changes: 2 additions & 0 deletions apps/browser/build/build.js
Expand Up @@ -20,6 +20,8 @@ BrowserAppBuilder.prototype.setOptions = function(options) {
};

BrowserAppBuilder.prototype.initJSON = function() {
// Note: The variant integration test in FTU will need to be changed if the
// defaults here change, otherwise the tests will fail.
var defaultJSONpath =
utils.joinPath(this.appDir.path, 'build', 'default.json');
var defaultJson = utils.getJSON(utils.getFile(defaultJSONpath));
Expand Down
25 changes: 17 additions & 8 deletions apps/communications/ftu/js/variant.js
Expand Up @@ -4,11 +4,6 @@ var VariantManager = {
// This file is created during the BUILD process
CUSTOMIZATION_FILE: '/resources/customization.json',
init: function vm_init() {
if (!IccHelper) {
console.error('Impossible to access iccInfo via IccHelper. Aborting.');
return;
}

// Check if the iccInfo is available
this.mcc_mnc = this.getMccMnc();
if (this.mcc_mnc) {
Expand Down Expand Up @@ -40,7 +35,9 @@ var VariantManager = {
iccHandler: function vm_iccHandler() {
this.mcc_mnc = this.getMccMnc();
if (this.mcc_mnc) {
IccHelper.removeEventListener('iccinfochange', this.boundIccHandler);
if (IccHelper) {
IccHelper.removeEventListener('iccinfochange', this.boundIccHandler);
}
// Load the variant customizers and the variant JSON file.
LazyLoader.load(
this.CUSTOMIZERS,
Expand Down Expand Up @@ -86,8 +83,20 @@ var VariantManager = {
},

getMccMnc: function vm_getMccMnc() {
var mcc = IccHelper.iccInfo ? IccHelper.iccInfo.mcc : undefined;
var mnc = IccHelper.iccInfo ? IccHelper.iccInfo.mnc : undefined;
var mcc = undefined;
var mnc = undefined;
// If we have valid iccInfo, use that. Otherwise continue with undefined
// values.
if (IccHelper && IccHelper.iccInfo) {
mcc = IccHelper.iccInfo.mcc;
mnc = IccHelper.iccInfo.mnc;
} else if (!IccHelper || IccHelper.cardState === null) {
// if IccHelper isn't available or if it is available
// but has null cardState (this means no SIM available) configure with
// defaults
mcc = '000';
mnc = '000';
}
if ((mcc !== undefined) && (mcc !== null) &&
(mnc !== undefined) && (mnc !== null)) {
return this.normalizeCode(mcc) + '-' + this.normalizeCode(mnc);
Expand Down
53 changes: 20 additions & 33 deletions apps/communications/ftu/test/marionette/ftu_tests.js
@@ -1,47 +1,34 @@
/* jshint node: true */
'use strict';

marionette('First Time Use >', function() {
var assert = require('assert');
var FTU = 'app://communications.gaiamobile.org';

var FTU = require('./lib/ftu_test_lib').FTU;
var client = marionette.client();

var clickThruPanel = function(panel_id, button_id) {
if (panel_id == '#wifi') {
// The wifi panel will bring up a screen to show it is scanning for
// networks. Not waiting for this to clear will blow test timing and cause
// things to fail.
client.helper.waitForElementToDisappear('#loading-overlay');
}
// waitForElement is used to make sure animations and page changes have
// finished, and that the panel is displayed.
client.helper.waitForElement(panel_id);
if (button_id) {
var button = client.waitForElement(button_id);
button.click();
}
};
var ftu = new FTU(client);

test('FTU comes up on profile generation', function() {
client.apps.switchToApp(FTU);
ftu.waitForFTU();
});

test('FTU click thru', function() {
client.apps.switchToApp(FTU);
clickThruPanel('#languages', '#forward');
clickThruPanel('#wifi', '#forward');
clickThruPanel('#date_and_time', '#forward');
clickThruPanel('#geolocation', '#forward');
clickThruPanel('#import_contacts', '#forward');
clickThruPanel('#welcome_browser', '#forward');
clickThruPanel('#browser_privacy', '#forward');
clickThruPanel('#finish-screen', undefined);
ftu.waitForFTU();
ftu.clickThruPanel('#languages', '#forward');
ftu.clickThruPanel('#wifi', '#forward');
ftu.clickThruPanel('#date_and_time', '#forward');
ftu.clickThruPanel('#geolocation', '#forward');
ftu.clickThruPanel('#import_contacts', '#forward');
ftu.clickThruPanel('#welcome_browser', '#forward');
ftu.clickThruPanel('#browser_privacy', '#forward');
ftu.clickThruPanel('#finish-screen', undefined);
});

test('FTU Wifi Scanning Tests', function() {
client.apps.switchToApp(FTU);
clickThruPanel('#languages', '#forward');
clickThruPanel('#wifi', '#forward');
clickThruPanel('#date_and_time', '#back');
clickThruPanel('#wifi', undefined);
ftu.waitForFTU();
ftu.clickThruPanel('#languages', '#forward');
ftu.clickThruPanel('#wifi', '#forward');
ftu.clickThruPanel('#date_and_time', '#back');
ftu.clickThruPanel('#wifi', undefined);
});

});
36 changes: 36 additions & 0 deletions apps/communications/ftu/test/marionette/lib/ftu_test_lib.js
@@ -0,0 +1,36 @@
/* jshint node: true */
'use strict';

function FTUHelper(client) {
this.client = client;
}

FTUHelper.prototype = {
client: null,
FTU_URL: 'app://communications.gaiamobile.org',
waitForFTU: function() {
this.client.apps.switchToApp(this.FTU_URL);
},
clickThruPanel: function(panel_id, button_id) {
if (panel_id == '#wifi') {
// The wifi panel will bring up a screen to show it is scanning for
// networks. Not waiting for this to clear will blow test timing and cause
// things to fail.
this.client.helper.waitForElementToDisappear('#loading-overlay');
}
// waitForElement is used to make sure animations and page changes have
// finished, and that the panel is displayed.
this.client.helper.waitForElement(panel_id);
if (button_id) {
var button = this.client.helper.waitForElement(button_id);
button.click();
}
},
close: function() {
this.client.apps.close(this.FTU_URL);
}
};

module.exports = {
FTU: FTUHelper
};
34 changes: 34 additions & 0 deletions apps/communications/ftu/test/marionette/variant_test.js
@@ -0,0 +1,34 @@
/* jshint node: true */
'use strict';

marionette('First Time Use > Single Variant Customization > ', function() {
var assert = require('assert');
var FTU = require('./lib/ftu_test_lib').FTU;
var client = marionette.client();
var ftu = new FTU(client);

var browser_url = 'app://browser.gaiamobile.org';

// This test will need to be changed if we change default bookmarks in
// build system.
test('FTU runs customization when no ICCHelper available', function() {
// wait for the ftu to come up, which means customization will have been run
ftu.waitForFTU();
ftu.close();
// bring up browser
client.apps.launch(browser_url);
client.apps.switchToApp(browser_url);

// Wait for the document body to know we're really 'launched'.
client.helper.waitForElement('body');

// Bring up the bookmarks tab, make sure we have 2 bookmarks. Not the most
// through of tests, but it'll do for now.
client.findElement('#url-input').click();
client.findElement('#bookmarks-tab').click();
client.helper.waitForElement('#bookmarks > ul');
var links = client.findElements('#bookmarks > ul > li');
assert(links.length == 2, 'Not enough links in bookmarks! ' + links.length);
});

});
13 changes: 13 additions & 0 deletions apps/communications/ftu/test/unit/resources/default_bookmarks.json
@@ -0,0 +1,13 @@
{
"bookmarks": [
{ "title": "Test",
"uri": "http://www.google.com",
"iconUri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC[truncated]"
},
{ "title": "Also Test",
"uri": "http://www.google.co.uk",
"iconUri": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC[truncated]"
}

]
}

0 comments on commit 3999923

Please sign in to comment.