33// found in the LICENSE file.
44
55import * 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' ;
78import { describeWithEnvironment } from '../../testing/EnvironmentHelpers.js' ;
9+ import { getMainThread } from '../../testing/TraceHelpers.js' ;
810import { TraceLoader } from '../../testing/TraceLoader.js' ;
11+ import * as UI from '../../ui/legacy/legacy.js' ;
912
1013import * as TimelineComponents from './components/components.js' ;
1114import * as Timeline from './timeline.js' ;
1215
1316describeWithEnvironment ( '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 ( ) ;
0 commit comments