1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/canvasdebugger/test/browser_canvas-frontend-snapshot-select.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,93 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if selecting snapshots in the frontend displays the appropriate data 1.9 + * respective to their recorded animation frame. 1.10 + */ 1.11 + 1.12 +function ifTestingSupported() { 1.13 + let [target, debuggee, panel] = yield initCanavsDebuggerFrontend(SIMPLE_CANVAS_URL); 1.14 + let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin; 1.15 + 1.16 + yield reload(target); 1.17 + 1.18 + yield recordAndWaitForFirstSnapshot(); 1.19 + info("First snapshot recorded.") 1.20 + 1.21 + is(SnapshotsListView.selectedIndex, 0, 1.22 + "A snapshot should be automatically selected after first recording."); 1.23 + is(CallsListView.selectedIndex, -1, 1.24 + "There should be no call item automatically selected in the snapshot."); 1.25 + 1.26 + yield recordAndWaitForAnotherSnapshot(); 1.27 + info("Second snapshot recorded.") 1.28 + 1.29 + is(SnapshotsListView.selectedIndex, 0, 1.30 + "A snapshot should not be automatically selected after another recording."); 1.31 + is(CallsListView.selectedIndex, -1, 1.32 + "There should still be no call item automatically selected in the snapshot."); 1.33 + 1.34 + let secondSnapshotTarget = SnapshotsListView.getItemAtIndex(1).target; 1.35 + let snapshotSelected = waitForSnapshotSelection(); 1.36 + EventUtils.sendMouseEvent({ type: "mousedown" }, secondSnapshotTarget, window); 1.37 + 1.38 + yield snapshotSelected; 1.39 + info("Second snapshot selected."); 1.40 + 1.41 + is(SnapshotsListView.selectedIndex, 1, 1.42 + "The second snapshot should now be selected."); 1.43 + is(CallsListView.selectedIndex, -1, 1.44 + "There should still be no call item automatically selected in the snapshot."); 1.45 + 1.46 + let firstDrawCallContents = $(".call-item-contents", CallsListView.getItemAtIndex(2).target); 1.47 + let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED); 1.48 + EventUtils.sendMouseEvent({ type: "mousedown" }, firstDrawCallContents, window); 1.49 + 1.50 + yield screenshotDisplayed; 1.51 + info("First draw call in the second snapshot selected."); 1.52 + 1.53 + is(SnapshotsListView.selectedIndex, 1, 1.54 + "The second snapshot should still be selected."); 1.55 + is(CallsListView.selectedIndex, 2, 1.56 + "The first draw call should now be selected in the snapshot."); 1.57 + 1.58 + let firstSnapshotTarget = SnapshotsListView.getItemAtIndex(0).target; 1.59 + let snapshotSelected = waitForSnapshotSelection(); 1.60 + EventUtils.sendMouseEvent({ type: "mousedown" }, firstSnapshotTarget, window); 1.61 + 1.62 + yield snapshotSelected; 1.63 + info("First snapshot re-selected."); 1.64 + 1.65 + is(SnapshotsListView.selectedIndex, 0, 1.66 + "The first snapshot should now be re-selected."); 1.67 + is(CallsListView.selectedIndex, -1, 1.68 + "There should still be no call item automatically selected in the snapshot."); 1.69 + 1.70 + function recordAndWaitForFirstSnapshot() { 1.71 + let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); 1.72 + let snapshotSelected = waitForSnapshotSelection(); 1.73 + SnapshotsListView._onRecordButtonClick(); 1.74 + return promise.all([recordingFinished, snapshotSelected]); 1.75 + } 1.76 + 1.77 + function recordAndWaitForAnotherSnapshot() { 1.78 + let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); 1.79 + SnapshotsListView._onRecordButtonClick(); 1.80 + return recordingFinished; 1.81 + } 1.82 + 1.83 + function waitForSnapshotSelection() { 1.84 + let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED); 1.85 + let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED); 1.86 + let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED); 1.87 + return promise.all([ 1.88 + callListPopulated, 1.89 + thumbnailsDisplayed, 1.90 + screenshotDisplayed 1.91 + ]); 1.92 + } 1.93 + 1.94 + yield teardown(panel); 1.95 + finish(); 1.96 +}