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 #26297 from gmarty/Bug-1095142-Dialer-screen-does-…
Browse files Browse the repository at this point in the history
…not-fully-cover-lockscreen a=bajaj

Bug 1095142 - [SHB] Dialer screen does not fully cover lockscreen
Conflicts:
	apps/system/js/attention_window_manager.js
	apps/system/js/layout_manager.js
	apps/system/test/unit/layout_manager_test.js
  • Loading branch information
gmarty authored and KWierso committed Nov 26, 2014
1 parent b711909 commit f20bbb0
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 21 deletions.
4 changes: 2 additions & 2 deletions apps/system/js/app_window.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@
}
// Resize only the overlays not the app
var width = layoutManager.width;
var height = layoutManager.height;
var height = layoutManager.getHeightFor(this);

this.iframe.style.width = this.width + 'px';
this.iframe.style.height = this.height + 'px';
Expand Down Expand Up @@ -1372,7 +1372,7 @@
*/
this.broadcast('withoutkeyboard');
}
height = layoutManager.height;
height = layoutManager.getHeightFor(this);

// If we have sidebar in the future, change layoutManager then.
width = layoutManager.width;
Expand Down
13 changes: 13 additions & 0 deletions apps/system/js/attention_window_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
case 'attentionopened':
this._openedInstances.set(attention, attention);
this.updateAttentionIndicator();
this.publish('-activated');
this.updateClassState();
break;

case 'attentionrequestclose':
Expand Down Expand Up @@ -152,6 +154,7 @@
this.publish('attention-inactive');
}
this.updateAttentionIndicator();
this.updateClassState();
break;

case 'attentionrequestopen':
Expand Down Expand Up @@ -197,6 +200,7 @@
}
this._openedInstances.delete(attention);
this.updateAttentionIndicator();
this.updateClassState();
break;

case 'home':
Expand Down Expand Up @@ -247,6 +251,15 @@
this.attentionIndicator.show();
}
},
updateClassState: function() {
// XXX We set a class to screen to allow overriding the screen.lock class.
// When we get rid of screen.lock in the future, this can go away safely.
if (this._instances.length) {
this.screen.classList.add('attention');
} else {
this.screen.classList.remove('attention');
}
},
closeAllAttentionWindows: function() {
this._openedInstances.forEach(function(value) {
value.close();
Expand Down
21 changes: 20 additions & 1 deletion apps/system/js/layout_manager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global KeyboardManager, softwareButtonManager, System,
AppWindowManager */
AppWindowManager, AttentionWindow */
'use strict';

(function(exports) {
Expand Down Expand Up @@ -79,6 +79,25 @@
0 : softwareButtonManager.width);
},

getHeightFor: function(currentWindow) {
if (currentWindow instanceof AttentionWindow) {
var keyboardHeight = this.keyboardEnabled ?
inputWindowManager.getHeight() : 0;
var height = window.innerHeight - keyboardHeight -
softwareButtonManager.height;

// Normalizing the height so that it always translates to an integral
// number of device pixels
var dpx = window.devicePixelRatio;
if ((height * dpx) % 1 !== 0) {
height = Math.ceil(height * dpx) / dpx;
}

return height;
}
return this.height;
},

/**
* Match the given size with current layout.
* @param {Number} width The matched width.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
}

#screen:not(.locked) #software-buttons.visible,
#screen.locked.attention #software-buttons.visible,
#screen.locked.secure-app #software-buttons.visible {
transform: translateY(-100%);
visibility: visible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

var assert = require('assert');
var System = require('./lib/system');
var FakeDialerApp = require('./lib/fakedialerapp.js');
var LockScreen = require('./lib/lockscreen');
var FakeDialerApp = require('./lib/fakedialerapp');

marionette('Software Home Button - Lockscreen Appearance', function() {
marionette('Software Home Button - Attention window', function() {
var apps = {};
apps[FakeDialerApp.DEFAULT_ORIGIN] = __dirname + '/fakedialerapp';

Expand All @@ -21,40 +22,43 @@ marionette('Software Home Button - Lockscreen Appearance', function() {
apps: apps
});
var system;
var lockScreen;
var fakedialer;

setup(function() {
system = new System(client);
system.waitForStartup();

fakedialer = new FakeDialerApp(client);
lockScreen = (new LockScreen()).start(client);
system.waitForStartup();
});

test('Call screen should be full height', function() {
fakedialer.launch();
fakedialer.waitForTitleShown(true);
client.switchToFrame();

function checkHeight() {
function rect(el) {
return el.getBoundingClientRect();
}

fakedialer.launch();
fakedialer.waitForTitleShown(true);
client.switchToFrame();

var winHeight = client.findElement('body').size().height;
client.waitFor(function() {
var attentionWindow =
client.helper.waitForElement('.attentionWindow.active');
var attentionWindowRect = attentionWindow.scriptWith(rect);

return winHeight === attentionWindowRect.height;
return winHeight >= attentionWindowRect.height;
});

assert.ok(system.softwareHome.displayed());
}

test('should show the SHB on locked screen', function() {
checkHeight();
});

test('Does not appear on lockscreen with an incoming call', function() {
var buttons = [
'softwareHome', 'softwareHomeFullscreen', 'softwareHomeFullscreenLayout'
];
buttons.forEach(function(buttonName) {
assert.ok(!system[buttonName].displayed());
});
test('should show the SHB on unlocked screen', function() {
lockScreen.unlock();
checkHeight();
});
});
31 changes: 30 additions & 1 deletion apps/system/test/unit/layout_manager_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ requireApp('system/test/unit/mock_lock_screen.js');
requireApp('system/test/unit/mock_keyboard_manager.js');
requireApp('system/test/unit/mock_app_window_manager.js');
requireApp('system/test/unit/mock_software_button_manager.js');
require('/test/unit/mock_app_window.js');
require('/test/unit/mock_attention_window.js');
require('/js/input_window_manager.js');

var mocksForLayoutManager = new MocksHelper([
'AppWindowManager',
'KeyboardManager',
'softwareButtonManager',
'LockScreen',
'System'
'Service',
'AttentionWindow'
]).init();

suite('system/LayoutManager >', function() {
Expand Down Expand Up @@ -196,7 +201,7 @@ suite('system/LayoutManager >', function() {
});
});

suite('dimentions >', () => {
suite('dimensions >', () => {
var H, W, _w;
setup(() => {
H = window.innerHeight;
Expand Down Expand Up @@ -224,4 +229,28 @@ suite('system/LayoutManager >', function() {
assert.equal(layoutManager.clientWidth, _w);
});
});

suite('getHeightFor()', function() {
setup(function() {
MocksoftwareButtonManager.height = 50;
MockService.locked = false;
});

test('should return the height for regular windows', function() {
assert.equal(layoutManager.height, layoutManager.getHeightFor({}));
});

test('should return the height for regular windows on lockscreen',
function() {
MockService.locked = true;
assert.equal(layoutManager.height, layoutManager.getHeightFor({}));
});

test('should consider SHB on attention windows and lockscreen', function() {
MockService.locked = true;
var attentionWindow = new window.AttentionWindow();
assert.operator(layoutManager.getHeightFor({}), '>',
layoutManager.getHeightFor(attentionWindow));
});
});
});
3 changes: 3 additions & 0 deletions apps/system/test/unit/mock_layout_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
match: function() {
return true;
},
getHeightFor: function() {
return this.height;
},
start: function() {
return this;
},
Expand Down

0 comments on commit f20bbb0

Please sign in to comment.