michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if selecting snapshots in the frontend displays the appropriate data michael@0: * respective to their recorded animation frame. michael@0: */ michael@0: michael@0: function ifTestingSupported() { michael@0: let [target, debuggee, panel] = yield initCanavsDebuggerFrontend(SIMPLE_CANVAS_URL); michael@0: let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin; michael@0: michael@0: yield reload(target); michael@0: michael@0: yield recordAndWaitForFirstSnapshot(); michael@0: info("First snapshot recorded.") michael@0: michael@0: is(SnapshotsListView.selectedIndex, 0, michael@0: "A snapshot should be automatically selected after first recording."); michael@0: is(CallsListView.selectedIndex, -1, michael@0: "There should be no call item automatically selected in the snapshot."); michael@0: michael@0: yield recordAndWaitForAnotherSnapshot(); michael@0: info("Second snapshot recorded.") michael@0: michael@0: is(SnapshotsListView.selectedIndex, 0, michael@0: "A snapshot should not be automatically selected after another recording."); michael@0: is(CallsListView.selectedIndex, -1, michael@0: "There should still be no call item automatically selected in the snapshot."); michael@0: michael@0: let secondSnapshotTarget = SnapshotsListView.getItemAtIndex(1).target; michael@0: let snapshotSelected = waitForSnapshotSelection(); michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, secondSnapshotTarget, window); michael@0: michael@0: yield snapshotSelected; michael@0: info("Second snapshot selected."); michael@0: michael@0: is(SnapshotsListView.selectedIndex, 1, michael@0: "The second snapshot should now be selected."); michael@0: is(CallsListView.selectedIndex, -1, michael@0: "There should still be no call item automatically selected in the snapshot."); michael@0: michael@0: let firstDrawCallContents = $(".call-item-contents", CallsListView.getItemAtIndex(2).target); michael@0: let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED); michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, firstDrawCallContents, window); michael@0: michael@0: yield screenshotDisplayed; michael@0: info("First draw call in the second snapshot selected."); michael@0: michael@0: is(SnapshotsListView.selectedIndex, 1, michael@0: "The second snapshot should still be selected."); michael@0: is(CallsListView.selectedIndex, 2, michael@0: "The first draw call should now be selected in the snapshot."); michael@0: michael@0: let firstSnapshotTarget = SnapshotsListView.getItemAtIndex(0).target; michael@0: let snapshotSelected = waitForSnapshotSelection(); michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, firstSnapshotTarget, window); michael@0: michael@0: yield snapshotSelected; michael@0: info("First snapshot re-selected."); michael@0: michael@0: is(SnapshotsListView.selectedIndex, 0, michael@0: "The first snapshot should now be re-selected."); michael@0: is(CallsListView.selectedIndex, -1, michael@0: "There should still be no call item automatically selected in the snapshot."); michael@0: michael@0: function recordAndWaitForFirstSnapshot() { michael@0: let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); michael@0: let snapshotSelected = waitForSnapshotSelection(); michael@0: SnapshotsListView._onRecordButtonClick(); michael@0: return promise.all([recordingFinished, snapshotSelected]); michael@0: } michael@0: michael@0: function recordAndWaitForAnotherSnapshot() { michael@0: let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); michael@0: SnapshotsListView._onRecordButtonClick(); michael@0: return recordingFinished; michael@0: } michael@0: michael@0: function waitForSnapshotSelection() { michael@0: let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED); michael@0: let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED); michael@0: let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED); michael@0: return promise.all([ michael@0: callListPopulated, michael@0: thumbnailsDisplayed, michael@0: screenshotDisplayed michael@0: ]); michael@0: } michael@0: michael@0: yield teardown(panel); michael@0: finish(); michael@0: }