3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/timeline-test.js"></script>
5 <script src="resources/timeline-data.js"></script>
10 var timelineData = InspectorTest.timelineData();
12 var timeline = WebInspector.panels.timeline;
13 var overviewPane = timeline._overviewPane;
14 var model = timeline._model;
15 InspectorTest.switchTimelineToWaterfallMode();
17 function createFileReader(file, delegate)
19 return new InspectorTest.FakeFileReader(timelineData, delegate, model.saveToFile.bind(model));
22 InspectorTest.override(model, "_createFileReader", createFileReader);
24 model.loadFromFile({}, new WebInspector.Progress());
25 timeline._currentViews[0]._refresh();
27 overviewPane.update();
28 InspectorTest.addResult("OverviewPane:");
29 overviewPane._overviewCalculator._setDisplayWindow(0, 450);
30 dumpDividers(overviewPane._overviewCalculator);
31 InspectorTest.addResult("");
33 function dumpRecordsCountForRange(windowLeft, windowRight)
35 var view = timeline._currentViews[0];
36 overviewPane._overviewGrid.setWindow(windowLeft, windowRight);
38 InspectorTest.addResult("mode = " + timeline._overviewModeSetting.get());
39 InspectorTest.addResult("range = " + windowLeft + " - " + windowRight);
40 InspectorTest.addResult("time range = " + view._windowStartTime + " - " + view._windowEndTime);
41 InspectorTest.addResult("records count: " + view._presentationModel.filteredRecords().length);
42 view._calculator.setDisplayWindow(5, 455 + WebInspector.TimelineCalculator._minWidth);
43 dumpDividers(view._calculator);
44 InspectorTest.addResult("");
47 function dumpFlameChartRecordsCountForRange(windowLeft, windowRight)
49 var mainView = timeline._currentViews[0]._mainView;
50 overviewPane._overviewGrid.setWindow(windowLeft, windowRight);
52 InspectorTest.addResult("mode = " + timeline._overviewModeSetting.get());
53 InspectorTest.addResult("range = " + windowLeft + " - " + windowRight);
54 InspectorTest.addResult("time range = " + mainView._timeWindowLeft + " - " + mainView._timeWindowRight);
55 mainView._calculator.setDisplayWindow(5, 455 + WebInspector.TimelineCalculator._minWidth);
56 dumpDividers(mainView._calculator);
57 InspectorTest.addResult("");
60 function dumpDividers(calculator)
62 var dividers = WebInspector.TimelineGrid.calculateDividerOffsets(calculator).offsets;
63 for (var i = 0; i < dividers.length; ++i)
64 dividers[i] -= calculator.zeroTime();
65 InspectorTest.addResult("divider offsets: [" + dividers.join(", ") + "]. We are expecting round numbers.");
68 timeline._overviewModeSetting.set(WebInspector.TimelinePanel.OverviewMode.Events);
69 timeline._onModeChanged();
70 dumpRecordsCountForRange(0, 1);
71 dumpRecordsCountForRange(0.25, 0.75);
72 dumpRecordsCountForRange(0.33, 0.66);
74 timeline._overviewModeSetting.set(WebInspector.TimelinePanel.OverviewMode.Frames);
75 timeline._onModeChanged();
76 dumpRecordsCountForRange(0, 1);
77 dumpRecordsCountForRange(0.25, 0.75);
78 dumpRecordsCountForRange(0.33, 0.66);
80 timeline._overviewModeSetting.set(WebInspector.TimelinePanel.OverviewMode.Frames);
81 timeline._flameChartEnabledSetting.set(true);
82 timeline._onModeChanged();
83 // FIXME(394762): uncomment once we support loading tracing events.
84 // dumpFlameChartRecordsCountForRange(0, 1);
85 // dumpFlameChartRecordsCountForRange(0.25, 0.5);
86 // dumpFlameChartRecordsCountForRange(0.33, 0.4);
88 overviewPane._overviewGrid.setWindow(0.1, 0.9);
90 InspectorTest.addResult("--------------------------------------------------------");
91 InspectorTest.addResult("mode = " + timeline._overviewModeSetting.get());
92 InspectorTest.addResult("time range = " + timeline._windowStartTime + " - " + timeline._windowEndTime);
94 timeline._overviewModeSetting.set(WebInspector.TimelinePanel.OverviewMode.Events);
95 timeline._flameChartEnabledSetting.set(false);
96 timeline._onModeChanged();
97 InspectorTest.addResult("");
99 InspectorTest.addResult("mode = " + timeline._overviewModeSetting.get());
100 InspectorTest.addResult("time range = " + timeline._windowStartTime + " - " + timeline._windowEndTime);
101 timeline._overviewModeSetting.set(WebInspector.TimelinePanel.OverviewMode.Frames);
102 timeline._onModeChanged();
103 InspectorTest.addResult("");
105 InspectorTest.addResult("mode = " + timeline._overviewModeSetting.get());
106 InspectorTest.addResult("time range = " + timeline._windowStartTime + " - " + timeline._windowEndTime);
107 timeline._overviewModeSetting.set(WebInspector.TimelinePanel.OverviewMode.Frames);
108 timeline._flameChartEnabledSetting.set(true);
109 timeline._onModeChanged();
111 InspectorTest.completeTest();
117 <body onload="runTest()">
119 Tests the Timeline window filter.
123 It applies different ranges to the OverviewGrid and expects that current view reflects the change.
126 Also it detects that after switching to another view it gets the proper time range.