mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 20:47:44 +00:00
f74b4d25f0
--HG-- extra : rebase_source : 15f48894284051c2f10d9b71c94d7074f893002a
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
/**
|
|
* Tests that the details view toggles subviews.
|
|
*/
|
|
function* spawnTest() {
|
|
let { panel } = yield initPerformance(SIMPLE_URL);
|
|
let { EVENTS, $, DetailsView, document: doc } = panel.panelWin;
|
|
|
|
yield startRecording(panel);
|
|
yield stopRecording(panel);
|
|
|
|
info("views on startup");
|
|
checkViews(DetailsView, doc, "waterfall");
|
|
|
|
// Select calltree view
|
|
let viewChanged = onceSpread(DetailsView, EVENTS.DETAILS_VIEW_SELECTED);
|
|
command($("toolbarbutton[data-view='js-calltree']"));
|
|
let [_, viewName] = yield viewChanged;
|
|
is(viewName, "js-calltree", "DETAILS_VIEW_SELECTED fired with view name");
|
|
checkViews(DetailsView, doc, "js-calltree");
|
|
|
|
// Select flamegraph view
|
|
viewChanged = onceSpread(DetailsView, EVENTS.DETAILS_VIEW_SELECTED);
|
|
command($("toolbarbutton[data-view='js-flamegraph']"));
|
|
[_, viewName] = yield viewChanged;
|
|
is(viewName, "js-flamegraph", "DETAILS_VIEW_SELECTED fired with view name");
|
|
checkViews(DetailsView, doc, "js-flamegraph");
|
|
|
|
// Select waterfall view
|
|
viewChanged = onceSpread(DetailsView, EVENTS.DETAILS_VIEW_SELECTED);
|
|
command($("toolbarbutton[data-view='waterfall']"));
|
|
[_, viewName] = yield viewChanged;
|
|
is(viewName, "waterfall", "DETAILS_VIEW_SELECTED fired with view name");
|
|
checkViews(DetailsView, doc, "waterfall");
|
|
|
|
yield teardown(panel);
|
|
finish();
|
|
}
|
|
|
|
function checkViews (DetailsView, doc, currentView) {
|
|
for (let viewName in DetailsView.components) {
|
|
let button = doc.querySelector(`toolbarbutton[data-view="${viewName}"]`);
|
|
|
|
is(DetailsView.el.selectedPanel.id, DetailsView.components[currentView].id,
|
|
`DetailsView correctly has ${currentView} selected.`);
|
|
if (viewName === currentView) {
|
|
ok(button.getAttribute("checked"), `${viewName} button checked`);
|
|
} else {
|
|
ok(!button.getAttribute("checked"), `${viewName} button not checked`);
|
|
}
|
|
}
|
|
}
|