1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/shadereditor/test/browser_se_programs-list.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,87 @@ 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 the programs list contains an entry after vertex and fragment 1.9 + * shaders are linked. 1.10 + */ 1.11 + 1.12 +function ifWebGLSupported() { 1.13 + let [target, debuggee, panel] = yield initShaderEditor(MULTIPLE_CONTEXTS_URL); 1.14 + let { gFront, EVENTS, L10N, ShadersListView, ShadersEditorsView } = panel.panelWin; 1.15 + 1.16 + is(ShadersListView.itemCount, 0, 1.17 + "The shaders list should initially be empty."); 1.18 + is(ShadersListView.selectedItem, null, 1.19 + "The shaders list has no selected item."); 1.20 + is(ShadersListView.selectedIndex, -1, 1.21 + "The shaders list has a negative index."); 1.22 + 1.23 + reload(target); 1.24 + 1.25 + let [firstProgramActor, secondProgramActor] = yield promise.all([ 1.26 + getPrograms(gFront, 2, (actors) => { 1.27 + // Fired upon each actor addition, we want to check only 1.28 + // after the first actor has been added so we can test state 1.29 + if (actors.length === 1) 1.30 + checkFirstProgram(); 1.31 + if (actors.length === 2) 1.32 + checkSecondProgram(); 1.33 + }), 1.34 + once(panel.panelWin, EVENTS.SOURCES_SHOWN) 1.35 + ]).then(([programs, ]) => programs); 1.36 + 1.37 + is(ShadersListView.attachments[0].label, L10N.getFormatStr("shadersList.programLabel", 0), 1.38 + "The correct first label is shown in the shaders list."); 1.39 + is(ShadersListView.attachments[1].label, L10N.getFormatStr("shadersList.programLabel", 1), 1.40 + "The correct second label is shown in the shaders list."); 1.41 + 1.42 + let vertexShader = yield firstProgramActor.getVertexShader(); 1.43 + let fragmentShader = yield firstProgramActor.getFragmentShader(); 1.44 + let vertSource = yield vertexShader.getText(); 1.45 + let fragSource = yield fragmentShader.getText(); 1.46 + 1.47 + let vsEditor = yield ShadersEditorsView._getEditor("vs"); 1.48 + let fsEditor = yield ShadersEditorsView._getEditor("fs"); 1.49 + 1.50 + is(vertSource, vsEditor.getText(), 1.51 + "The vertex shader editor contains the correct text."); 1.52 + is(fragSource, fsEditor.getText(), 1.53 + "The vertex shader editor contains the correct text."); 1.54 + 1.55 + let compiled = once(panel.panelWin, EVENTS.SHADER_COMPILED).then(() => { 1.56 + ok(false, "Selecting a different program shouldn't recompile its shaders."); 1.57 + }); 1.58 + 1.59 + let shown = once(panel.panelWin, EVENTS.SOURCES_SHOWN).then(() => { 1.60 + ok(true, "The vertex and fragment sources have changed in the editors."); 1.61 + }); 1.62 + 1.63 + EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[1].target); 1.64 + yield shown; 1.65 + 1.66 + is(ShadersListView.selectedItem, ShadersListView.items[1], 1.67 + "The shaders list has a correct item selected."); 1.68 + is(ShadersListView.selectedIndex, 1, 1.69 + "The shaders list has a correct index selected."); 1.70 + 1.71 + yield teardown(panel); 1.72 + finish(); 1.73 + 1.74 + function checkFirstProgram () { 1.75 + is(ShadersListView.itemCount, 1, 1.76 + "The shaders list contains one entry."); 1.77 + is(ShadersListView.selectedItem, ShadersListView.items[0], 1.78 + "The shaders list has a correct item selected."); 1.79 + is(ShadersListView.selectedIndex, 0, 1.80 + "The shaders list has a correct index selected."); 1.81 + } 1.82 + function checkSecondProgram () { 1.83 + is(ShadersListView.itemCount, 2, 1.84 + "The shaders list contains two entries."); 1.85 + is(ShadersListView.selectedItem, ShadersListView.items[0], 1.86 + "The shaders list has a correct item selected."); 1.87 + is(ShadersListView.selectedIndex, 0, 1.88 + "The shaders list has a correct index selected."); 1.89 + } 1.90 +}