|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests if selecting snapshots in the frontend displays the appropriate data |
|
6 * respective to their recorded animation frame. |
|
7 */ |
|
8 |
|
9 function ifTestingSupported() { |
|
10 let [target, debuggee, panel] = yield initCanavsDebuggerFrontend(SIMPLE_CANVAS_URL); |
|
11 let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin; |
|
12 |
|
13 yield reload(target); |
|
14 |
|
15 yield recordAndWaitForFirstSnapshot(); |
|
16 info("First snapshot recorded.") |
|
17 |
|
18 is(SnapshotsListView.selectedIndex, 0, |
|
19 "A snapshot should be automatically selected after first recording."); |
|
20 is(CallsListView.selectedIndex, -1, |
|
21 "There should be no call item automatically selected in the snapshot."); |
|
22 |
|
23 yield recordAndWaitForAnotherSnapshot(); |
|
24 info("Second snapshot recorded.") |
|
25 |
|
26 is(SnapshotsListView.selectedIndex, 0, |
|
27 "A snapshot should not be automatically selected after another recording."); |
|
28 is(CallsListView.selectedIndex, -1, |
|
29 "There should still be no call item automatically selected in the snapshot."); |
|
30 |
|
31 let secondSnapshotTarget = SnapshotsListView.getItemAtIndex(1).target; |
|
32 let snapshotSelected = waitForSnapshotSelection(); |
|
33 EventUtils.sendMouseEvent({ type: "mousedown" }, secondSnapshotTarget, window); |
|
34 |
|
35 yield snapshotSelected; |
|
36 info("Second snapshot selected."); |
|
37 |
|
38 is(SnapshotsListView.selectedIndex, 1, |
|
39 "The second snapshot should now be selected."); |
|
40 is(CallsListView.selectedIndex, -1, |
|
41 "There should still be no call item automatically selected in the snapshot."); |
|
42 |
|
43 let firstDrawCallContents = $(".call-item-contents", CallsListView.getItemAtIndex(2).target); |
|
44 let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED); |
|
45 EventUtils.sendMouseEvent({ type: "mousedown" }, firstDrawCallContents, window); |
|
46 |
|
47 yield screenshotDisplayed; |
|
48 info("First draw call in the second snapshot selected."); |
|
49 |
|
50 is(SnapshotsListView.selectedIndex, 1, |
|
51 "The second snapshot should still be selected."); |
|
52 is(CallsListView.selectedIndex, 2, |
|
53 "The first draw call should now be selected in the snapshot."); |
|
54 |
|
55 let firstSnapshotTarget = SnapshotsListView.getItemAtIndex(0).target; |
|
56 let snapshotSelected = waitForSnapshotSelection(); |
|
57 EventUtils.sendMouseEvent({ type: "mousedown" }, firstSnapshotTarget, window); |
|
58 |
|
59 yield snapshotSelected; |
|
60 info("First snapshot re-selected."); |
|
61 |
|
62 is(SnapshotsListView.selectedIndex, 0, |
|
63 "The first snapshot should now be re-selected."); |
|
64 is(CallsListView.selectedIndex, -1, |
|
65 "There should still be no call item automatically selected in the snapshot."); |
|
66 |
|
67 function recordAndWaitForFirstSnapshot() { |
|
68 let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); |
|
69 let snapshotSelected = waitForSnapshotSelection(); |
|
70 SnapshotsListView._onRecordButtonClick(); |
|
71 return promise.all([recordingFinished, snapshotSelected]); |
|
72 } |
|
73 |
|
74 function recordAndWaitForAnotherSnapshot() { |
|
75 let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); |
|
76 SnapshotsListView._onRecordButtonClick(); |
|
77 return recordingFinished; |
|
78 } |
|
79 |
|
80 function waitForSnapshotSelection() { |
|
81 let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED); |
|
82 let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED); |
|
83 let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED); |
|
84 return promise.all([ |
|
85 callListPopulated, |
|
86 thumbnailsDisplayed, |
|
87 screenshotDisplayed |
|
88 ]); |
|
89 } |
|
90 |
|
91 yield teardown(panel); |
|
92 finish(); |
|
93 } |