browser_perf-overview-selection-03.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. /**
  5. * Tests that the graphs' selections are linked.
  6. */
  7. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  8. const { UI_ENABLE_MEMORY_PREF } = require("devtools/client/performance/test/helpers/prefs");
  9. const { initPerformanceInNewTab, teardownToolboxAndRemoveTab } = require("devtools/client/performance/test/helpers/panel-utils");
  10. const { startRecording, stopRecording } = require("devtools/client/performance/test/helpers/actions");
  11. const { times } = require("devtools/client/performance/test/helpers/event-utils");
  12. const { dragStartCanvasGraph, dragStopCanvasGraph } = require("devtools/client/performance/test/helpers/input-utils");
  13. add_task(function* () {
  14. let { panel } = yield initPerformanceInNewTab({
  15. url: SIMPLE_URL,
  16. win: window
  17. });
  18. let { EVENTS, OverviewView } = panel.panelWin;
  19. // Enable memory to test.
  20. Services.prefs.setBoolPref(UI_ENABLE_MEMORY_PREF, true);
  21. yield startRecording(panel);
  22. yield stopRecording(panel);
  23. let markersOverview = OverviewView.graphs.get("timeline");
  24. let memoryGraph = OverviewView.graphs.get("memory");
  25. let framerateGraph = OverviewView.graphs.get("framerate");
  26. let width = framerateGraph.width;
  27. // Perform a selection inside the framerate graph.
  28. let rangeSelected = times(OverviewView, EVENTS.UI_OVERVIEW_RANGE_SELECTED, 2);
  29. dragStartCanvasGraph(framerateGraph, { x: 0 });
  30. dragStopCanvasGraph(framerateGraph, { x: width / 2 });
  31. yield rangeSelected;
  32. is(markersOverview.getSelection().toSource(), framerateGraph.getSelection().toSource(),
  33. "The markers overview has a correct selection.");
  34. is(memoryGraph.getSelection().toSource(), framerateGraph.getSelection().toSource(),
  35. "The memory overview has a correct selection.");
  36. is(framerateGraph.getSelection().toSource(), "({start:0, end:" + (width / 2) + "})",
  37. "The framerate graph has a correct selection.");
  38. // Perform a selection inside the markers overview.
  39. markersOverview.dropSelection();
  40. rangeSelected = times(OverviewView, EVENTS.UI_OVERVIEW_RANGE_SELECTED, 2);
  41. dragStartCanvasGraph(markersOverview, { x: 0 });
  42. dragStopCanvasGraph(markersOverview, { x: width / 4 });
  43. yield rangeSelected;
  44. is(markersOverview.getSelection().toSource(), framerateGraph.getSelection().toSource(),
  45. "The markers overview has a correct selection.");
  46. is(memoryGraph.getSelection().toSource(), framerateGraph.getSelection().toSource(),
  47. "The memory overview has a correct selection.");
  48. is(framerateGraph.getSelection().toSource(), "({start:0, end:" + (width / 4) + "})",
  49. "The framerate graph has a correct selection.");
  50. // Perform a selection inside the memory overview.
  51. markersOverview.dropSelection();
  52. rangeSelected = times(OverviewView, EVENTS.UI_OVERVIEW_RANGE_SELECTED, 2);
  53. dragStartCanvasGraph(memoryGraph, { x: 0 });
  54. dragStopCanvasGraph(memoryGraph, { x: width / 10 });
  55. yield rangeSelected;
  56. is(markersOverview.getSelection().toSource(), framerateGraph.getSelection().toSource(),
  57. "The markers overview has a correct selection.");
  58. is(memoryGraph.getSelection().toSource(), framerateGraph.getSelection().toSource(),
  59. "The memory overview has a correct selection.");
  60. is(framerateGraph.getSelection().toSource(), "({start:0, end:" + (width / 10) + "})",
  61. "The framerate graph has a correct selection.");
  62. yield teardownToolboxAndRemoveTab(panel);
  63. });