Skip to content

Commit 9c1e664

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
test: Migrate TimelineOverview interactions to MiniMap unit tests
R=alexrudenko@chromium.org Fixed: 413414809 Change-Id: I0ff370083a1a8e95dc89606b49ecb1b4fa706cd6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6616830 Commit-Queue: Alex Rudenko <alexrudenko@chromium.org> Auto-Submit: Jack Franklin <jacktfranklin@chromium.org> Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
1 parent 109931c commit 9c1e664

14 files changed

Lines changed: 43 additions & 186 deletions

File tree

front_end/panels/timeline/TimelineMiniMap.test.ts

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,52 @@
33
// found in the LICENSE file.
44

55
import * as Trace from '../../models/trace/trace.js';
6-
import {raf, renderElementIntoDOM} from '../../testing/DOMHelpers.js';
6+
import * as TraceBounds from '../../services/trace_bounds/trace_bounds.js';
7+
import {assertScreenshot, raf, renderElementIntoDOM} from '../../testing/DOMHelpers.js';
78
import {describeWithEnvironment} from '../../testing/EnvironmentHelpers.js';
9+
import {getMainThread} from '../../testing/TraceHelpers.js';
810
import {TraceLoader} from '../../testing/TraceLoader.js';
11+
import * as UI from '../../ui/legacy/legacy.js';
912

1013
import * as TimelineComponents from './components/components.js';
1114
import * as Timeline from './timeline.js';
1215

1316
describeWithEnvironment('TimelineMiniMap', function() {
14-
it('always shows the responsiveness, CPU activity and network panel', async function() {
15-
const {parsedTrace} = await TraceLoader.traceEngine(this, 'web-dev.json.gz');
16-
17+
async function renderMiniMapForScreenshot(parsedTrace: Trace.Handlers.Types.ParsedTrace): Promise<void> {
1718
const container = document.createElement('div');
19+
container.style.flex = 'none';
20+
container.style.display = 'flex';
21+
container.style.position = 'relative';
22+
container.style.width = '600px';
23+
container.style.height = '200px';
24+
container.innerHTML = `<style>${UI.inspectorCommonStyles}</style>`;
1825
renderElementIntoDOM(container);
1926

2027
const minimap = new Timeline.TimelineMiniMap.TimelineMiniMap();
2128
minimap.markAsRoot();
2229
minimap.show(container);
23-
2430
minimap.setData({
2531
parsedTrace,
2632
settings: {
27-
showMemory: false,
28-
showScreenshots: false,
33+
showMemory: true,
34+
showScreenshots: true,
2935
},
3036
});
31-
37+
// This needs to happen once the MiniMap is in the DOM in order to first set the trace bounds.
38+
TraceBounds.TraceBounds.BoundsManager.instance().resetWithNewBounds(parsedTrace.Meta.traceBounds);
39+
40+
// Now we can zoom into the main thread activity; this means the resize handles are
41+
// not both on the edge of the screen, so it's a more representative screenshot.
42+
const mainThread = getMainThread(parsedTrace.Renderer);
43+
const zoomedWindow = Trace.Extras.MainThreadActivity.calculateWindow(
44+
parsedTrace.Meta.traceBounds,
45+
mainThread.entries,
46+
);
47+
TraceBounds.TraceBounds.BoundsManager.instance().setTimelineVisibleWindow(zoomedWindow);
3248
await raf();
33-
assert.exists(container.querySelector('#timeline-overview-responsiveness'));
34-
assert.exists(container.querySelector('#timeline-overview-cpu-activity'));
35-
assert.exists(container.querySelector('#timeline-overview-network'));
36-
assert.isNull(container.querySelector('#timeline-overview-filmstrip'));
37-
assert.isNull(container.querySelector('#timeline-overview-memory'));
38-
minimap.detach();
39-
});
49+
}
4050

41-
it('will show the other panels if they are set to visible', async function() {
51+
it('always shows the responsiveness, CPU activity and network panel', async function() {
4252
const {parsedTrace} = await TraceLoader.traceEngine(this, 'web-dev.json.gz');
4353

4454
const container = document.createElement('div');
@@ -51,18 +61,29 @@ describeWithEnvironment('TimelineMiniMap', function() {
5161
minimap.setData({
5262
parsedTrace,
5363
settings: {
54-
showMemory: true,
55-
showScreenshots: true,
64+
showMemory: false,
65+
showScreenshots: false,
5666
},
5767
});
5868

5969
await raf();
6070
assert.exists(container.querySelector('#timeline-overview-responsiveness'));
6171
assert.exists(container.querySelector('#timeline-overview-cpu-activity'));
6272
assert.exists(container.querySelector('#timeline-overview-network'));
63-
assert.exists(container.querySelector('#timeline-overview-filmstrip'));
64-
assert.exists(container.querySelector('#timeline-overview-memory'));
65-
minimap.detach();
73+
assert.isNull(container.querySelector('#timeline-overview-filmstrip'));
74+
assert.isNull(container.querySelector('#timeline-overview-memory'));
75+
});
76+
77+
it('shows memory and screenshots also if they are set to be visible', async function() {
78+
const {parsedTrace} = await TraceLoader.traceEngine(this, 'web-dev.json.gz');
79+
await renderMiniMapForScreenshot(parsedTrace);
80+
await assertScreenshot('timeline/minimap_with_memory_and_screenshots.png');
81+
});
82+
83+
it('highlights long tasks in red', async function() {
84+
const {parsedTrace} = await TraceLoader.traceEngine(this, 'one-second-interaction.json.gz');
85+
await renderMiniMapForScreenshot(parsedTrace);
86+
await assertScreenshot('timeline/minimap_long_task.png');
6687
});
6788

6889
it('creates the first breadcrumb', async function() {
@@ -92,6 +113,7 @@ describeWithEnvironment('TimelineMiniMap', function() {
92113
assert.lengthOf(TimelineComponents.Breadcrumbs.flattenBreadcrumbs(minimap.breadcrumbs.initialBreadcrumb), 1);
93114
assert.deepEqual(minimap.breadcrumbs.initialBreadcrumb, {window: parsedTrace.Meta.traceBounds, child: null});
94115
});
116+
95117
it('stores breadcrumbs to be serialized', async function() {
96118
const {parsedTrace} = await TraceLoader.traceEngine(this, 'web-dev.json.gz');
97119
const minimap = new Timeline.TimelineMiniMap.TimelineMiniMap();

front_end/panels/timeline/timelineMiniMap.css

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,6 @@
88
position: relative;
99
}
1010

11-
.timeline-sidebar-floating-icon {
12-
position: absolute;
13-
top: 5px;
14-
left: 10px;
15-
z-index: 999;
16-
border: none;
17-
width: 36px;
18-
height: 36px;
19-
border-radius: 50%;
20-
box-shadow: var(--drop-shadow-depth-1);
21-
background: var(--sys-color-cdt-base-container);
22-
23-
&:hover {
24-
background: var(--sys-color-base-container-elevated);
25-
}
26-
}
27-
2811
.timeline-minimap .overview-strip {
2912
margin-top: 2px;
3013
justify-content: center;

front_end/ui/components/docs/performance_panel/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ ts_library("ts") {
1212
"layout_shift_details.ts",
1313
"network_request_details.ts",
1414
"network_request_tooltip.ts",
15-
"overview.ts",
1615
"track_example.ts",
1716
]
1817
deps = [
@@ -36,7 +35,6 @@ copy_to_gen("performance_panel") {
3635
"layout_shift_details.html",
3736
"network_request_details.html",
3837
"network_request_tooltip.html",
39-
"overview.html",
4038
"track_example.html",
4139
]
4240

front_end/ui/components/docs/performance_panel/overview.html

Lines changed: 0 additions & 27 deletions
This file was deleted.

front_end/ui/components/docs/performance_panel/overview.ts

Lines changed: 0 additions & 65 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-11.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)