@@ -83,6 +83,32 @@ def test_webagg_general(random_port, page):
83
83
raise ImageComparisonFailure (err )
84
84
85
85
86
+ @pytest .mark .backend ('webagg' )
87
+ def test_webagg_resize (random_port , page ):
88
+ fig , ax = plt .subplots (facecolor = 'w' )
89
+ orig_bbox = fig .bbox .frozen ()
90
+
91
+ # Don't start the Tornado event loop, but use the existing event loop
92
+ # started by the `page` fixture.
93
+ WebAggApplication .initialize (port = random_port )
94
+ WebAggApplication .started = True
95
+
96
+ page .goto (f'http://{ WebAggApplication .address } :{ WebAggApplication .port } /' )
97
+
98
+ canvas = page .locator ('canvas.mpl-canvas' )
99
+
100
+ # Resize the canvas to be twice as big.
101
+ bbox = canvas .bounding_box ()
102
+ x , y = bbox ['x' ] + bbox ['width' ] - 1 , bbox ['y' ] + bbox ['height' ] - 1
103
+ page .mouse .move (x , y )
104
+ page .mouse .down ()
105
+ page .mouse .move (x + bbox ['width' ], y + bbox ['height' ])
106
+ page .mouse .up ()
107
+
108
+ assert fig .bbox .height == orig_bbox .height * 2
109
+ assert fig .bbox .width == orig_bbox .width * 2
110
+
111
+
86
112
@pytest .mark .backend ('webagg' )
87
113
@pytest .mark .parametrize ('toolbar' , ['toolbar2' , 'toolmanager' ])
88
114
def test_webagg_toolbar (random_port , page , toolbar ):
0 commit comments