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 #16109 from desaintmartin/952912
Browse files Browse the repository at this point in the history
Bug 952912 - System update check for NOFTU build, r=alive
  • Loading branch information
alivedise committed Feb 12, 2014
2 parents dc63ede + 4b15569 commit f9d9163
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 13 deletions.
14 changes: 11 additions & 3 deletions apps/system/js/bootstrap.js
Expand Up @@ -34,14 +34,22 @@ window.addEventListener('load', function startup() {
});
}

window.addEventListener('ftudone', function doneWithFTU() {
/**
* Enable checkForUpdate after FTU is either done or skipped.
*/
function doneWithFTU() {
window.removeEventListener('ftudone', doneWithFTU);

window.removeEventListener('ftuskip', doneWithFTU);
var lock = window.navigator.mozSettings.createLock();
lock.set({
'gaia.system.checkForUpdates': true
});
});
}

window.addEventListener('ftudone', doneWithFTU);
// Enable checkForUpdate as well if booted without FTU
window.addEventListener('ftuskip', doneWithFTU);


SourceView.init();
Shortcuts.init();
Expand Down
97 changes: 97 additions & 0 deletions apps/system/test/unit/bootstrap_test.js
@@ -0,0 +1,97 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */

/*global MockNavigatormozApps, MockNavigatorSettings, MocksHelper*/

'use strict';

requireApp('system/shared/test/unit/mocks/mock_navigator_moz_apps.js');
requireApp('system/shared/test/unit/mocks/mock_navigator_moz_settings.js');
requireApp('system/shared/test/unit/mocks/mock_settings_listener.js');
requireApp('system/shared/test/unit/mocks/mock_settings_url.js');
requireApp('system/test/unit/mock_applications.js');
requireApp('system/test/unit/mock_ftu_launcher.js');
requireApp('system/test/unit/mock_homescreen_launcher.js');
requireApp('system/test/unit/mock_places.js');
requireApp('system/test/unit/mock_screen_manager.js');
requireApp('system/test/unit/mock_source_view.js');

mocha.globals([
'Shortcuts',
'wallpaperURL',
'cancelHomeTouchstart',
'cancelHomeTouchend',
'secureWindowManager',
'secureWindowFactory',
]);

var mocksForBootstrap = new MocksHelper([
'Applications',
'FtuLauncher',
'HomescreenLauncher',
'Places',
'ScreenManager',
'SettingsListener',
'SettingsURL',
'SourceView',
]).init();

suite('system/Bootstrap', function() {
var realNavigatorSettings;
var realNavigatormozApps;
var realDocumentElementDir;
var realDocumentElementLang;

mocksForBootstrap.attachTestHelpers();

suiteSetup(function(done) {
realNavigatormozApps = navigator.mozApps;
navigator.mozApps = MockNavigatormozApps;

realNavigatorSettings = navigator.mozSettings;
navigator.mozSettings = MockNavigatorSettings;

realDocumentElementDir = document.documentElement.dir;
realDocumentElementLang = document.documentElement.lang;

requireApp('system/js/bootstrap.js', done);
});

suiteTeardown(function() {
navigator.mozApps = realNavigatormozApps;
realNavigatormozApps = null;

navigator.mozSettings = realNavigatorSettings;
realNavigatorSettings = null;

document.documentElement.dir = realDocumentElementDir;
document.documentElement.lang = realDocumentElementLang;
});

suite('check for updates setting', function() {
var setting = 'gaia.system.checkForUpdates';
suite('after First Time User setup has been done', function() {
setup(function() {
MockNavigatorSettings.mSettings[setting] = false;
window.dispatchEvent(new CustomEvent('load'));
window.dispatchEvent(new CustomEvent('ftudone'));
});

test('should be enabled', function() {
assert.isTrue(MockNavigatorSettings.mSettings[setting]);
});
});

suite('at boot, if NOFTU is defined (i.e in DEBUG mode)', function() {
setup(function() {
MockNavigatorSettings.mSettings[setting] = false;
window.dispatchEvent(new CustomEvent('load'));
window.dispatchEvent(new CustomEvent('ftuskip'));
});

test('should be enabled', function() {
assert.isTrue(MockNavigatorSettings.mSettings[setting]);
});
});
});
});
16 changes: 16 additions & 0 deletions apps/system/test/unit/mock_places.js
@@ -0,0 +1,16 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */

/*exported MockPlaces*/

'use strict';

var MockPlaces = (function() {

function init() {
}

return {
init: init
};
})();
18 changes: 18 additions & 0 deletions apps/system/test/unit/mock_screen_manager.js
@@ -0,0 +1,18 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */

/*exported MockScreenManager*/

'use strict';

var MockScreenManager = (function() {
var screenEnabled = true;

function turnScreenOn() {
}

return {
turnScreenOn: turnScreenOn,
screenEnabled: screenEnabled
};
})();
16 changes: 16 additions & 0 deletions apps/system/test/unit/mock_source_view.js
@@ -0,0 +1,16 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */

/*exported MockSourceView*/

'use strict';

var MockSourceView = (function() {

function init() {
}

return {
init: init
};
})();
12 changes: 2 additions & 10 deletions apps/system/test/unit/notifications_test.js
Expand Up @@ -12,13 +12,15 @@ mocha.globals(['ScreenManager']);
require('/shared/test/unit/mocks/mock_settings_url.js');
require('/test/unit/mock_statusbar.js');
require('/shared/test/unit/mocks/mock_gesture_detector.js');
require('/test/unit/mock_screen_manager.js');
require('/test/unit/mock_utility_tray.js');
require('/shared/test/unit/mocks/mock_settings_listener.js');
require('/js/notifications.js');

var mocksForNotificationScreen = new MocksHelper([
'StatusBar',
'GestureDetector',
'ScreenManager',
'SettingsListener',
'SettingsURL',
'UtilityTray'
Expand Down Expand Up @@ -109,14 +111,8 @@ suite('system/NotificationScreen >', function() {
});

suite('updateStatusBarIcon >', function() {
var realScreenManager;
setup(function() {
this.sinon.spy(MockStatusBar, 'updateNotification');
realScreenManager = window.ScreenManager;
window.ScreenManager = {
screenEnabled: true,
turnScreenOn: sinon.stub()
};
NotificationScreen.updateStatusBarIcon();
});

Expand Down Expand Up @@ -224,10 +220,6 @@ suite('system/NotificationScreen >', function() {
fakeLockScreenContainer.querySelector(
'[data-notification-i-d="id-10000"]'));
});

teardown(function() {
window.ScreenManager = realScreenManager;
});
});

suite('differentiating api >', function() {
Expand Down

0 comments on commit f9d9163

Please sign in to comment.