Skip to content

Commit

Permalink
Create child/dialog windows when FTU is running
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoster committed Oct 1, 2014
1 parent a707bb3 commit 27f182c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 35 deletions.
21 changes: 6 additions & 15 deletions apps/system/js/app_window_manager.js
@@ -1,5 +1,5 @@
/* global SettingsListener, homescreenLauncher, KeyboardManager,
FtuLauncher, layoutManager, System, NfcHandler, rocketbar */
layoutManager, System, NfcHandler, rocketbar */
'use strict';

(function(exports) {
Expand Down Expand Up @@ -107,21 +107,12 @@
*/
display: function awm_display(newApp, openAnimation, closeAnimation) {
this._dumpAllWindows();
var appCurrent = this._activeApp, appNext = newApp;
var ftuApp;
var appCurrent = this._activeApp, appNext = newApp ||
homescreenLauncher.getHomescreen(true);

if (!appNext && FtuLauncher && FtuLauncher.isFtuRunning()) {
ftuApp = this.getApp(FtuLauncher.getFtuOrigin());
if (ftuApp && !ftuApp.isDead()) {
appNext = ftuApp;
}
}
if (!appNext) {
appNext = homescreenLauncher.getHomescreen(true);
if (!appNext) {
this.debug('no next app.');
return;
}
this.debug('no next app.');
return;
}

// If the app has child app window, open it instead.
Expand Down Expand Up @@ -249,7 +240,7 @@
* 1. Applications is ready. (mozApps are parsed.)
* 2. Bootstrap tells HomescreenLauncher to init.
* 3. Homescreen is ready.
* 4. Bootstrap tells FtuLauncher to fetch FTU(First Time Use app) info.
* 4. Bootstrap tells FTULauncher to fetch FTU(First Time Use app) info.
* 5. FTU app is skipped or done.
* 6. AppWindowManager open homescreen app via HomescreenLauncher.
*
Expand Down
3 changes: 2 additions & 1 deletion apps/system/js/child_window_factory.js
@@ -1,6 +1,6 @@
'use strict';
/* global AppWindow, PopupWindow, ActivityWindow, SettingsListener,
AttentionWindow, MozActivity */
FtuLauncher, AttentionWindow, MozActivity */

(function(exports) {
var ENABLE_IN_APP_SHEET = false;
Expand Down Expand Up @@ -56,6 +56,7 @@

// <a href="" target="_blank"> should never be part of the app
if (evt.detail.name == '_blank' &&
!FtuLauncher.isFtuRunning() &&
evt.detail.features !== 'attention') {
this.createNewWindow(evt);
evt.stopPropagation();
Expand Down
22 changes: 3 additions & 19 deletions apps/system/test/unit/app_window_manager_test.js
@@ -1,5 +1,5 @@
/* global AppWindowManager, AppWindow, homescreenLauncher,
HomescreenWindow, MocksHelper, FtuLauncher,
HomescreenWindow, MocksHelper,
MockSettingsListener, System, HomescreenLauncher,
MockRocketbar, rocketbar */
'use strict';
Expand All @@ -18,16 +18,14 @@ requireApp('system/test/unit/mock_homescreen_window.js');
requireApp('system/test/unit/mock_homescreen_launcher.js');
requireApp('system/test/unit/mock_nfc_handler.js');
requireApp('system/test/unit/mock_rocketbar.js');
requireApp('system/test/unit/mock_ftu_launcher.js');
requireApp('system/js/system.js');
requireApp('system/shared/test/unit/mocks/mock_settings_listener.js');

var mocksForAppWindowManager = new MocksHelper([
'OrientationManager', 'ActivityWindow',
'Applications', 'SettingsListener', 'HomescreenLauncher',
'ManifestHelper', 'KeyboardManager', 'StatusBar', 'SoftwareButtonManager',
'HomescreenWindow', 'AppWindow', 'LayoutManager', 'System', 'NfcHandler',
'FtuLauncher'
'HomescreenWindow', 'AppWindow', 'LayoutManager', 'System', 'NfcHandler'
]).init();

suite('system/AppWindowManager', function() {
Expand Down Expand Up @@ -605,7 +603,7 @@ suite('system/AppWindowManager', function() {
assert.isTrue(stubKill.called);
});
});

suite('updateActiveApp()', function() {
test('update', function() {
var spyPublish= this.sinon.spy(AppWindowManager, 'publish');
Expand Down Expand Up @@ -647,20 +645,6 @@ suite('system/AppWindowManager', function() {
assert.equal(AppWindowManager._activeApp, app);
});

test('default to FTU when running', function() {
var ftu = new AppWindow(fakeFTUConfig);

injectRunningApps(ftu);
AppWindowManager._activeApp = null;
this.sinon.stub(FtuLauncher, 'isFtuRunning').returns(true);
this.sinon.stub(FtuLauncher, 'getFtuOrigin')
.returns(fakeFTUConfig.origin);
var stubReady = this.sinon.stub(ftu, 'ready');
AppWindowManager.display();
stubReady.yield();
assert.equal(AppWindowManager._activeApp, ftu);
});

test('app to app', function() {
var stub_updateActiveApp = this.sinon.stub(AppWindowManager,
'_updateActiveApp');
Expand Down

0 comments on commit 27f182c

Please sign in to comment.