browser/devtools/shadereditor/test/browser_se_programs-list.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:0266a8cf3c73
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests if the programs list contains an entry after vertex and fragment
6 * shaders are linked.
7 */
8
9 function ifWebGLSupported() {
10 let [target, debuggee, panel] = yield initShaderEditor(MULTIPLE_CONTEXTS_URL);
11 let { gFront, EVENTS, L10N, ShadersListView, ShadersEditorsView } = panel.panelWin;
12
13 is(ShadersListView.itemCount, 0,
14 "The shaders list should initially be empty.");
15 is(ShadersListView.selectedItem, null,
16 "The shaders list has no selected item.");
17 is(ShadersListView.selectedIndex, -1,
18 "The shaders list has a negative index.");
19
20 reload(target);
21
22 let [firstProgramActor, secondProgramActor] = yield promise.all([
23 getPrograms(gFront, 2, (actors) => {
24 // Fired upon each actor addition, we want to check only
25 // after the first actor has been added so we can test state
26 if (actors.length === 1)
27 checkFirstProgram();
28 if (actors.length === 2)
29 checkSecondProgram();
30 }),
31 once(panel.panelWin, EVENTS.SOURCES_SHOWN)
32 ]).then(([programs, ]) => programs);
33
34 is(ShadersListView.attachments[0].label, L10N.getFormatStr("shadersList.programLabel", 0),
35 "The correct first label is shown in the shaders list.");
36 is(ShadersListView.attachments[1].label, L10N.getFormatStr("shadersList.programLabel", 1),
37 "The correct second label is shown in the shaders list.");
38
39 let vertexShader = yield firstProgramActor.getVertexShader();
40 let fragmentShader = yield firstProgramActor.getFragmentShader();
41 let vertSource = yield vertexShader.getText();
42 let fragSource = yield fragmentShader.getText();
43
44 let vsEditor = yield ShadersEditorsView._getEditor("vs");
45 let fsEditor = yield ShadersEditorsView._getEditor("fs");
46
47 is(vertSource, vsEditor.getText(),
48 "The vertex shader editor contains the correct text.");
49 is(fragSource, fsEditor.getText(),
50 "The vertex shader editor contains the correct text.");
51
52 let compiled = once(panel.panelWin, EVENTS.SHADER_COMPILED).then(() => {
53 ok(false, "Selecting a different program shouldn't recompile its shaders.");
54 });
55
56 let shown = once(panel.panelWin, EVENTS.SOURCES_SHOWN).then(() => {
57 ok(true, "The vertex and fragment sources have changed in the editors.");
58 });
59
60 EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[1].target);
61 yield shown;
62
63 is(ShadersListView.selectedItem, ShadersListView.items[1],
64 "The shaders list has a correct item selected.");
65 is(ShadersListView.selectedIndex, 1,
66 "The shaders list has a correct index selected.");
67
68 yield teardown(panel);
69 finish();
70
71 function checkFirstProgram () {
72 is(ShadersListView.itemCount, 1,
73 "The shaders list contains one entry.");
74 is(ShadersListView.selectedItem, ShadersListView.items[0],
75 "The shaders list has a correct item selected.");
76 is(ShadersListView.selectedIndex, 0,
77 "The shaders list has a correct index selected.");
78 }
79 function checkSecondProgram () {
80 is(ShadersListView.itemCount, 2,
81 "The shaders list contains two entries.");
82 is(ShadersListView.selectedItem, ShadersListView.items[0],
83 "The shaders list has a correct item selected.");
84 is(ShadersListView.selectedIndex, 0,
85 "The shaders list has a correct index selected.");
86 }
87 }

mercurial