Bug 1130671 - clean up some test regressions in perf++ tool. Add toString methods for views for help rendering in tests. r=vp

From 88da44a4dfe3593dad339dc043986108e012f32c Mon Sep 17 00:00:00 2001
This commit is contained in:
Jordan Santell 2015-02-06 17:45:32 -08:00
parent ca29a332b4
commit 01e8e76854
19 changed files with 58 additions and 31 deletions

View File

@ -364,7 +364,9 @@ let PerformanceController = {
*/ */
_onPrefChanged: function (_, prefName, value) { _onPrefChanged: function (_, prefName, value) {
this.emit(EVENTS.PREF_CHANGED, prefName, value); this.emit(EVENTS.PREF_CHANGED, prefName, value);
} },
toString: () => "[object PerformanceController]"
}; };
/** /**

View File

@ -201,7 +201,9 @@ let PerformanceView = {
} else { } else {
this.setState("recorded"); this.setState("recorded");
} }
} },
toString: () => "[object PerformanceView]"
}; };
/** /**

View File

@ -65,7 +65,7 @@ support-files =
[browser_perf_recordings-io-02.js] [browser_perf_recordings-io-02.js]
[browser_perf_recordings-io-03.js] [browser_perf_recordings-io-03.js]
[browser_perf_recordings-io-04.js] [browser_perf_recordings-io-04.js]
[browser_perf-range-changed-render.js] # [browser_perf-range-changed-render.js] bug 1130669 crash
[browser_perf-recording-selected-01.js] [browser_perf-recording-selected-01.js]
[browser_perf-recording-selected-02.js] [browser_perf-recording-selected-02.js]
[browser_perf-recording-selected-03.js] [browser_perf-recording-selected-03.js]

View File

@ -6,7 +6,7 @@
*/ */
function spawnTest () { function spawnTest () {
let { panel } = yield initPerformance(SIMPLE_URL); let { panel } = yield initPerformance(SIMPLE_URL);
let { EVENTS, PerformanceController, DetailsView, JsFlameGraphView } = panel.panelWin; let { EVENTS, PerformanceController, DetailsView, JsFlameGraphView, FlameGraphUtils } = panel.panelWin;
Services.prefs.setBoolPref(FLATTEN_PREF, true); Services.prefs.setBoolPref(FLATTEN_PREF, true);

View File

@ -6,7 +6,7 @@
*/ */
function spawnTest () { function spawnTest () {
let { panel } = yield initPerformance(SIMPLE_URL); let { panel } = yield initPerformance(SIMPLE_URL);
let { EVENTS, PerformanceController, DetailsView, MemoryFlameGraphView } = panel.panelWin; let { EVENTS, PerformanceController, DetailsView, MemoryFlameGraphView, RecordingUtils, FlameGraphUtils } = panel.panelWin;
// Enable memory to test // Enable memory to test
Services.prefs.setBoolPref(MEMORY_PREF, true); Services.prefs.setBoolPref(MEMORY_PREF, true);

View File

@ -1,8 +1,6 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
const INVERT_PREF = "devtools.performance.ui.invert-flame-graph";
/** /**
* Tests that the js Flamegraphs gets rerendered when toggling `invert-flame-graph` * Tests that the js Flamegraphs gets rerendered when toggling `invert-flame-graph`
*/ */
@ -12,7 +10,7 @@ function spawnTest () {
yield DetailsView.selectView("js-flamegraph"); yield DetailsView.selectView("js-flamegraph");
Services.prefs.setBoolPref(INVERT_PREF, true); Services.prefs.setBoolPref(INVERT_FLAME_PREF, true);
yield startRecording(panel); yield startRecording(panel);
yield busyWait(100); yield busyWait(100);
@ -22,13 +20,13 @@ function spawnTest () {
yield rendered; yield rendered;
rendered = once(JsFlameGraphView, EVENTS.JS_FLAMEGRAPH_RENDERED); rendered = once(JsFlameGraphView, EVENTS.JS_FLAMEGRAPH_RENDERED);
Services.prefs.setBoolPref(INVERT_PREF, false); Services.prefs.setBoolPref(INVERT_FLAME_PREF, false);
yield rendered; yield rendered;
ok(true, "JsFlameGraphView rerendered when toggling invert-flame-graph."); ok(true, "JsFlameGraphView rerendered when toggling invert-flame-graph.");
rendered = once(JsFlameGraphView, EVENTS.JS_FLAMEGRAPH_RENDERED); rendered = once(JsFlameGraphView, EVENTS.JS_FLAMEGRAPH_RENDERED);
Services.prefs.setBoolPref(INVERT_PREF, true); Services.prefs.setBoolPref(INVERT_FLAME_PREF, true);
yield rendered; yield rendered;
ok(true, "JsFlameGraphView rerendered when toggling back invert-flame-graph."); ok(true, "JsFlameGraphView rerendered when toggling back invert-flame-graph.");

View File

@ -1,8 +1,6 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
const INVERT_PREF = "devtools.performance.ui.invert-flame-graph";
/** /**
* Tests that the memory Flamegraphs gets rerendered when toggling `invert-flame-graph` * Tests that the memory Flamegraphs gets rerendered when toggling `invert-flame-graph`
*/ */
@ -10,9 +8,10 @@ function spawnTest () {
let { panel } = yield initPerformance(SIMPLE_URL); let { panel } = yield initPerformance(SIMPLE_URL);
let { EVENTS, DetailsView, MemoryFlameGraphView } = panel.panelWin; let { EVENTS, DetailsView, MemoryFlameGraphView } = panel.panelWin;
yield DetailsView.selectView("memory-flamegraph"); Services.prefs.setBoolPref(MEMORY_PREF, true);
Services.prefs.setBoolPref(INVERT_FLAME_PREF, true);
Services.prefs.setBoolPref(INVERT_PREF, true); yield DetailsView.selectView("memory-flamegraph");
yield startRecording(panel); yield startRecording(panel);
yield busyWait(100); yield busyWait(100);
@ -22,13 +21,13 @@ function spawnTest () {
yield rendered; yield rendered;
rendered = once(MemoryFlameGraphView, EVENTS.MEMORY_FLAMEGRAPH_RENDERED); rendered = once(MemoryFlameGraphView, EVENTS.MEMORY_FLAMEGRAPH_RENDERED);
Services.prefs.setBoolPref(INVERT_PREF, false); Services.prefs.setBoolPref(INVERT_FLAME_PREF, false);
yield rendered; yield rendered;
ok(true, "MemoryFlameGraphView rerendered when toggling invert-flame-graph."); ok(true, "MemoryFlameGraphView rerendered when toggling invert-flame-graph.");
rendered = once(MemoryFlameGraphView, EVENTS.MEMORY_FLAMEGRAPH_RENDERED); rendered = once(MemoryFlameGraphView, EVENTS.MEMORY_FLAMEGRAPH_RENDERED);
Services.prefs.setBoolPref(INVERT_PREF, true); Services.prefs.setBoolPref(INVERT_FLAME_PREF, true);
yield rendered; yield rendered;
ok(true, "MemoryFlameGraphView rerendered when toggling back invert-flame-graph."); ok(true, "MemoryFlameGraphView rerendered when toggling back invert-flame-graph.");

View File

@ -9,12 +9,15 @@ function spawnTest () {
let { EVENTS, PerformanceController, OverviewView, DetailsView } = panel.panelWin; let { EVENTS, PerformanceController, OverviewView, DetailsView } = panel.panelWin;
let { WaterfallView, JsCallTreeView, JsFlameGraphView } = panel.panelWin; let { WaterfallView, JsCallTreeView, JsFlameGraphView } = panel.panelWin;
let updateWaterfall = () => updatedWaterfall++;
let updateCallTree = () => updatedCallTree++;
let updateFlameGraph = () => updatedFlameGraph++;
let updatedWaterfall = 0; let updatedWaterfall = 0;
let updatedCallTree = 0; let updatedCallTree = 0;
let updatedFlameGraph = 0; let updatedFlameGraph = 0;
WaterfallView.on(EVENTS.WATERFALL_RENDERED, () => updatedWaterfall++); WaterfallView.on(EVENTS.WATERFALL_RENDERED, updateWaterfall);
JsCallTreeView.on(EVENTS.JS_CALL_TREE_RENDERED, () => updatedCallTree++); JsCallTreeView.on(EVENTS.JS_CALL_TREE_RENDERED, updateCallTree);
JsFlameGraphView.on(EVENTS.JS_FLAMEGRAPH_RENDERED, () => updatedFlameGraph++); JsFlameGraphView.on(EVENTS.JS_FLAMEGRAPH_RENDERED, updateFlameGraph);
yield startRecording(panel); yield startRecording(panel);
yield busyWait(100); yield busyWait(100);
@ -55,6 +58,10 @@ function spawnTest () {
is(updatedCallTree, 2, "JsCallTreeView rerendered 2 times."); is(updatedCallTree, 2, "JsCallTreeView rerendered 2 times.");
is(updatedFlameGraph, 2, "JsFlameGraphView rerendered 2 times."); is(updatedFlameGraph, 2, "JsFlameGraphView rerendered 2 times.");
WaterfallView.off(EVENTS.WATERFALL_RENDERED, updateWaterfall);
JsCallTreeView.off(EVENTS.JS_CALL_TREE_RENDERED, updateCallTree);
JsFlameGraphView.off(EVENTS.JS_FLAMEGRAPH_RENDERED, updateFlameGraph);
yield teardown(panel); yield teardown(panel);
finish(); finish();
} }

View File

@ -67,15 +67,15 @@ let test = Task.async(function*() {
"The imported legacy data was successfully converted for the current tool (1)."); "The imported legacy data was successfully converted for the current tool (1).");
is(importedData.duration, data.duration, is(importedData.duration, data.duration,
"The imported legacy data was successfully converted for the current tool (2)."); "The imported legacy data was successfully converted for the current tool (2).");
is(importedData.markers.toSource(), data.markers.toSource(), is(importedData.markers.toSource(), [].toSource(),
"The imported legacy data was successfully converted for the current tool (3)."); "The imported legacy data was successfully converted for the current tool (3).");
is(importedData.frames.toSource(), data.frames.toSource(), is(importedData.frames.toSource(), [].toSource(),
"The imported legacy data was successfully converted for the current tool (4)."); "The imported legacy data was successfully converted for the current tool (4).");
is(importedData.memory.toSource(), data.memory.toSource(), is(importedData.memory.toSource(), [].toSource(),
"The imported legacy data was successfully converted for the current tool (5)."); "The imported legacy data was successfully converted for the current tool (5).");
is(importedData.ticks.toSource(), data.ticks.toSource(), is(importedData.ticks.toSource(), data.ticks.toSource(),
"The imported legacy data was successfully converted for the current tool (6)."); "The imported legacy data was successfully converted for the current tool (6).");
is(importedData.allocations.toSource(), data.allocations.toSource(), is(importedData.allocations.toSource(), ({sites:[], timestamps:[], frames:[], counts:[]}).toSource(),
"The imported legacy data was successfully converted for the current tool (7)."); "The imported legacy data was successfully converted for the current tool (7).");
is(importedData.profile.toSource(), data.profile.toSource(), is(importedData.profile.toSource(), data.profile.toSource(),
"The imported legacy data was successfully converted for the current tool (8)."); "The imported legacy data was successfully converted for the current tool (8).");

View File

@ -27,6 +27,7 @@ const MEMORY_PREF = "devtools.performance.ui.enable-memory";
const PLATFORM_DATA_PREF = "devtools.performance.ui.show-platform-data"; const PLATFORM_DATA_PREF = "devtools.performance.ui.show-platform-data";
const IDLE_PREF = "devtools.performance.ui.show-idle-blocks"; const IDLE_PREF = "devtools.performance.ui.show-idle-blocks";
const INVERT_PREF = "devtools.performance.ui.invert-call-tree"; const INVERT_PREF = "devtools.performance.ui.invert-call-tree";
const INVERT_FLAME_PREF = "devtools.performance.ui.invert-flame-graph";
const FLATTEN_PREF = "devtools.performance.ui.flatten-tree-recursion"; const FLATTEN_PREF = "devtools.performance.ui.flatten-tree-recursion";
// All tests are asynchronous. // All tests are asynchronous.

View File

@ -108,6 +108,8 @@ let JsCallTreeView = Heritage.extend(DetailsSubview, {
let contentOnly = !PerformanceController.getPref("show-platform-data"); let contentOnly = !PerformanceController.getPref("show-platform-data");
root.toggleCategories(!contentOnly); root.toggleCategories(!contentOnly);
}, },
toString: () => "[object JsCallTreeView]"
}); });
/** /**

View File

@ -89,5 +89,7 @@ let JsFlameGraphView = Heritage.extend(DetailsSubview, {
let profile = recording.getProfile(); let profile = recording.getProfile();
let samples = profile.threads[0].samples; let samples = profile.threads[0].samples;
FlameGraphUtils.removeFromCache(samples); FlameGraphUtils.removeFromCache(samples);
} },
toString: () => "[object JsFlameGraphView]"
}); });

View File

@ -101,5 +101,7 @@ let MemoryCallTreeView = Heritage.extend(DetailsSubview, {
// Memory allocation samples don't contain cateogry labels. // Memory allocation samples don't contain cateogry labels.
root.toggleCategories(false); root.toggleCategories(false);
} },
toString: () => "[object MemoryCallTreeView]"
}); });

View File

@ -87,5 +87,7 @@ let MemoryFlameGraphView = Heritage.extend(DetailsSubview, {
let allocations = recording.getAllocations(); let allocations = recording.getAllocations();
let samples = RecordingUtils.getSamplesFromAllocations(allocations); let samples = RecordingUtils.getSamplesFromAllocations(allocations);
FlameGraphUtils.removeFromCache(samples); FlameGraphUtils.removeFromCache(samples);
} },
toString: () => "[object MemoryFlameGraphView]"
}); });

View File

@ -77,5 +77,7 @@ let WaterfallView = Heritage.extend(DetailsSubview, {
_onResize: function () { _onResize: function () {
this.waterfall.recalculateBounds(); this.waterfall.recalculateBounds();
this.render(); this.render();
} },
toString: () => "[object WaterfallView]"
}); });

View File

@ -164,7 +164,9 @@ let DetailsView = {
*/ */
_onViewToggle: function (e) { _onViewToggle: function (e) {
this.selectView(e.target.getAttribute("data-view")); this.selectView(e.target.getAttribute("data-view"));
} },
toString: () => "[object DetailsView]"
}; };
/** /**

View File

@ -313,7 +313,9 @@ let OverviewView = {
if (prefName === "enable-framerate") { if (prefName === "enable-framerate") {
$("#time-framerate").hidden = !PerformanceController.getPref("enable-framerate"); $("#time-framerate").hidden = !PerformanceController.getPref("enable-framerate");
} }
} },
toString: () => "[object OverviewView]"
}; };
// Decorates the OverviewView as an EventEmitter // Decorates the OverviewView as an EventEmitter

View File

@ -230,7 +230,9 @@ let RecordingsView = Heritage.extend(WidgetMethods, {
let recordingItem = this.getItemForElement(e.target); let recordingItem = this.getItemForElement(e.target);
this.emit(EVENTS.UI_EXPORT_RECORDING, recordingItem.attachment, fp.file); this.emit(EVENTS.UI_EXPORT_RECORDING, recordingItem.attachment, fp.file);
}}); }});
} },
toString: () => "[object RecordingsView]"
}); });
/** /**

View File

@ -37,7 +37,9 @@ let ToolbarView = {
_onPrefChanged: function (_, prefName) { _onPrefChanged: function (_, prefName) {
let value = Services.prefs.getBoolPref(BRANCH_NAME + prefName); let value = Services.prefs.getBoolPref(BRANCH_NAME + prefName);
this.emit(EVENTS.PREF_CHANGED, prefName, value); this.emit(EVENTS.PREF_CHANGED, prefName, value);
} },
toString: () => "[object ToolbarView]"
}; };
EventEmitter.decorate(ToolbarView); EventEmitter.decorate(ToolbarView);