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 #8714 from jaoo/852537
Browse files Browse the repository at this point in the history
Bug 852537 - [Settings] Create performance test for the WiFi network lis...
  • Loading branch information
jaoo committed Mar 25, 2013
2 parents 9718ace + 6d935b8 commit 12174ec
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 4 deletions.
3 changes: 3 additions & 0 deletions apps/settings/index.html
Expand Up @@ -32,6 +32,9 @@
<script defer src="shared/js/l10n.js"></script>
<script defer src="shared/js/l10n_date.js"></script>

<!-- For perf-measurement related utilities -->
<script defer src="/shared/js/performance_testing_helper.js"></script>

<!-- Specific code -->
<script defer src="js/settings.js"></script>

Expand Down
17 changes: 13 additions & 4 deletions apps/settings/js/settings.js
Expand Up @@ -649,6 +649,10 @@ window.addEventListener('load', function loadSettings() {
function showPanel() {
var hash = window.location.hash;

if (hash === '#wifi') {
PerformanceTestingHelper.dispatch('start');
}

var oldPanel = document.querySelector(oldHash);
var newPanel = document.querySelector(hash);

Expand Down Expand Up @@ -694,10 +698,15 @@ window.addEventListener('load', function loadSettings() {

oldPanel.addEventListener('transitionend', function onTransitionEnd() {
oldPanel.removeEventListener('transitionend', onTransitionEnd);
// Workaround for bug 825622, remove when fixed
if (newPanel.id == 'about-licensing') {
var iframe = document.getElementById('os-license');
iframe.src = iframe.dataset.src;
switch (newPanel.id) {
case 'about-licensing':
// Workaround for bug 825622, remove when fixed
var iframe = document.getElementById('os-license');
iframe.src = iframe.dataset.src;
break;
case 'wifi':
PerformanceTestingHelper.dispatch('settings-panel-wifi-visible');
break;
}
});
});
Expand Down
5 changes: 5 additions & 0 deletions apps/settings/js/wifi.js
Expand Up @@ -350,6 +350,8 @@ navigator.mozL10n.ready(function wifiSettings() {
// display the "Search Again" button
list.dataset.state = 'ready';

PerformanceTestingHelper.dispatch('settings-panel-wifi-ready');

// auto-rescan if requested
if (autoscan) {
window.setTimeout(scan, scanRate);
Expand All @@ -361,6 +363,9 @@ navigator.mozL10n.ready(function wifiSettings() {
req.onerror = function onScanError(error) {
// always try again.
scanning = false;

PerformanceTestingHelper.dispatch('settings-panel-wifi-ready');

window.setTimeout(scan, scanRate);
};
}
Expand Down
18 changes: 18 additions & 0 deletions apps/settings/test/integration/app.js
@@ -0,0 +1,18 @@
'use strict';

require('/tests/js/app_integration.js');
require('/tests/js/integration_helper.js');

function SettingsIntegration(device) {
AppIntegration.apply(this, arguments);
}

SettingsIntegration.prototype = {
__proto__: AppIntegration.prototype,
appName: 'Settings',
manifestURL: 'app://settings.gaiamobile.org/manifest.webapp',

selectors: {
wifiSelector: '#menuItem-wifi'
}
};
48 changes: 48 additions & 0 deletions apps/settings/test/performance/rendering_wifi_list_test.js
@@ -0,0 +1,48 @@
'use strict';

requireCommon('test/synthetic_gestures.js');
require('/tests/performance/performance_helper.js');
require('apps/settings/test/integration/app.js');

suite(window.mozTestInfo.appPath + ' >', function() {
var device;
var app;

MarionetteHelper.start(function(client) {
app = new SettingsIntegration(client);
device = app.device;
});

setup(function() {
// It affects the first run otherwise
yield IntegrationHelper.unlock(device);
});

test('rendering WiFi list >', function() {
this.timeout(500000);
yield device.setScriptTimeout(50000);

var lastEvent = 'settings-panel-wifi-ready';

var performanceHelper = new PerformanceHelper({
app: app,
lastEvent: lastEvent
});

yield performanceHelper.repeatWithDelay(function(app, next) {
var waitForBody = true;
yield app.launch(waitForBody);

var wifiSubpanel = yield app.element('wifiSelector');
yield wifiSubpanel.singleTap();

var runResults = yield performanceHelper.observe(next);
performanceHelper.reportRunDurations(runResults);

yield app.close();
});

performanceHelper.finish();

});
});

0 comments on commit 12174ec

Please sign in to comment.