browser_canvas-frontend-img-thumbnails-02.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Tests if thumbnails are correctly linked with other UI elements like
  5. * function call items and their respective screenshots.
  6. */
  7. function* ifTestingSupported() {
  8. let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
  9. let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
  10. yield reload(target);
  11. let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
  12. let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
  13. let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED);
  14. let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
  15. SnapshotsListView._onRecordButtonClick();
  16. yield promise.all([
  17. recordingFinished,
  18. callListPopulated,
  19. thumbnailsDisplayed,
  20. screenshotDisplayed
  21. ]);
  22. is($all(".filmstrip-thumbnail[highlighted]").length, 0,
  23. "There should be no highlighted thumbnail available yet.");
  24. is(CallsListView.selectedIndex, -1,
  25. "There should be no selected item in the calls list view.");
  26. EventUtils.sendMouseEvent({ type: "mousedown" }, $all(".filmstrip-thumbnail")[0], window);
  27. yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
  28. info("The first draw call was selected, by clicking the first thumbnail.");
  29. isnot($(".filmstrip-thumbnail[highlighted][index='0']"), null,
  30. "There should be a highlighted thumbnail available now, for the first draw call.");
  31. is($all(".filmstrip-thumbnail[highlighted]").length, 1,
  32. "There should be only one highlighted thumbnail available now.");
  33. is(CallsListView.selectedIndex, 0,
  34. "The first draw call should be selected in the calls list view.");
  35. EventUtils.sendMouseEvent({ type: "mousedown" }, $all(".call-item-view")[1], window);
  36. yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
  37. info("The second context call was selected, by clicking the second call item.");
  38. isnot($(".filmstrip-thumbnail[highlighted][index='0']"), null,
  39. "There should be a highlighted thumbnail available, for the first draw call.");
  40. is($all(".filmstrip-thumbnail[highlighted]").length, 1,
  41. "There should be only one highlighted thumbnail available.");
  42. is(CallsListView.selectedIndex, 1,
  43. "The second draw call should be selected in the calls list view.");
  44. EventUtils.sendMouseEvent({ type: "mousedown" }, $all(".call-item-view")[2], window);
  45. yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
  46. info("The second draw call was selected, by clicking the third call item.");
  47. isnot($(".filmstrip-thumbnail[highlighted][index='2']"), null,
  48. "There should be a highlighted thumbnail available, for the second draw call.");
  49. is($all(".filmstrip-thumbnail[highlighted]").length, 1,
  50. "There should be only one highlighted thumbnail available.");
  51. is(CallsListView.selectedIndex, 2,
  52. "The second draw call should be selected in the calls list view.");
  53. yield teardown(panel);
  54. finish();
  55. }