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 #26481 from mancas/bug1100341
Browse files Browse the repository at this point in the history
Bug 1100341 - [Statusbar][Edge gestures] Icons overlay when performing e...
  • Loading branch information
rvandermeulen committed Jan 5, 2015
2 parents b77e0d5 + 296ede1 commit 0fe45b1
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 46 deletions.
14 changes: 5 additions & 9 deletions apps/system/js/edge_swipe_detector.js
Expand Up @@ -37,8 +37,7 @@
*/
start: function esd_init() {
window.addEventListener('homescreenopened', this);
window.addEventListener('appopen', this);
window.addEventListener('launchapp', this);
window.addEventListener('appopened', this);
window.addEventListener('cardviewclosed', this);
window.addEventListener('mozChromeEvent', this);

Expand Down Expand Up @@ -114,18 +113,15 @@
e.preventDefault();
this._touchEnd(e);
break;
case 'appopen':
case 'appopened':
var app = e.detail;
this.lifecycleEnabled = (app.origin !== FtuLauncher.getFtuOrigin());
if (!app.stayBackground) {
this.lifecycleEnabled = (app.origin !== FtuLauncher.getFtuOrigin());
}
break;
case 'homescreenopened':
this.lifecycleEnabled = false;
break;
case 'launchapp':
if (!e.detail.stayBackground) {
this.lifecycleEnabled = true;
}
break;
case 'cardviewclosed':
if (e.detail && e.detail.newStackPosition) {
this.lifecycleEnabled = true;
Expand Down
21 changes: 20 additions & 1 deletion apps/system/js/statusbar.js
Expand Up @@ -143,6 +143,8 @@ var StatusBar = {

_minimizedStatusBarWidth: window.innerWidth,

_pausedForGesture: false,

/**
* Object used for handling the clock UI element, wraps all related timers
*/
Expand Down Expand Up @@ -366,7 +368,10 @@ var StatusBar = {

case 'sheets-gesture-begin':
this.element.classList.add('hidden');
this.pauseUpdate();
if (!this._pausedForGesture) {
this.pauseUpdate();
this._pausedForGesture = true;
}
break;

case 'utilitytraywillshow':
Expand Down Expand Up @@ -547,6 +552,7 @@ var StatusBar = {

case 'sheets-gesture-end':
this.element.classList.remove('hidden');
this._pausedForGesture = false;
this.resumeUpdate();
break;

Expand All @@ -572,8 +578,21 @@ var StatusBar = {
/* falls through */
case 'apptitlestatechanged':
case 'activitytitlestatechanged':
this.setAppearance(evt.detail);
if (!this.isPaused()) {
this.element.classList.remove('hidden');
}
break;
case 'homescreenopened':
// In some cases, if the user has been switching apps so fast and
// quickly he press the home button, we might miss the
// |sheets-gesture-end| event so we must resume the statusbar
// if needed
this.setAppearance(evt.detail);
if (this._pausedForGesture) {
this.resumeUpdate();
this._pausedForGesture = false;
}
this.element.classList.remove('hidden');
break;
case 'activityterminated':
Expand Down
42 changes: 6 additions & 36 deletions apps/system/test/unit/edge_swipe_detector_test.js
Expand Up @@ -84,12 +84,6 @@ suite('system/EdgeSwipeDetector >', function() {
name: 'FTU'
};

function appLaunch(config) {
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent('launchapp', true, false, config);
window.dispatchEvent(evt);
}

function homescreen() {
window.dispatchEvent(new Event('homescreenopened'));
}
Expand All @@ -104,7 +98,7 @@ suite('system/EdgeSwipeDetector >', function() {
function launchTransitionEnd(config) {
var evt = document.createEvent('CustomEvent');
config || (config = dialer);
evt.initCustomEvent('appopen', true, false, config);
evt.initCustomEvent('appopened', true, false, config);
window.dispatchEvent(evt);
}

Expand Down Expand Up @@ -152,7 +146,7 @@ suite('system/EdgeSwipeDetector >', function() {
});

test('the edges should be enabled', function() {
appLaunch(dialer);
launchTransitionEnd(dialer);
assert.isFalse(subject.previous.classList.contains('disabled'));
assert.isFalse(subject.next.classList.contains('disabled'));
});
Expand All @@ -167,7 +161,7 @@ suite('system/EdgeSwipeDetector >', function() {
});

test('the edges should not be enabled', function() {
appLaunch(dialer);
launchTransitionEnd(dialer);
var previous = subject.previous;
assert.isTrue(previous.classList.contains('disabled'));
assert.isTrue(subject.next.classList.contains('disabled'));
Expand All @@ -185,7 +179,7 @@ suite('system/EdgeSwipeDetector >', function() {
suite('in background', function() {
setup(function() {
dialer.stayBackground = true;
appLaunch(dialer);
launchTransitionEnd(dialer);
});

test('the edges should not be enabled', function() {
Expand All @@ -203,38 +197,14 @@ suite('system/EdgeSwipeDetector >', function() {
});
});

suite('When a wrapper is launched', function() {
var google = {
url: 'http://google.com/index.html',
origin: 'http://google.com'
};

function wrapperLaunch(config) {
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent('launchapp', true, false, config);
window.dispatchEvent(evt);
}

setup(function() {
subject.previous.classList.add('disabled');
subject.next.classList.add('disabled');
});

test('the edges should be enabled', function() {
wrapperLaunch(google);
assert.isFalse(subject.previous.classList.contains('disabled'));
assert.isFalse(subject.next.classList.contains('disabled'));
});
});

suite('When the setting is enabled', function() {
setup(function() {
subject.lifecycleEnabled = true;
MockSettingsListener.mCallbacks['edgesgesture.enabled'](false);
subject.previous.classList.add('disabled');
subject.next.classList.add('disabled');

appLaunch(dialer);
launchTransitionEnd(dialer);
});

teardown(function() {
Expand Down Expand Up @@ -265,7 +235,7 @@ suite('system/EdgeSwipeDetector >', function() {
subject.previous.classList.remove('disabled');
subject.next.classList.remove('disabled');

appLaunch(dialer);
launchTransitionEnd(dialer);
});

teardown(function() {
Expand Down
56 changes: 56 additions & 0 deletions apps/system/test/unit/statusbar_test.js
Expand Up @@ -2118,6 +2118,26 @@ suite('system/Statusbar', function() {
assert.isFalse(StatusBar.element.classList.contains('hidden'));
}

function testEventThatNotShowsIfSwipeDetected(event) {
var currentApp = {
getTopMostWindow: function getTopMostWindow() {
return this._topWindow;
}
};
Service.currentApp = currentApp;
var evt = new CustomEvent(event, {detail: currentApp});
StatusBar.element.classList.add('hidden');
StatusBar.handleEvent(evt);
assert.isTrue(setAppearanceStub.called);
assert.isTrue(setAppearanceStub.calledWith(currentApp));
assert.isTrue(StatusBar.element.classList.contains('hidden'));
}

function dispatchEdgeSwipeEvent(event) {
var evt = new CustomEvent(event);
StatusBar.handleEvent(evt);
}

function testEventThatPause(event) {
var evt = new CustomEvent(event);
StatusBar.handleEvent(evt);
Expand All @@ -2135,12 +2155,20 @@ suite('system/Statusbar', function() {
assert.isFalse(StatusBar.isPaused());
}

function testEventThatResumeIfNeeded(event) {
var evt = new CustomEvent(event);
StatusBar.handleEvent(evt);
assert.isTrue(resumeUpdateStub.called);
assert.isFalse(StatusBar.element.classList.contains('hidden'));
}

setup(function() {
app = {};
MockService.currentApp = app;
setAppearanceStub = this.sinon.stub(StatusBar, 'setAppearance');
pauseUpdateStub = this.sinon.stub(StatusBar, 'pauseUpdate');
resumeUpdateStub = this.sinon.stub(StatusBar, 'resumeUpdate');
StatusBar._pausedForGesture = false;
});

test('stackchanged', function() {
Expand Down Expand Up @@ -2233,6 +2261,34 @@ suite('system/Statusbar', function() {
test('cardviewclosed', function() {
testEventThatResume.bind(this)('cardviewclosed');
});

suite('handle events with swipe detected', function() {
setup(function() {
StatusBar.element.classList.add('hidden');
dispatchEdgeSwipeEvent('sheets-gesture-begin');
dispatchEdgeSwipeEvent('sheets-gesture-begin');
this.sinon.stub(StatusBar, 'isPaused', function() {
return true;
});
});

teardown(function() {
StatusBar.element.classList.remove('hidden');
});

test('apptitlestatechanged', function() {
testEventThatNotShowsIfSwipeDetected.bind(this)('apptitlestatechanged');
});

test('activitytitlestatechanged', function() {
testEventThatNotShowsIfSwipeDetected.
bind(this)('activitytitlestatechanged');
});

test('homescreenopened', function() {
testEventThatResumeIfNeeded.bind(this)('homescreenopened');
});
});
});

suite('Label icon width', function() {
Expand Down

0 comments on commit 0fe45b1

Please sign in to comment.