browser_wa_graph-render-01.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Tests that SVG nodes and edges were created for the Graph View.
  5. */
  6. var connectCount = 0;
  7. add_task(function* () {
  8. let { target, panel } = yield initWebAudioEditor(SIMPLE_CONTEXT_URL);
  9. let { panelWin } = panel;
  10. let { gFront, $, $$, EVENTS, gAudioNodes } = panelWin;
  11. let started = once(gFront, "start-context");
  12. gAudioNodes.on("connect", onConnectNode);
  13. let events = Promise.all([
  14. get3(gFront, "create-node"),
  15. waitForGraphRendered(panelWin, 3, 2)
  16. ]);
  17. reload(target);
  18. let [actors] = yield events;
  19. let [destId, oscId, gainId] = actors.map(actor => actor.actorID);
  20. ok(findGraphNode(panelWin, oscId).classList.contains("type-OscillatorNode"), "found OscillatorNode with class");
  21. ok(findGraphNode(panelWin, gainId).classList.contains("type-GainNode"), "found GainNode with class");
  22. ok(findGraphNode(panelWin, destId).classList.contains("type-AudioDestinationNode"), "found AudioDestinationNode with class");
  23. is(findGraphEdge(panelWin, oscId, gainId).toString(), "[object SVGGElement]", "found edge for osc -> gain");
  24. is(findGraphEdge(panelWin, gainId, destId).toString(), "[object SVGGElement]", "found edge for gain -> dest");
  25. yield wait(1000);
  26. is(connectCount, 2, "Only two node connect events should be fired.");
  27. gAudioNodes.off("connect", onConnectNode);
  28. yield teardown(target);
  29. });
  30. function onConnectNode() {
  31. ++connectCount;
  32. }