Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: LayoutTests/inspector/profiler/webgl/webgl-get-resource-state-buffer-data.html

Issue 1073863003: DevTools: remove Canvas profiler from DevTools source base. See details in the bug. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tests gone Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../canvas-profiler-test.js"></script>
5 <script>
6 if (window.internals)
7 window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
8
9 var gl;
10
11 function createCanvasContext()
12 {
13 gl = createWebGLContext(document.getElementById("canvas"));
14 console.assert(gl, "Failed to create a WebGL context");
15 }
16
17 function doCanvasCalls()
18 {
19 gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
20 gl.bufferData(gl.ARRAY_BUFFER, 5, gl.STATIC_DRAW); // 5 zeros
21
22 var bufferView = new Uint16Array([0x0000, 0x1122, 0x3344, 0x5566, 0x7788, 0x 99aa, 0xbbcc, 0xddee, 0xffff]);
23 gl.bufferData(gl.ARRAY_BUFFER, bufferView, gl.DYNAMIC_DRAW);
24
25 var bufferView2 = new Int8Array([1, 1, 2, 2, 3, 3]);
26 gl.bufferSubData(gl.ARRAY_BUFFER, 2, bufferView2);
27
28 gl.bufferSubData(gl.ARRAY_BUFFER, 8, new ArrayBuffer(4)); // zero out [0x778 8, 0x99aa]
29
30 var subBufferView = new Uint8Array(bufferView.buffer, 14, 4); // refers to [ 0xddee, 0xffff]
31 gl.bufferSubData(gl.ARRAY_BUFFER, 0, subBufferView);
32
33 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, 0, 1]), gl.DYNAMIC_DRAW );
34 gl.bufferSubData(gl.ARRAY_BUFFER, 0, new Uint32Array([1, 2, 3])); // full replacement
35 gl.bufferSubData(gl.ARRAY_BUFFER, 0, new Int16Array([-1, -2, -3, -4, -5, -6] )); // full replacement
36 gl.bufferSubData(gl.ARRAY_BUFFER, 0, new Int8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])); // full replacement
37 gl.bufferSubData(gl.ARRAY_BUFFER, 1, new Uint32Array([0xffffffff, 0xffffffff ])); // -1 x8
38
39 var err = gl.getError();
40 console.assert(err === gl.NO_ERROR, "Should be no GL errors, but was: " + er r);
41 }
42
43 function test()
44 {
45 var traceLog;
46 var traceLogId;
47 var resourceIds;
48
49 InspectorTest.enableCanvasAgent(step1);
50 function step1()
51 {
52 InspectorTest.evaluateInPage("createCanvasContext()", step2);
53 }
54 function step2()
55 {
56 InspectorTest.CanvasAgent.startCapturing(didStartCapturing);
57 }
58 function didStartCapturing(error, id)
59 {
60 InspectorTest.assertTrue(!error && !!id, "Unexpected error: " + error);
61 InspectorTest.addResult("\nStarted capturing.");
62 traceLogId = id;
63 InspectorTest.evaluateInPage("doCanvasCalls()", didCanvasCalls);
64 }
65 function didCanvasCalls()
66 {
67 InspectorTest.CanvasAgent.stopCapturing(traceLogId, didStopCapturing);
68 }
69 function didStopCapturing()
70 {
71 InspectorTest.addResult("Stopped capturing.");
72 InspectorTest.CanvasAgent.getTraceLog(traceLogId, 0, undefined, didRecei veTraceLog);
73 }
74 function didReceiveTraceLog(error, traceLogValue)
75 {
76 traceLog = traceLogValue;
77 InspectorTest.assertTrue(!error && !!traceLog, "Unexpected error: " + er ror);
78 InspectorTest.assertTrue(traceLog.calls.length > 0, "Expected not empty trace log calls array");
79 resourceIds = InspectorTest.collectResourceIdsFromTraceLog(traceLog);
80 replayUntilNextBufferDataCall(0);
81 }
82 function replayUntilNextBufferDataCall(offset)
83 {
84 var bufferDataCalls = ["bindBuffer", "bufferData", "bufferSubData"];
85 var calls = traceLog.calls;
86 for (var i = offset, n = calls.length; i < n; ++i) {
87 var call = calls[i];
88 if (bufferDataCalls.indexOf(call.functionName) !== -1) {
89 InspectorTest.CanvasAgent.replayTraceLog(traceLogId, i, didRepla yTraceLog.bind(null, i));
90 return;
91 }
92 }
93 InspectorTest.completeTest();
94 }
95 function didReplayTraceLog(stepNo)
96 {
97 InspectorTest.addResult("\nReplayed call #" + stepNo);
98 InspectorTest.CanvasAgent.getResourceState(traceLogId, resourceIds["WebG LBuffer@1"], didGetResourceState);
99
100 function didGetResourceState(error, resourceState)
101 {
102 InspectorTest.assertTrue(!error && !!resourceState, "Unexpected erro r: " + error);
103 var descriptor = InspectorTest.findResourceStateDescriptor(resourceS tate, "bufferData");
104 if (!descriptor)
105 InspectorTest.addResult("No bufferData available");
106 else {
107 var remoteObject = descriptor.value && descriptor.value.remoteOb ject;
108 if (!remoteObject)
109 InspectorTest.addResult("FAIL: Internal error in the protoco l: no \"remoteObject\" property in a CallArgument");
110 else {
111 var obj = InspectorTest.runtimeModel.createRemoteObject(remo teObject);
112 obj.getOwnProperties(didGetOwnProperties.bind(null, descript or.value.description));
113 return;
114 }
115 }
116 replayUntilNextBufferDataCall(stepNo + 1);
117 }
118
119 function didGetOwnProperties(description, properties)
120 {
121 function formatNumber(value)
122 {
123 if (/^Uint16Array/.test(description)) {
124 var str = "0000" + Number(value || 0).toString(16);
125 str = str.replace(/^0+(.{4,})$/, "$1");
126 return "0x" + str;
127 }
128 return value;
129 }
130
131 var result = [];
132 for (var i = 0; i < properties.length; ++i) {
133 var index = properties[i].name;
134 var value = properties[i].value;
135 if (!isNaN(index))
136 result[+index] = formatNumber(value && value.value);
137 }
138 InspectorTest.addResult("bufferData: " + description + ": [" + resul t.join(", ") + "]");
139 replayUntilNextBufferDataCall(stepNo + 1);
140 }
141 }
142 }
143
144 </script>
145 </head>
146 <body onload="runTest()">
147 <p>
148 Tests WebGLBuffer data state during the replay.
149 </p>
150 <canvas id="canvas"></canvas>
151 </body>
152 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698