File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,4 +56,38 @@ describe("withTestRenderer", () => {
5656 expect ( ctrlC . ctrl ) . toBe ( true ) ;
5757 } ) ;
5858 } ) ;
59+
60+ test ( "surfaces native stats and advances nativeFrameCount across renderOnce" , async ( ) => {
61+ await withTestRenderer (
62+ async ( h ) => {
63+ expect ( typeof h . waitForVisualIdle ) . toBe ( "function" ) ;
64+ expect ( typeof h . externalOutput . take ) . toBe ( "function" ) ;
65+ expect ( h . externalOutput . take ( ) ) . toEqual ( [ ] ) ;
66+
67+ const before = h . getNativeStats ( ) ;
68+ expect ( typeof before . nativeLastFrameTime ) . toBe ( "number" ) ;
69+ expect ( typeof before . nativeAverageFrameTime ) . toBe ( "number" ) ;
70+ expect ( typeof before . cellsUpdated ) . toBe ( "number" ) ;
71+ expect ( typeof before . averageCellsUpdated ) . toBe ( "number" ) ;
72+
73+ const box = new BoxRenderable ( h . renderer , {
74+ id : "stats" ,
75+ width : "100%" ,
76+ height : "100%" ,
77+ } ) ;
78+ box . add (
79+ new TextRenderable ( h . renderer , {
80+ content : "native-stats" ,
81+ } ) ,
82+ ) ;
83+ h . root . add ( box ) ;
84+
85+ await h . renderOnce ( ) ;
86+ const after = h . getNativeStats ( ) ;
87+ expect ( after . nativeFrameCount ) . toBeGreaterThan ( before . nativeFrameCount ) ;
88+ await h . waitForVisualIdle ( ) ;
89+ } ,
90+ { width : 40 , height : 10 } ,
91+ ) ;
92+ } ) ;
5993} ) ;
Original file line number Diff line number Diff line change @@ -119,6 +119,10 @@ export interface Harness {
119119 readonly flush : TestRendererSetup [ "flush" ] ;
120120 readonly waitFor : TestRendererSetup [ "waitFor" ] ;
121121 readonly waitForFrame : TestRendererSetup [ "waitForFrame" ] ;
122+ readonly waitForVisualIdle : TestRendererSetup [ "waitForVisualIdle" ] ;
123+ /** Recorded external stdout commits from the test renderer. */
124+ readonly externalOutput : TestRendererSetup [ "externalOutput" ] ;
125+ readonly getNativeStats : TestRendererSetup [ "getNativeStats" ] ;
122126 readonly captureCharFrame : ( ) => string ;
123127 readonly captureSpans : TestRendererSetup [ "captureSpans" ] ;
124128 readonly resize : ( width : number , height : number ) => void ;
@@ -196,6 +200,9 @@ export async function createHarness(
196200 flush : setup . flush ,
197201 waitFor : setup . waitFor ,
198202 waitForFrame : setup . waitForFrame ,
203+ waitForVisualIdle : setup . waitForVisualIdle ,
204+ externalOutput : setup . externalOutput ,
205+ getNativeStats : setup . getNativeStats ,
199206 captureCharFrame : setup . captureCharFrame ,
200207 captureSpans : setup . captureSpans ,
201208 resize : setup . resize ,
You can’t perform that action at this time.
0 commit comments