gecko-dev/browser/devtools/performance/test/browser_profiler_tree-view-01.js

96 lines
3.8 KiB
JavaScript
Raw Normal View History

2014-08-06 15:25:18 +00:00
/* Any copyright is dedicated to the Public Domain.
http://foo/bar/creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests if the profiler's tree view implementation works properly and
* creates the correct column structure.
*/
function test() {
Bug 1101235 - Move tree utilities out of profiler, r=vp --HG-- rename : browser/devtools/profiler/test/browser_profiler_categories.js => browser/devtools/performance/test/browser_profiler_categories.js rename : browser/devtools/profiler/test/browser_profiler_content-check.js => browser/devtools/performance/test/browser_profiler_content-check.js rename : browser/devtools/profiler/test/browser_profiler_tree-abstract-01.js => browser/devtools/performance/test/browser_profiler_tree-abstract-01.js rename : browser/devtools/profiler/test/browser_profiler_tree-abstract-02.js => browser/devtools/performance/test/browser_profiler_tree-abstract-02.js rename : browser/devtools/profiler/test/browser_profiler_tree-abstract-03.js => browser/devtools/performance/test/browser_profiler_tree-abstract-03.js rename : browser/devtools/profiler/test/browser_profiler_tree-abstract-04.js => browser/devtools/performance/test/browser_profiler_tree-abstract-04.js rename : browser/devtools/profiler/test/browser_profiler_tree-frame-node.js => browser/devtools/performance/test/browser_profiler_tree-frame-node.js rename : browser/devtools/profiler/test/browser_profiler_tree-model-01.js => browser/devtools/performance/test/browser_profiler_tree-model-01.js rename : browser/devtools/profiler/test/browser_profiler_tree-model-02.js => browser/devtools/performance/test/browser_profiler_tree-model-02.js rename : browser/devtools/profiler/test/browser_profiler_tree-model-03.js => browser/devtools/performance/test/browser_profiler_tree-model-03.js rename : browser/devtools/profiler/test/browser_profiler_tree-model-04.js => browser/devtools/performance/test/browser_profiler_tree-model-04.js rename : browser/devtools/profiler/test/browser_profiler_tree-model-05.js => browser/devtools/performance/test/browser_profiler_tree-model-05.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-01.js => browser/devtools/performance/test/browser_profiler_tree-view-01.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-02.js => browser/devtools/performance/test/browser_profiler_tree-view-02.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-03.js => browser/devtools/performance/test/browser_profiler_tree-view-03.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-04.js => browser/devtools/performance/test/browser_profiler_tree-view-04.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-05.js => browser/devtools/performance/test/browser_profiler_tree-view-05.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-06.js => browser/devtools/performance/test/browser_profiler_tree-view-06.js rename : browser/devtools/profiler/test/browser_profiler_tree-view-07.js => browser/devtools/performance/test/browser_profiler_tree-view-07.js rename : browser/devtools/timeline/test/browser_timeline_blueprint.js => browser/devtools/performance/test/browser_timeline_blueprint.js rename : browser/devtools/profiler/utils/global.js => browser/devtools/shared/profiler/global.js rename : browser/devtools/profiler/utils/tree-model.js => browser/devtools/shared/profiler/tree-model.js rename : browser/devtools/profiler/utils/tree-view.js => browser/devtools/shared/profiler/tree-view.js rename : browser/devtools/timeline/widgets/global.js => browser/devtools/shared/timeline/global.js rename : browser/devtools/timeline/widgets/marker-details.js => browser/devtools/shared/timeline/marker-details.js rename : browser/devtools/timeline/widgets/markers-overview.js => browser/devtools/shared/timeline/markers-overview.js rename : browser/devtools/timeline/widgets/memory-overview.js => browser/devtools/shared/timeline/memory-overview.js rename : browser/devtools/timeline/widgets/waterfall.js => browser/devtools/shared/timeline/waterfall.js
2015-02-11 20:23:32 +00:00
let { ThreadNode } = devtools.require("devtools/shared/profiler/tree-model");
let { CallView } = devtools.require("devtools/shared/profiler/tree-view");
2014-08-06 15:25:18 +00:00
let threadNode = new ThreadNode(gSamples);
let treeRoot = new CallView({ frame: threadNode });
let container = document.createElement("vbox");
treeRoot.autoExpandDepth = 0;
treeRoot.attachTo(container);
is(container.childNodes.length, 1,
"The container node should have one child available.");
is(container.childNodes[0].className, "call-tree-item",
"The root node in the tree has the correct class name.");
is(container.childNodes[0].childNodes.length, 6,
2014-08-06 15:25:18 +00:00
"The root node in the tree has the correct number of children.");
is(container.childNodes[0].querySelectorAll(".call-tree-cell").length, 6,
"The root node in the tree has only 6 'call-tree-cell' children.");
2014-08-06 15:25:18 +00:00
is(container.childNodes[0].childNodes[0].getAttribute("type"), "duration",
"The root node in the tree has a duration cell.");
is(container.childNodes[0].childNodes[0].getAttribute("value"), "15 ms",
2014-08-06 15:25:18 +00:00
"The root node in the tree has the correct duration cell value.");
is(container.childNodes[0].childNodes[1].getAttribute("type"), "percentage",
2014-08-06 15:25:18 +00:00
"The root node in the tree has a percentage cell.");
is(container.childNodes[0].childNodes[1].getAttribute("value"), "100%",
2014-08-06 15:25:18 +00:00
"The root node in the tree has the correct percentage cell value.");
is(container.childNodes[0].childNodes[2].getAttribute("type"), "self-duration",
"The root node in the tree has a self-duration cell.");
is(container.childNodes[0].childNodes[2].getAttribute("value"), "0 ms",
"The root node in the tree has the correct self-duration cell value.");
is(container.childNodes[0].childNodes[3].getAttribute("type"), "self-percentage",
"The root node in the tree has a self-percentage cell.");
is(container.childNodes[0].childNodes[3].getAttribute("value"), "0%",
"The root node in the tree has the correct self-percentage cell value.");
is(container.childNodes[0].childNodes[4].getAttribute("type"), "samples",
"The root node in the tree has an samples cell.");
is(container.childNodes[0].childNodes[4].getAttribute("value"), "4",
"The root node in the tree has the correct samples cell value.");
2014-08-06 15:25:18 +00:00
is(container.childNodes[0].childNodes[5].getAttribute("type"), "function",
2014-08-06 15:25:18 +00:00
"The root node in the tree has a function cell.");
is(container.childNodes[0].childNodes[5].style.MozMarginStart, "0px",
2014-08-06 15:25:18 +00:00
"The root node in the tree has the correct indentation.");
finish();
}
let gSamples = [{
time: 5,
frames: [
{ category: 8, location: "(root)" },
{ category: 8, location: "A (http://foo/bar/baz:12)" },
{ category: 16, location: "B (http://foo/bar/baz:34)" },
{ category: 32, location: "C (http://foo/bar/baz:56)" }
]
}, {
time: 5 + 1,
2014-08-06 15:25:18 +00:00
frames: [
{ category: 8, location: "(root)" },
{ category: 8, location: "A (http://foo/bar/baz:12)" },
{ category: 16, location: "B (http://foo/bar/baz:34)" },
{ category: 64, location: "D (http://foo/bar/baz:78)" }
]
}, {
time: 5 + 1 + 2,
frames: [
{ category: 8, location: "(root)" },
{ category: 8, location: "A (http://foo/bar/baz:12)" },
{ category: 16, location: "B (http://foo/bar/baz:34)" },
{ category: 64, location: "D (http://foo/bar/baz:78)" }
]
}, {
time: 5 + 1 + 2 + 7,
2014-08-06 15:25:18 +00:00
frames: [
{ category: 8, location: "(root)" },
{ category: 8, location: "A (http://foo/bar/baz:12)" },
{ category: 128, location: "E (http://foo/bar/baz:90)" },
{ category: 256, location: "F (http://foo/bar/baz:99)" }
]
}];