Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1080812 - Fixing performance test issue with screen timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
eliperelman authored and rvandermeulen committed Oct 17, 2014
1 parent 5e4e19d commit 1ea7494
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 89 deletions.
Expand Up @@ -3,7 +3,6 @@
var assert = require('assert');

requireGaia('/dev_apps/test-agent/common/test/synthetic_gestures.js');
var MarionetteHelper = requireGaia('/tests/js-marionette/helper.js');

var PerformanceHelper =
requireGaia('/tests/performance/performance_helper.js');
Expand All @@ -12,7 +11,8 @@ var DialerIntegration = require('./integration.js');
marionette(config.appPath + ' >', function() {
var client = marionette.client({
settings: {
'ftu.manifestURL': null
'ftu.manifestURL': null,
'lockscreen.enabled': false
}
});
// Do nothing on script timeout. Bug 987383
Expand All @@ -21,11 +21,7 @@ marionette(config.appPath + ' >', function() {
setup(function() {
this.timeout(config.timeout);
client.setScriptTimeout(config.scriptTimeout);

// inject perf event listener
PerformanceHelper.injectHelperAtom(client);

MarionetteHelper.unlockScreen(client);
});

test('Dialer/callLog rendering time >', function() {
Expand All @@ -39,6 +35,8 @@ marionette(config.appPath + ' >', function() {
lastEvent: lastEvent
});

performanceHelper.disableScreenTimeout();

performanceHelper.repeatWithDelay(function(app, next) {
var waitForBody = true;
app.launch(waitForBody);
Expand Down
2 changes: 2 additions & 0 deletions apps/settings/test/performance/overfill_ratio_test.js
Expand Up @@ -33,6 +33,8 @@ marionette(config.appPath + ' >', function() {
lastEvent: lastEvent
});

performanceHelper.disableScreenTimeout();

function sendOverfill() {
window.wrappedJSObject.mozRequestOverfill(function result(aOverfill) {
marionetteScriptFinished(aOverfill);
Expand Down
2 changes: 2 additions & 0 deletions apps/settings/test/performance/rendering_wifi_list_test.js
Expand Up @@ -32,6 +32,8 @@ marionette(config.appPath + ' >', function() {
lastEvent: lastEvent
});

performanceHelper.disableScreenTimeout();

performanceHelper.repeatWithDelay(function(app, next) {
var waitForBody = true;
app.launch(waitForBody);
Expand Down
172 changes: 93 additions & 79 deletions tests/performance/performance_helper.js
Expand Up @@ -129,98 +129,98 @@ PerformanceHelper.reportGoal = function(goals) {
};

PerformanceHelper.prototype = {
// startValue is the name of the start event.
// By default it is 'start'
reportRunDurations: function(runResults, startValue) {

startValue = startValue || 'start';

var start = runResults[startValue] || 0;
delete runResults[startValue];

for (var name in runResults) {
var value = runResults[name] - start;
// Sometime we start from an event that happen later.
// Ignore the one that occur before - ie negative values.
if (value >= 0) {
this.results[name] = this.results[name] || [];
this.results[name].push(value);
}
// startValue is the name of the start event.
// By default it is 'start'
reportRunDurations: function(runResults, startValue) {

startValue = startValue || 'start';

var start = runResults[startValue] || 0;
delete runResults[startValue];

for (var name in runResults) {
var value = runResults[name] - start;
// Sometime we start from an event that happen later.
// Ignore the one that occur before - ie negative values.
if (value >= 0) {
this.results[name] = this.results[name] || [];
this.results[name].push(value);
}
}

},
},

finish: function() {
for (var name in this.results) {
PerformanceHelper.reportDuration(this.results[name], name);
}
},

/**
* Repeat the task 'fn' with a delay.
* Call 'callback' if exist.
*
* perf.repeatWithDelay(function(app, next) {
* app.launch();
* app.close();
* });
*
*/
repeatWithDelay: function(fn, callback) {

callback = callback || this.app.defaultCallback;

var pending = this.runs;

function nextTask(err) {
if (err) {
return callback(err);
}

if (!--pending) {
callback();
} else {
trigger();
}
finish: function() {
for (var name in this.results) {
PerformanceHelper.reportDuration(this.results[name], name);
}
},

/**
* Repeat the task 'fn' with a delay.
* Call 'callback' if exist.
*
* perf.repeatWithDelay(function(app, next) {
* app.launch();
* app.close();
* });
*
*/
repeatWithDelay: function(fn, callback) {

callback = callback || this.app.defaultCallback;

var pending = this.runs;

function nextTask(err) {
if (err) {
return callback(err);
}

var self = this;
function trigger() {
self.delay(function() {
self.task(fn, nextTask);
});
if (!--pending) {
callback();
} else {
trigger();
}
}

trigger();
},
var self = this;
function trigger() {
self.delay(function() {
self.task(fn, nextTask);
});
}

trigger();
},

/*
* Run a task 'fn', and then chain on the 'next' task.
*/
task: function(fn, next) {
var app = this.app;
next = next || app.defaultCallback;
/*
* Run a task 'fn', and then chain on the 'next' task.
*/
task: function(fn, next) {
var app = this.app;
next = next || app.defaultCallback;

fn(app);
next();
},
fn(app);
next();
},

delay: function(givenCallback) {
givenCallback = givenCallback || client.defaultCallback;
var interval = this.opts.spawnInterval;
delay: function(givenCallback) {
givenCallback = givenCallback || client.defaultCallback;
var interval = this.opts.spawnInterval;

MarionetteHelper.delay(this.app.client, interval, givenCallback);
},
MarionetteHelper.delay(this.app.client, interval, givenCallback);
},

waitForPerfEvent: function(callback) {
this.app.waitForPerfEvents(this.opts.lastEvent, callback);
},
waitForPerfEvent: function(callback) {
this.app.waitForPerfEvents(this.opts.lastEvent, callback);
},

/*
* Get the memory stats for the specified app
* as well as the main b2g.
* See bug 917717.
*/
/*
* Get the memory stats for the specified app
* as well as the main b2g.
* See bug 917717.
*/
getMemoryUsage: function(app) {
var appName = GetAppName(app);
var meminfo = MemInfo.meminfo();
Expand Down Expand Up @@ -255,6 +255,20 @@ PerformanceHelper.prototype = {
vsize: parseFloat(system.VSIZE)
}
};
},

/*
* Keep the device from "going to sleep" by disabling the screen from
* dimming and shutting off
*/
disableScreenTimeout: function() {
this.app.client.executeScript(function() {
window.wrappedJSObject.SettingsListener
.getSettingsLock()
.set({
'screen.timeout': 0
});
});
}
};

Expand Down
1 change: 1 addition & 0 deletions tests/performance/startup_events_test.js
Expand Up @@ -43,6 +43,7 @@ marionette('startup event test > ' + appPath + ' >', function() {
this.timeout(config.timeout);
client.setScriptTimeout(config.scriptTimeout);
PerformanceHelper.injectHelperAtom(client);
performanceHelper.disableScreenTimeout();
});

test('startup >', function() {
Expand Down
7 changes: 3 additions & 4 deletions tests/performance/startup_test.js
Expand Up @@ -3,7 +3,6 @@
var assert = require('assert');
var App = require('./app');
var PerformanceHelper = requireGaia('/tests/performance/performance_helper.js');
var MarionetteHelper = requireGaia('/tests/js-marionette/helper.js');
var perfUtils = require('./perf-utils');
var appPath = config.appPath;

Expand All @@ -20,7 +19,8 @@ marionette('startup test > ' + appPath + ' >', function() {
var app;
var client = marionette.client({
settings: {
'ftu.manifestURL': null
'ftu.manifestURL': null,
'lockscreen.enabled': false
}
});
// Do nothing on script timeout. Bug 987383
Expand All @@ -39,13 +39,12 @@ marionette('startup test > ' + appPath + ' >', function() {
this.timeout(config.timeout);
// Marionnette timeout for each command sent to the device
client.setScriptTimeout(config.scriptTimeout);

MarionetteHelper.unlockScreen(client);
});

test('startup time', function() {

performanceHelper = new PerformanceHelper({ app: app });
performanceHelper.disableScreenTimeout();

PerformanceHelper.registerLoadTimeListener(client);

Expand Down

0 comments on commit 1ea7494

Please sign in to comment.