@@ -20,9 +20,14 @@ void testMain() {
2020 group ('CanvasKit' , () {
2121 setUpCanvasKitTest ();
2222
23+ setUp (() {
24+ window.debugOverrideDevicePixelRatio (1 );
25+ });
26+
2327 test ('Surface allocates canvases efficiently' , () {
2428 final Surface surface = Surface (HtmlViewEmbedder ());
25- final CkSurface original = surface.acquireFrame (ui.Size (9 , 19 )).skiaSurface;
29+ final CkSurface original =
30+ surface.acquireFrame (ui.Size (9 , 19 )).skiaSurface;
2631
2732 // Expect exact requested dimensions.
2833 expect (original.width (), 9 );
@@ -38,7 +43,8 @@ void testMain() {
3843
3944 // The first increase will allocate a new surface, but will overallocate
4045 // by 40% to accommodate future increases.
41- final CkSurface firstIncrease = surface.acquireFrame (ui.Size (10 , 20 )).skiaSurface;
46+ final CkSurface firstIncrease =
47+ surface.acquireFrame (ui.Size (10 , 20 )).skiaSurface;
4248 expect (firstIncrease, isNot (same (original)));
4349
4450 // Expect overallocated dimensions
@@ -48,7 +54,8 @@ void testMain() {
4854 expect (surface.htmlCanvas! .style.height, '28px' );
4955
5056 // Subsequent increases within 40% reuse the old surface.
51- final CkSurface secondIncrease = surface.acquireFrame (ui.Size (11 , 22 )).skiaSurface;
57+ final CkSurface secondIncrease =
58+ surface.acquireFrame (ui.Size (11 , 22 )).skiaSurface;
5259 expect (secondIncrease, same (firstIncrease));
5360
5461 // Increases beyond the 40% limit will cause a new allocation.
@@ -62,7 +69,8 @@ void testMain() {
6269 expect (surface.htmlCanvas! .style.height, '56px' );
6370
6471 // Shrink again. Reuse the last allocated surface.
65- final CkSurface shrunk2 = surface.acquireFrame (ui.Size (5 , 15 )).skiaSurface;
72+ final CkSurface shrunk2 =
73+ surface.acquireFrame (ui.Size (5 , 15 )).skiaSurface;
6674 expect (shrunk2, same (huge));
6775 });
6876
@@ -71,25 +79,30 @@ void testMain() {
7179 () async {
7280 final Surface surface = Surface (HtmlViewEmbedder ());
7381 expect (surface.debugForceNewContext, isTrue);
74- final CkSurface before = surface.acquireFrame (ui.Size (9 , 19 )).skiaSurface;
82+ final CkSurface before =
83+ surface.acquireFrame (ui.Size (9 , 19 )).skiaSurface;
7584 expect (surface.debugForceNewContext, isFalse);
7685
7786 // Pump a timer to flush any microtasks.
7887 await Future <void >.delayed (Duration .zero);
79- final CkSurface afterAcquireFrame = surface.acquireFrame (ui.Size (9 , 19 )).skiaSurface;
88+ final CkSurface afterAcquireFrame =
89+ surface.acquireFrame (ui.Size (9 , 19 )).skiaSurface;
8090 // Existing context is reused.
8191 expect (afterAcquireFrame, same (before));
8292
8393 // Emulate WebGL context loss.
84- final html.CanvasElement canvas = surface.htmlElement.children.single as html.CanvasElement ;
94+ final html.CanvasElement canvas =
95+ surface.htmlElement.children.single as html.CanvasElement ;
8596 final dynamic ctx = canvas.getContext ('webgl2' );
86- final dynamic loseContextExtension = ctx.getExtension ('WEBGL_lose_context' );
97+ final dynamic loseContextExtension =
98+ ctx.getExtension ('WEBGL_lose_context' );
8799 loseContextExtension.loseContext ();
88100
89101 // Pump a timer to allow the "lose context" event to propagate.
90102 await Future <void >.delayed (Duration .zero);
91103 expect (surface.debugForceNewContext, isTrue);
92- final CkSurface afterContextLost = surface.acquireFrame (ui.Size (9 , 19 )).skiaSurface;
104+ final CkSurface afterContextLost =
105+ surface.acquireFrame (ui.Size (9 , 19 )).skiaSurface;
93106 // A new cotext is created.
94107 expect (afterContextLost, isNot (same (before)));
95108 },
@@ -100,7 +113,8 @@ void testMain() {
100113 // Regression test for https://github.com/flutter/flutter/issues/75286
101114 test ('updates canvas logical size when device-pixel ratio changes' , () {
102115 final Surface surface = Surface (HtmlViewEmbedder ());
103- final CkSurface original = surface.acquireFrame (ui.Size (10 , 16 )).skiaSurface;
116+ final CkSurface original =
117+ surface.acquireFrame (ui.Size (10 , 16 )).skiaSurface;
104118
105119 expect (original.width (), 10 );
106120 expect (original.height (), 16 );
@@ -110,7 +124,8 @@ void testMain() {
110124 // Increase device-pixel ratio: this makes CSS pixels bigger, so we need
111125 // fewer of them to cover the browser window.
112126 window.debugOverrideDevicePixelRatio (2.0 );
113- final CkSurface highDpr = surface.acquireFrame (ui.Size (10 , 16 )).skiaSurface;
127+ final CkSurface highDpr =
128+ surface.acquireFrame (ui.Size (10 , 16 )).skiaSurface;
114129 expect (highDpr.width (), 10 );
115130 expect (highDpr.height (), 16 );
116131 expect (surface.htmlCanvas! .style.width, '5px' );
@@ -119,7 +134,8 @@ void testMain() {
119134 // Decrease device-pixel ratio: this makes CSS pixels smaller, so we need
120135 // more of them to cover the browser window.
121136 window.debugOverrideDevicePixelRatio (0.5 );
122- final CkSurface lowDpr = surface.acquireFrame (ui.Size (10 , 16 )).skiaSurface;
137+ final CkSurface lowDpr =
138+ surface.acquireFrame (ui.Size (10 , 16 )).skiaSurface;
123139 expect (lowDpr.width (), 10 );
124140 expect (lowDpr.height (), 16 );
125141 expect (surface.htmlCanvas! .style.width, '20px' );
0 commit comments