/**
 * Test script to valid performance/responsiveness of the typing scenario
 */ import * as assert from "assert" ; import * as os from "os" ; import { Rectangle , remote } from "electron" ; import * as Oni from "oni-api" ; import { createNewFile , getCompletionElement } from "./Common" ; export const test = async ( oni ) => { await oni . automation . waitForEditors ( ) ; await createNewFile ( "test_file" , oni ) ; oni . automation . sendKeys ( "i" ) ; for ( let i = 0 ; i < 5 ; i ++ ) { await oni . automation . sleep ( 100 ) ; oni . automation . sendKeys ( "." ) ; } const gpuFeatureStatus = remote . app . getGPUFeatureStatus ( ) ; console . log ( "[PaintPerformance] gpuFeatureStatus: " + JSON . stringify ( gpuFeatureStatus ) ) ; const gpuCompositingEnabled = gpuFeatureStatus . gpu_compositing === "enabled" ; const startHeadCount = document . head . querySelectorAll ( "*" ) . length ; const startBodyCount = document . body . querySelectorAll ( "*" ) . length ; const currentWindow = remote . getCurrentWindow ( ) ; const currentWebContents = currentWindow . webContents ; const paintRectangles = [ ] ; currentWebContents . beginFrameSubscription ( true , ( buffer , dirtyRect ) => { console . log ( "[PaintPerformance] dirtyRect: " + JSON . stringify ( dirtyRect ) ) ; paintRectangles . push ( dirtyRect ) ; } ) ; for ( let i = 0 ; i < 5 ; i ++ ) { await oni . automation . sleep ( 100 ) ; oni . automation . sendKeys ( "." ) ; } await oni . automation . sleep ( 100 ) ; const endHeadCount = document . head . querySelectorAll ( "*" ) . length ; const endBodyCount = document . body . querySelectorAll ( "*" ) . length ; assert . strictEqual ( startHeadCount , endHeadCount , "There should be no items added to the head over the course of typing." ) ; assert . strictEqual ( startBodyCount , endBodyCount , "There should be no items added to the body over the course of typing." ) ; if ( os . platform ( ) !== "win32" ) { console . warn ( "Aborting remaining validations because it isn't a Windows machine." ) ; return ; } assert . ok ( paintRectangles . length >= 5 , "There should be at least 5 paint rectangles" ) ; const maxHeight = gpuCompositingEnabled ? 20 : 256 ; paintRectangles . forEach ( pr => { assert . ok ( pr . height <= maxHeight , "Validate rectangle height is less than the max height" ) ; } ) ; } ; export const settings = { configPath : "PaintPerformanceTest.config.js" , } ;