OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../http/tests/inspector/timeline-test.js"></script> |
4 <script src="../../http/tests/inspector/layers-test.js"></script> | 5 <script src="../../http/tests/inspector/layers-test.js"></script> |
5 <script src="../tracing-test.js"></script> | 6 <script src="../tracing-test.js"></script> |
6 | 7 |
7 <script> | 8 <script> |
8 function doActions(callback) | 9 function doActions(callback) |
9 { | 10 { |
10 var div = document.createElement("div"); | 11 var div = document.createElement("div"); |
11 div.id = "b4"; | 12 div.id = "b4"; |
12 document.getElementById("a").appendChild(div); | 13 document.getElementById("a").appendChild(div); |
13 | 14 |
14 // Make sure to force commit, otherwise some owner nodes will be missing. | 15 // Make sure to force commit, otherwise some owner nodes will be missing. |
15 var style = document.createElement("style"); | 16 var style = document.createElement("style"); |
16 style.textContent = ".layer { transform: translateZ(10px); opacity: 0.8; }"; | 17 style.textContent = ".layer { transform: translateZ(10px); opacity: 0.8; }"; |
17 document.head.appendChild(style); | 18 document.head.appendChild(style); |
18 | 19 |
19 if (!window.testRunner) { | 20 if (!window.testRunner) { |
20 callback(); | 21 callback(); |
21 return; | 22 return; |
22 } | 23 } |
23 testRunner.displayAsyncThen(callback); | 24 var pendingFrames = 3; |
| 25 makeFrame(); |
| 26 function makeFrame() |
| 27 { |
| 28 if (!--pendingFrames) { |
| 29 callback(); |
| 30 return; |
| 31 } |
| 32 testRunner.displayAsyncThen(requestAnimationFrame.bind(window, makeFrame
)); |
| 33 } |
24 } | 34 } |
25 | 35 |
26 function test() | 36 function test() |
27 { | 37 { |
28 InspectorTest.invokeWithTracing("doActions", onTracingComplete); | 38 WebInspector.panels.timeline._captureLayersAndPicturesSetting.set(true); |
29 | 39 |
30 var target = /** @type {!WebInspector.Target} */ (WebInspector.targetManager
.mainTarget()); | 40 InspectorTest.invokeAsyncWithTimeline("doActions", step1); |
31 var layerTree = new WebInspector.TracingLayerTree(target); | 41 function step1() |
32 | |
33 function onTracingComplete() | |
34 { | 42 { |
35 var events = InspectorTest.tracingTimelineModel().inspectedTargetEvents(
); | 43 var frames = InspectorTest.timelineFrameModel().frames(); |
36 for (var i = events.length - 1; i >= 0; --i) { | 44 var lastFrame = InspectorTest.timelineFrameModel().frames().peekLast(); |
37 if (events[i].phase === WebInspector.TracingModel.Phase.SnapshotObje
ct && events[i].name === "cc::LayerTreeHostImpl") { | 45 var deferredLayerTree = lastFrame.layerTree; |
38 var rootLayer = events[i].args["snapshot"]["active_tree"]["root_
layer"]; | 46 deferredLayerTree.resolve(InspectorTest.safeWrap(layerTreeResolved)); |
39 dumpLayerTreeSnapshot(rootLayer); | |
40 return; | |
41 } | |
42 } | |
43 InspectorTest.addResult("FAIL: cc::LayerTreeHostImpl snapshot not found"
); | |
44 InspectorTest.completeTest(); | |
45 } | 47 } |
46 | 48 |
47 function dumpLayerTreeSnapshot(rootLayer) | 49 function layerTreeResolved(layerTree) |
48 { | |
49 layerTree.setLayers(rootLayer, onLayersSet); | |
50 } | |
51 | |
52 function onLayersSet() | |
53 { | 50 { |
54 InspectorTest.layerTreeModel.setLayerTree(layerTree); | 51 InspectorTest.layerTreeModel.setLayerTree(layerTree); |
55 InspectorTest.dumpLayerTree(); | 52 InspectorTest.dumpLayerTree(); |
56 InspectorTest.completeTest(); | 53 InspectorTest.completeTest(); |
57 } | 54 } |
58 } | 55 } |
59 </script> | 56 </script> |
60 | 57 |
61 <body onload="runTestAfterDisplay()"> | 58 <body onload="runTestAfterDisplay()"> |
62 Tests that LayerTreeModel successfully imports layers from a trace. | 59 Tests that LayerTreeModel successfully imports layers from a trace. |
63 </p> | 60 </p> |
64 <div id="a" style="width: 200px; height: 200px" class="layer"> | 61 <div id="a" style="width: 200px; height: 200px" class="layer"> |
65 <div class="layer" id="b1" style="width: 150px; height: 100px"></div> | 62 <div class="layer" id="b1" style="width: 150px; height: 100px"></div> |
66 <div id="b2" class="layer" style="width: 140px; height: 110px"> | 63 <div id="b2" class="layer" style="width: 140px; height: 110px"> |
67 <div id="c" class="layer" style="width: 100px; height: 90px"></div> | 64 <div id="c" class="layer" style="width: 100px; height: 90px"></div> |
68 </div> | 65 </div> |
69 <div id="b3" class="layer" style="width: 140px; height: 110px"></div> | 66 <div id="b3" class="layer" style="width: 140px; height: 110px"></div> |
70 </div> | 67 </div> |
71 </body> | 68 </body> |
72 </html> | 69 </html> |
OLD | NEW |