Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#29471 from evanxd/bug-1148733
Browse files Browse the repository at this point in the history
Cancel the installation when user hold home button
  • Loading branch information
evanxd committed Apr 14, 2015
2 parents 4ba5ce1 + 5570037 commit 4854df6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 14 deletions.
5 changes: 3 additions & 2 deletions apps/system/js/app_install_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ var AppInstallManager = {
window.addEventListener('applicationready',
this.handleApplicationReady);

window.addEventListener('home', this.handleHomeButtonPressed.bind(this));
window.addEventListener('home', this.cancelInstallation.bind(this));
window.addEventListener('holdhome', this.cancelInstallation.bind(this));
},

handleHomeButtonPressed: function ai_handleHomeButtonPressed(e) {
cancelInstallation: function ai_cancelInstallation() {
this.dialog.classList.remove('visible');
this.dispatchPromptEvent('hidden');
this.handleInstallCancel();
Expand Down
58 changes: 46 additions & 12 deletions apps/system/test/unit/app_install_manager_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,14 @@ suite('system/AppInstallManager >', function() {
});

test('the dialog should be hidden after press home', function() {
var evt = {
type: 'home'
};
assert.equal('visible', AppInstallManager.dialog.className);
AppInstallManager.handleHomeButtonPressed(evt);
window.dispatchEvent(new CustomEvent('home'));
assert.notEqual('visible', AppInstallManager.dialog.className);
});

test('the dialog should be hidden after hold home', function() {
assert.equal('visible', AppInstallManager.dialog.className);
window.dispatchEvent(new CustomEvent('holdhome'));
assert.notEqual('visible', AppInstallManager.dialog.className);
});

Expand Down Expand Up @@ -523,12 +526,17 @@ suite('system/AppInstallManager >', function() {
});

test('the dialog should be hidden after press home', function() {
var evt = {
type: 'home'
};
assert.equal('visible',
AppInstallManager.installCancelDialog.className);
AppInstallManager.handleHomeButtonPressed(evt);
window.dispatchEvent(new CustomEvent('home'));
assert.notEqual('visible',
AppInstallManager.installCancelDialog.className);
});

test('the dialog should be hidden after hold home', function() {
assert.equal('visible',
AppInstallManager.installCancelDialog.className);
window.dispatchEvent(new CustomEvent('holdhome'));
assert.notEqual('visible',
AppInstallManager.installCancelDialog.className);
});
Expand Down Expand Up @@ -1632,28 +1640,54 @@ suite('system/AppInstallManager >', function() {
sinon.assert.calledOnce(KeyboardHelper.saveToSettings);
});

test('IME setup dialog should be hidden after pressing home',
test('IME setup dialog should be hidden after press home',
function(done) {
waitForEvent('installprompthidden', done);

AppInstallManager.handleInstallSuccess(mockApp);
assert.isTrue(AppInstallManager.
setupInstalledAppDialog.classList.contains('visible'));

window.dispatchEvent(new CustomEvent('home'));
assert.isFalse(AppInstallManager.
setupInstalledAppDialog.classList.contains('visible'));
});

test('IME setup dialog should be hidden after hold home',
function(done) {
waitForEvent('installprompthidden', done);

AppInstallManager.handleInstallSuccess(mockApp);
assert.isTrue(AppInstallManager.
setupInstalledAppDialog.classList.contains('visible'));

AppInstallManager.handleHomeButtonPressed();
window.dispatchEvent(new CustomEvent('holdhome'));
assert.isFalse(AppInstallManager.
setupInstalledAppDialog.classList.contains('visible'));
});

test('IME list should be hidden after pressing home', function(done) {
test('IME list should be hidden after press home', function(done) {
waitForEvent('installprompthidden', done);

AppInstallManager.handleInstallSuccess(mockAppTwo);
AppInstallManager.setupConfirmButton.click();
assert.isTrue(AppInstallManager.
imeLayoutDialog.classList.contains('visible'));

window.dispatchEvent(new CustomEvent('home'));
assert.isFalse(AppInstallManager.
imeLayoutDialog.classList.contains('visible'));
});

test('IME list should be hidden after hold home', function(done) {
waitForEvent('installprompthidden', done);

AppInstallManager.handleInstallSuccess(mockAppTwo);
AppInstallManager.setupConfirmButton.click();
assert.isTrue(AppInstallManager.
imeLayoutDialog.classList.contains('visible'));

AppInstallManager.handleHomeButtonPressed();
window.dispatchEvent(new CustomEvent('holdhome'));
assert.isFalse(AppInstallManager.
imeLayoutDialog.classList.contains('visible'));
});
Expand Down

0 comments on commit 4854df6

Please sign in to comment.