Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / file-path-scoring.html
blob0268162e1ce51bce9ab7734a505d686c1d76ed07
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script src="../http/tests/inspector/sources-test.js"></script>
5 <script src="./resources/example-fileset-for-test.js"></script>
6 <script>
7 function test()
9 const TestQueries = [
10 ["textepl", "./Source/devtools/front_end/TextEditor.pl"],
11 ["defted", "./Source/devtools/front_end/DefaultTextEditor.pl"],
12 ["CMTE", "./Source/devtools/front_end/CodeMirrorTextEditor.pl"],
13 ["frocmte", "./Source/devtools/front_end/CodeMirrorTextEditor.pl"],
14 ["cmtepl", "./Source/devtools/front_end/CodeMirrorTextEditor.pl"],
15 ["setscr", "./Source/devtools/front_end/SettingsScreen.pl"],
16 ["cssnfv", "./Source/devtools/front_end/CSSNamedFlowView.pl"],
17 ["jssf", "./Source/devtools/front_end/JavaScriptSourceFrame.pl"],
18 ["sofrapl", "./Source/devtools/front_end/SourceFrame.pl"],
19 ["inspeins", "./Source/core/inspector/InspectorInstrumentation.bpp"],
20 ["froscr", "./Source/devtools/front_end/Script.pl"],
21 ["adscon", "./Source/devtools/front_end/AdvancedSearchController.pl"]
23 InspectorTest.evaluateInPage("blinkFilePaths()", step1);
24 InspectorTest.addResult("Expected score must be equal to the actual score");
26 function step1(filePaths)
28 var files = filePaths.value.split(":");
29 InspectorTest.addResult("Test set size: " + files.length);
30 for(var i = 0; i < TestQueries.length; ++i) {
31 runQuery(files, TestQueries[i][0], TestQueries[i][1]);
34 runQuery([
35 "svg/SVGTextRunRenderingContext.cpp",
36 "dom/ExecutionContext.cpp",
37 "testing/NullExecutionContext.cpp"
38 ], "execontext", "dom/ExecutionContext.cpp");
40 InspectorTest.completeTest();
43 function runQuery(paths, query, expected)
45 var scorer = new WebInspector.FilePathScoreFunction(query);
46 var bestScore = -1;
47 var bestIndex = -1;
48 var filter = WebInspector.FilePathScoreFunction.filterRegex(query);
49 for(var i = 0; i < paths.length; ++i) {
50 if (!filter.test(paths[i]))
51 continue;
52 var score = scorer.score(paths[i]);
53 if (score > bestScore) {
54 bestScore = score;
55 bestIndex = i;
58 var result = "\n=== Test query: " + query;
59 result += "\n expected return: " + render(scorer, expected);
60 result += "\n actual return: " + render(scorer, paths[bestIndex]);
61 InspectorTest.addResult(result);
64 function render(scorer, value)
66 var indexes = [];
67 var score = scorer.score(value, indexes);
68 var result = "";
69 var bold = false;
70 for(var i = 0; i < value.length; ++i) {
71 if (indexes.indexOf(i) !== -1) {
72 if (!bold)
73 result += ">";
74 bold = true;
75 result += value[i];
76 } else {
77 if (bold)
78 result += "<";
79 result += value[i];
80 bold = false;
83 if (bold)
84 result += "<";
85 return result + " (score: " + score + ")";
88 </script>
89 </head>
90 <body onload="runTest()">
91 <p>Test file path scoring function</p>
92 </body>
93 </html>