browser_graphs-09b.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. // Tests that line graphs properly use the tooltips configuration properties.
  5. const TEST_DATA = [
  6. { delta: 112, value: 48 }, { delta: 213, value: 59 },
  7. { delta: 313, value: 60 }, { delta: 413, value: 59 },
  8. { delta: 530, value: 59 }, { delta: 646, value: 58 },
  9. { delta: 747, value: 60 }, { delta: 863, value: 48 },
  10. { delta: 980, value: 37 }, { delta: 1097, value: 30 },
  11. { delta: 1213, value: 29 }, { delta: 1330, value: 23 },
  12. { delta: 1430, value: 10 }, { delta: 1534, value: 17 },
  13. { delta: 1645, value: 20 }, { delta: 1746, value: 22 },
  14. { delta: 1846, value: 39 }, { delta: 1963, value: 26 },
  15. { delta: 2080, value: 27 }, { delta: 2197, value: 35 },
  16. { delta: 2312, value: 47 }, { delta: 2412, value: 53 },
  17. { delta: 2514, value: 60 }, { delta: 2630, value: 37 },
  18. { delta: 2730, value: 36 }, { delta: 2830, value: 37 },
  19. { delta: 2946, value: 36 }, { delta: 3046, value: 40 },
  20. { delta: 3163, value: 47 }, { delta: 3280, value: 41 },
  21. { delta: 3380, value: 35 }, { delta: 3480, value: 27 },
  22. { delta: 3580, value: 39 }, { delta: 3680, value: 42 },
  23. { delta: 3780, value: 49 }, { delta: 3880, value: 55 },
  24. { delta: 3980, value: 60 }, { delta: 4080, value: 60 },
  25. { delta: 4180, value: 60 }
  26. ];
  27. const LineGraphWidget = require("devtools/client/shared/widgets/LineGraphWidget");
  28. add_task(function* () {
  29. yield addTab("about:blank");
  30. yield performTest();
  31. gBrowser.removeCurrentTab();
  32. });
  33. function* performTest() {
  34. let [host,, doc] = yield createHost();
  35. let graph = new LineGraphWidget(doc.body, "fps");
  36. graph.withTooltipArrows = false;
  37. graph.withFixedTooltipPositions = true;
  38. yield testGraph(graph);
  39. yield graph.destroy();
  40. host.destroy();
  41. }
  42. function* testGraph(graph) {
  43. yield graph.setDataWhenReady(TEST_DATA);
  44. is(graph._gutter.hidden, false,
  45. "The gutter should be visible even if the tooltips don't have arrows.");
  46. is(graph._maxTooltip.hidden, false,
  47. "The max tooltip should not be hidden.");
  48. is(graph._avgTooltip.hidden, false,
  49. "The avg tooltip should not be hidden.");
  50. is(graph._minTooltip.hidden, false,
  51. "The min tooltip should not be hidden.");
  52. is(graph._maxTooltip.getAttribute("with-arrows"), "false",
  53. "The maximum tooltip has the correct 'with-arrows' attribute.");
  54. is(graph._avgTooltip.getAttribute("with-arrows"), "false",
  55. "The average tooltip has the correct 'with-arrows' attribute.");
  56. is(graph._minTooltip.getAttribute("with-arrows"), "false",
  57. "The minimum tooltip has the correct 'with-arrows' attribute.");
  58. is(parseInt(graph._maxTooltip.style.top, 10), 8,
  59. "The maximum tooltip is positioned correctly.");
  60. is(parseInt(graph._avgTooltip.style.top, 10), 8,
  61. "The average tooltip is positioned correctly.");
  62. is(parseInt(graph._minTooltip.style.top, 10), 142,
  63. "The minimum tooltip is positioned correctly.");
  64. is(parseInt(graph._maxGutterLine.style.top, 10), 22,
  65. "The maximum gutter line is positioned correctly.");
  66. is(parseInt(graph._avgGutterLine.style.top, 10), 61,
  67. "The average gutter line is positioned correctly.");
  68. is(parseInt(graph._minGutterLine.style.top, 10), 128,
  69. "The minimum gutter line is positioned correctly.");
  70. }