From 6ccdd9eba206e7ef8b73189b087bc54fa7ed3da9 Mon Sep 17 00:00:00 2001 From: Alive Kuo Date: Wed, 17 Sep 2014 11:34:45 +0800 Subject: [PATCH] Bug 1066869 - Do not wait transition to show contact photo anymore --- apps/callscreen/js/call_screen.js | 31 +-------- apps/callscreen/test/unit/call_screen_test.js | 65 ------------------- 2 files changed, 3 insertions(+), 93 deletions(-) diff --git a/apps/callscreen/js/call_screen.js b/apps/callscreen/js/call_screen.js index 9304794a05a8..e5ba0761877c 100644 --- a/apps/callscreen/js/call_screen.js +++ b/apps/callscreen/js/call_screen.js @@ -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() { diff --git a/apps/callscreen/test/unit/call_screen_test.js b/apps/callscreen/test/unit/call_screen_test.js index 5d86a2671347..76686a49a0e9 100755 --- a/apps/callscreen/test/unit/call_screen_test.js +++ b/apps/callscreen/test/unit/call_screen_test.js @@ -395,54 +395,16 @@ 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); @@ -450,30 +412,6 @@ suite('call screen', function() { }); }); }); - - 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(); - }); - }); - }); }); }); @@ -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'}); @@ -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();