Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
106 lines
3.2 KiB
JavaScript
Executable file
106 lines
3.2 KiB
JavaScript
Executable file
'use strict';
|
|
/* global __dirname */
|
|
|
|
marionette('Find My Device lock >', function() {
|
|
var assert = require('assert');
|
|
|
|
var FINDMYDEVICE_TEST_APP = 'app://test-findmydevice.gaiamobile.org';
|
|
var SETTINGS_DIGEST_VALUE = 'lockscreen.passcode-lock.digest.value';
|
|
|
|
var client = marionette.client({
|
|
profile: {
|
|
apps: {
|
|
'test-findmydevice.gaiamobile.org':
|
|
__dirname + '/fixtures/test-findmydevice',
|
|
}
|
|
}
|
|
});
|
|
|
|
setup(function() {
|
|
// launch the test app
|
|
client.apps.launch(FINDMYDEVICE_TEST_APP);
|
|
client.apps.switchToApp(FINDMYDEVICE_TEST_APP);
|
|
client.helper.waitForElement('body');
|
|
});
|
|
|
|
test('Lock the screen through the test app', function() {
|
|
var messageText = 'This phone is lost.';
|
|
var messageInput = client.findElement('input[name="message"]');
|
|
messageInput.sendKeys(messageText);
|
|
|
|
client.switchToFrame();
|
|
var oldDigest = client.settings.get(SETTINGS_DIGEST_VALUE);
|
|
client.apps.switchToApp(FINDMYDEVICE_TEST_APP);
|
|
var passcode = '4567';
|
|
var passcodeInput = client.findElement('input[name="code"]');
|
|
passcodeInput.sendKeys(passcode);
|
|
|
|
var lockButton = client.findElement('#lock');
|
|
lockButton.click();
|
|
|
|
// XXX: After we make LockScreen as an iframe or app, this should be the
|
|
// line to switch to LockScreen frame.
|
|
client.switchToFrame();
|
|
var lockscreen = client.findElement('#lockscreen');
|
|
client.waitFor(function() {
|
|
return lockscreen.displayed();
|
|
});
|
|
|
|
var lockscreenMessage = client.findElement('#lockscreen-message');
|
|
client.waitFor(function() {
|
|
var text = lockscreenMessage.text();
|
|
if (text !== '') {
|
|
assert.equal(lockscreenMessage.text(), messageText);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
});
|
|
|
|
// sanity-check the settings we should have set
|
|
var settings = {
|
|
'lockscreen.enabled': true,
|
|
'lockscreen.passcode-lock.enabled': true,
|
|
'lockscreen.notifications-preview.enabled': false,
|
|
'lockscreen.lock-message': messageText,
|
|
};
|
|
for (var s in settings) {
|
|
assert.equal(client.settings.get(s), settings[s]);
|
|
}
|
|
// checking if passcode was changed:
|
|
var newDigest = client.settings.get(SETTINGS_DIGEST_VALUE);
|
|
assert.notEqual(newDigest, oldDigest);
|
|
|
|
client.switchToFrame();
|
|
|
|
// now unlock the screen and re-lock it, the message should disappear
|
|
client.executeScript(function() {
|
|
window.wrappedJSObject.Service.request('unlock');
|
|
});
|
|
|
|
client.waitFor(function() {
|
|
return client.executeScript(function() {
|
|
return !window.wrappedJSObject.Service.locked;
|
|
});
|
|
});
|
|
|
|
client.executeScript(function() {
|
|
window.wrappedJSObject.Service.request('lock');
|
|
});
|
|
|
|
// XXX: After we make LockScreen as an iframe or app, this should be the
|
|
// line to switch to LockScreen frame.
|
|
client.switchToFrame();
|
|
lockscreen = client.findElement('#lockscreen');
|
|
client.waitFor(function() {
|
|
return lockscreen.displayed();
|
|
});
|
|
|
|
lockscreenMessage = client.findElement('#lockscreen-message');
|
|
client.waitFor(function() {
|
|
return !lockscreenMessage.displayed();
|
|
});
|
|
|
|
assert.equal(client.settings.get('lockscreen.lock-message'), '');
|
|
});
|
|
});
|