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 #24122 from alivedise/bugzilla/1066869/show-contac…
Browse files Browse the repository at this point in the history
…t-image-correctly

Bug 1066869 - Do not wait transition to show contact photo anymore, r=etienne
  • Loading branch information
alivedise committed Sep 17, 2014
2 parents 0d11eae + 6ccdd9e commit ead625f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 93 deletions.
31 changes: 3 additions & 28 deletions apps/callscreen/js/call_screen.js
Expand Up @@ -267,35 +267,10 @@ var CallScreen = {
return;
}

var screen = this.screen;

// If we toggle the class during the transition we'll loose the
// transitionend ; and we have no opening transition for incoming locked
var skipTransition = this._transitioning ||
(this.screen.dataset.layout === 'incoming-locked');

if (skipTransition) {
if (callback && typeof(callback) == 'function') {
setTimeout(callback);
}
this._onTransitionDone();
return;
if (callback && typeof(callback) == 'function') {
setTimeout(callback);
}

/* We need CSS transitions for the status bar state and the regular state */
var self = this;
self._transitioning = true;
screen.addEventListener('transitionend', function trWait(evt) {
if (evt.target != screen) {
return;
}
screen.removeEventListener('transitionend', trWait);
self._transitioning = false;
if (callback && typeof(callback) == 'function') {
callback();
}
self._onTransitionDone();
});
this._onTransitionDone();
},

_onTransitionDone: function cs_onTransitionDone() {
Expand Down
65 changes: 0 additions & 65 deletions apps/callscreen/test/unit/call_screen_test.js
Expand Up @@ -395,85 +395,23 @@ suite('call screen', function() {
});

suite('once the wallpaper is loaded', function() {
suite('when a callback is given', function() {
var addEventListenerSpy;
var removeEventListenerSpy;
var spyCallback;

setup(function() {
addEventListenerSpy = this.sinon.spy(screen, 'addEventListener');
removeEventListenerSpy = this.sinon.spy(screen,
'removeEventListener');
spyCallback = this.sinon.spy();
CallScreen.toggle(spyCallback);
});

test('should listen for transitionend', function() {
assert.isTrue(addEventListenerSpy.calledWith('transitionend'));
});

suite('once the transition ended', function() {
setup(function() {
addEventListenerSpy.yield({target: screen});
});

test('should remove the event listener', function() {
assert.isTrue(removeEventListenerSpy.calledWith('transitionend'));
});

test('should trigger the callback', function() {
assert.isTrue(spyCallback.calledOnce);
});
});
});

suite('when opening in incoming-locked mode', function() {
var addEventListenerSpy;
var spyCallback;

setup(function() {
CallScreen.screen.dataset.layout = 'incoming-locked';
addEventListenerSpy = this.sinon.spy(screen, 'addEventListener');
spyCallback = this.sinon.spy();

CallScreen.toggle(spyCallback);
});

test('should not listen for transitionend', function() {
assert.isFalse(addEventListenerSpy.called);
});

test('should call the callback', function(done) {
setTimeout(function() {
assert.isTrue(spyCallback.called);
done();
});
});
});

suite('when toggling again in the middle of a transition', function() {
var addEventListenerSpy;
var spyCallback;

setup(function() {
addEventListenerSpy = this.sinon.spy(screen, 'addEventListener');
spyCallback = this.sinon.spy();

CallScreen.toggle(spyCallback);
CallScreen.toggle(spyCallback);
});

test('should not wait for transitionend the second time', function() {
assert.isTrue(addEventListenerSpy.calledOnce);
});

test('should call the callback once', function(done) {
setTimeout(function() {
assert.isTrue(spyCallback.calledOnce);
done();
});
});
});
});
});

Expand All @@ -491,8 +429,6 @@ suite('call screen', function() {
});

test('it should wait for the transition to be over', function(done) {
var addEventListenerSpy = this.sinon.spy(screen, 'addEventListener');

MockCallsHandler.mActiveCallForContactImage = new MockHandledCall();
MockCallsHandler.mActiveCallForContactImage.photo =
new Blob([], {type: 'image/png'});
Expand All @@ -503,7 +439,6 @@ suite('call screen', function() {
CallScreen.toggle();

setTimeout(function() {
addEventListenerSpy.yield({target: screen});
assert.ok(CallScreen.contactBackground.style.backgroundImage);
CallScreen.setCallerContactImage();
done();
Expand Down

0 comments on commit ead625f

Please sign in to comment.