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

Side by Side Diff: LayoutTests/inspector/profiler/heap-snapshot-summary-search-by-id.html

Issue 696703003: DevTools: implement search for CPUProfiler FlameChart view (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comments addressed Created 6 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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="heap-snapshot-test.js"></script> 4 <script src="heap-snapshot-test.js"></script>
5 <script> 5 <script>
6 6
7 function test() 7 function test()
8 { 8 {
9 var instanceCount = 200; 9 var instanceCount = 200;
10 function createHeapSnapshot() 10 function createHeapSnapshot()
11 { 11 {
12 return InspectorTest.createHeapSnapshot(instanceCount, 100); 12 return InspectorTest.createHeapSnapshot(instanceCount, 100);
13 } 13 }
14 14
15 InspectorTest.runHeapSnapshotTestSuite([ 15 InspectorTest.runHeapSnapshotTestSuite([
16 function testSearch(next) 16 function testSearch(next)
17 { 17 {
18 InspectorTest.takeAndOpenSnapshot(createHeapSnapshot, step1); 18 InspectorTest.takeAndOpenSnapshot(createHeapSnapshot, step1);
19 19
20 function step1() 20 function step1()
21 { 21 {
22 InspectorTest.switchToView("Summary", step2); 22 InspectorTest.switchToView("Summary", step2);
23 } 23 }
24 24
25 var view; 25 var view;
26 function addNodeHighlightSniffer(constructorName, nodeId, onSuccess)
27 {
28 InspectorTest.addSniffer(view, "_didHighlightById", checkNodeIsH ighlighted.bind(view, constructorName, nodeId, onSuccess));
29 }
30
26 function step2() 31 function step2()
27 { 32 {
28 view = InspectorTest.currentProfileView(); 33 view = InspectorTest.currentProfileView();
29 view.performSearch("@101", checkNodeIsHighlighted.bind(this, "A" , "101", step3)); 34 addNodeHighlightSniffer("A", "101", step3);
35 view.performSearch({query:"@101", caseSensitive: false});
30 } 36 }
31 37
32 function step3() 38 function step3()
33 { 39 {
34 view.searchCanceled(); 40 view.performSearch({query: "@a", caseSensitive: false});
35 view.performSearch("@a", step4); 41 if (view._searchResults.length !== 0) {
36 }
37
38 function step4(view, resultCount)
39 {
40 if (resultCount !== 0) {
41 InspectorTest.addResult("FAIL: node @a found"); 42 InspectorTest.addResult("FAIL: node @a found");
42 return next(); 43 return next();
43 } 44 }
44 view.searchCanceled(); 45 InspectorTest.addResult("PASS: node @a was not found");
45 view.performSearch("@999", step5); 46 InspectorTest.addSniffer(view, "_didHighlightById", step5);
47 view.performSearch({query: "@999", caseSensitive: false}, step5) ;
46 } 48 }
47 49
48 function step5(view, resultCount) 50 function step5(found)
49 { 51 {
50 if (resultCount !== 0) { 52 if (found) {
51 InspectorTest.addResult("FAIL: found node @999"); 53 InspectorTest.addResult("FAIL: found node @999");
52 return next(); 54 return next();
53 } 55 }
54 view.searchCanceled(); 56 InspectorTest.addResult("PASS: node @999 was not found");
55 view.performSearch("@100", checkNodeIsHighlighted.bind(this, "B" , "100", step6)); 57 addNodeHighlightSniffer("B", "100", step6);
58 view.performSearch({query: "@100", caseSensitive: false});
56 } 59 }
57 60
58 function step6() 61 function step6()
59 { 62 {
60 view.searchCanceled(); 63 addNodeHighlightSniffer("B", "400", step7);
61 view.performSearch("@400", checkNodeIsHighlighted.bind(this, "B" , "400", step7)); 64 view.performSearch({query: "@400", caseSensitive: false});
62 } 65 }
63 66
64 function step7() 67 function step7()
65 { 68 {
66 view.searchCanceled(); 69 addNodeHighlightSniffer("A", "401", next);
67 view.performSearch("@401", checkNodeIsHighlighted.bind(this, "A" , "401", next)); 70 view.performSearch({query: "@401", caseSensitive: false});
68 } 71 }
69 72
70 function checkNodeIsHighlighted(constructorName, nodeId, onSuccess, view, resultCount) 73 function checkNodeIsHighlighted(constructorName, nodeId, onSuccess, found)
71 { 74 {
72 if (resultCount !== 1) { 75 if (!found) {
73 InspectorTest.addResult("FAIL: node @" + nodeId + " not foun d"); 76 InspectorTest.addResult("FAIL: node @" + nodeId + " not foun d");
74 return next(); 77 return next();
75 } 78 }
76 try { 79 try {
77 var constructorsGrid = InspectorTest.currentProfileView()._d ataGrid; 80 var constructorsGrid = InspectorTest.currentProfileView()._d ataGrid;
78 var constructorNodes = constructorsGrid.rootNode().children; 81 var constructorNodes = constructorsGrid.rootNode().children;
79 var constructorNode; 82 var constructorNode;
80 for (var i = 0; i < constructorNodes.length; i++) { 83 for (var i = 0; i < constructorNodes.length; i++) {
81 if (constructorNodes[i].data.object === constructorName) { 84 if (constructorNodes[i].data.object === constructorName) {
82 constructorNode = constructorNodes[i]; 85 constructorNode = constructorNodes[i];
83 break; 86 break;
84 } 87 }
85 } 88 }
86 if (!constructorNode) { 89 if (!constructorNode) {
87 InspectorTest.addResult("FAIL: constructor " + construct orName + " not found in viewport"); 90 InspectorTest.addResult("FAIL: constructor " + construct orName + " not found in viewport");
88 return next(); 91 return next();
89 } 92 }
90 var instanceNodes = constructorNode.children; 93 var instanceNodes = constructorNode.children;
91 for (var i = 0; i < instanceNodes.length; i++) { 94 for (var i = 0; i < instanceNodes.length; i++) {
92 if (instanceNodes[i].snapshotNodeId == nodeId) { 95 if (instanceNodes[i].snapshotNodeId == nodeId) {
93 if (!instanceNodes[i].element().classList.contains(" highlighted-row")) { 96 if (!instanceNodes[i].element().classList.contains(" highlighted-row")) {
94 if (constructorsGrid._nodeToHighlightAfterScroll === instanceNodes[i]) { 97 if (constructorsGrid._nodeToHighlightAfterScroll === instanceNodes[i]) {
95 function afterScroll(nodeToHighlight) 98 function afterScroll(nodeToHighlight)
96 { 99 {
100 InspectorTest.addResult("PASS: found nod e @" + nodeId + " with class '" + constructorName + "'");
97 onSuccess(); 101 onSuccess();
98 } 102 }
99 InspectorTest.addSniffer(WebInspector.HeapSn apshotSortableDataGrid.prototype, "highlightNode", afterScroll); 103 InspectorTest.addSniffer(WebInspector.HeapSn apshotSortableDataGrid.prototype, "highlightNode", afterScroll);
100 return; 104 return;
101 } else { 105 } else {
102 InspectorTest.addResult("FAIL: node is not h ighlighted"); 106 InspectorTest.addResult("FAIL: node is not h ighlighted");
103 return next(); 107 return next();
104 } 108 }
105 } 109 }
110 InspectorTest.addResult("PASS: found node @" + nodeI d + " with class '" + constructorName + "'");
106 return onSuccess(); 111 return onSuccess();
107 } 112 }
108 } 113 }
109 } catch (e) { 114 } catch (e) {
110 InspectorTest.addResult("EXCEPTION: " + e); 115 InspectorTest.addResult("EXCEPTION: " + e);
111 } 116 }
112 return next(); 117 return next();
113 } 118 }
114 } 119 }
115 ]); 120 ]);
116 } 121 }
117 122
118 </script> 123 </script>
119 </head> 124 </head>
120 <body onload="runTest()"> 125 <body onload="runTest()">
121 <p> 126 <p>
122 Tests search in Summary view of detailed heap snapshots. 127 Tests search in Summary view of detailed heap snapshots.
123 </p> 128 </p>
124 </body> 129 </body>
125 </html> 130 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698