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 #33675 from snowmantw/bug1235105
Browse files Browse the repository at this point in the history
Bug 1235105 - Add integration test: |lockscreen_unlock_handler_test.js| to see if the slider will reset to default after the relocking
  • Loading branch information
snowmantw committed Dec 26, 2015
2 parents 8ca3e10 + e199ed0 commit 0fac66f
Showing 1 changed file with 110 additions and 0 deletions.
110 changes: 110 additions & 0 deletions apps/system/test/marionette/lockscreen_unlock_handler_test.js
@@ -0,0 +1,110 @@

'use strict';

var dirapps = require('path').resolve(__dirname + '/../../../');
var Settings = require(dirapps + '/settings/test/marionette/app/app'),
LockScreen = require('./lib/lockscreen'),
Promise = require('es6-promise').Promise, // jshint ignore:line
assert = require('assert');

marionette('LockScreen > ', function() {
var client = marionette.client({
desiredCapabilities: { raisesAccessibilityExceptions: false }
});
var system;
var settingsApp;
var screenLockPanel;
var lockScreen;

setup(function() {
system = client.loader.getAppClass('system');
lockScreen = (new LockScreen()).start(client);
settingsApp = new Settings(client);
settingsApp.launch();
// Navigate to the ScreenLock menu
screenLockPanel = settingsApp.screenLockPanel;
screenLockPanel.setupScreenLock();
screenLockPanel.toggleScreenLock();
});

var setupPasscode = function() {
screenLockPanel.togglePasscodeLock();
screenLockPanel.typePasscode('1234', '1234');
screenLockPanel.tapCreatePasscode();
settingsApp.close();
lockScreen.lock();
};

var setupWithoutPasscode = function() {
settingsApp.close();
lockScreen.lock();
};

test('slide to the unlock handler without the passcode, and then check ' +
'if the slider will reset after lock it again',
function(done) {
setupWithoutPasscode();
client.switchToFrame();
new Promise(function(resolve) {
lockScreen.slideToUnlock(resolve);
})
.then(function() {
client.executeScript(function() {
window.wrappedJSObject.Service.request('turnScreenOff', true);
window.wrappedJSObject.Service.request('turnScreenOn', true);
});

client.waitFor(function() {
return client.findElement('#lockscreen').displayed();
});

// From UI to check if it's back to the original style.
// We cannot check if the canvas 'element' is streched or not.
// If it's not reset the class `dark` will not attach on it.
assert.ok(client.executeScript(function() {
return document.querySelector('#lockscreen-area-unlock')
.classList.contains('dark');
}));
})
.then(done)
.catch(done);
});

test('slide to the unlock handler with the passcode, and then check ' +
'if the slider will reset after lock it again',
function(done) {
setupPasscode();
client.switchToFrame();
new Promise(function(resolve) {
lockScreen.slideToUnlock(resolve);
})
.then(function() {
// Wait for the panel rising.
client.waitFor(function() {
return client.findElement('#lockscreen-passcode-code').displayed();
});

client.executeScript(function() {
window.wrappedJSObject.Service.request('turnScreenOff', true);
window.wrappedJSObject.Service.request('turnScreenOn', true);
});

client.waitFor(function() {
return client.findElement('#lockscreen').displayed();
});

assert.ok(!client.findElement('#lockscreen-passcode-pad').displayed());

// From UI to check if it's back to the original style.
// We cannot check if the canvas 'element' is streched or not.
// If it's not reset the class `dark` will not attach on it.
assert.ok(client.executeScript(function() {
return document.querySelector('#lockscreen-area-unlock')
.classList.contains('dark');
}));
})
.then(done)
.catch(done);
});

});

0 comments on commit 0fac66f

Please sign in to comment.