@@ -978,7 +978,7 @@ it.effect.each(["succeeds", "fails"] as const)(
978978 } ,
979979) ;
980980
981- it . effect ( "matches Windows accessibility windows on a scaled display" , ( ) => {
981+ it . effect ( "captures and reads Windows windows in physical pixels on a scaled display" , ( ) => {
982982 const png = Buffer . from ( [ 1 , 2 , 3 ] ) ;
983983 const active = {
984984 platform : "windows" ,
@@ -987,26 +987,26 @@ it.effect("matches Windows accessibility windows on a scaled display", () => {
987987 owner : { name : "Editor" , processId : 123 } ,
988988 bounds : { x : 10 , y : 20 , width : 800 , height : 600 } ,
989989 } as const ;
990- const dipBounds = { x : 5 , y : 10 , width : 400 , height : 300 } ;
990+ const window = ( name : string , value : string ) => ( {
991+ role : "window" ,
992+ name,
993+ bounds : active . bounds ,
994+ children : async ( ) => [
995+ {
996+ role : "button" ,
997+ name : "Save" ,
998+ bounds : { x : 210 , y : 220 , width : 200 , height : 100 } ,
999+ children : async ( ) => [ ] ,
1000+ } ,
1001+ ] ,
1002+ tree : async ( ) => ( { name, value, children : [ ] } ) ,
1003+ } ) ;
9911004 activeWindowMock . mockReset ( ) . mockResolvedValue ( active ) ;
992- screenToDipRectMock . mockImplementation ( ( ) => dipBounds ) ;
1005+ screenToDipRectMock . mockImplementation ( ( ) => ( { x : 5 , y : 10 , width : 400 , height : 300 } ) ) ;
9931006 regionCaptureMock . mockReset ( ) . mockResolvedValue ( { width : 800 , height : 600 , png } ) ;
9941007 accessibilityForegroundMock . mockReset ( ) . mockResolvedValue ( {
9951008 pid : 123 ,
996- asElement : ( ) => ( {
997- role : "window" ,
998- name : "Editor" ,
999- bounds : dipBounds ,
1000- children : async ( ) => [
1001- {
1002- role : "button" ,
1003- name : "Save" ,
1004- bounds : { x : 105 , y : 110 , width : 100 , height : 50 } ,
1005- children : async ( ) => [ ] ,
1006- } ,
1007- ] ,
1008- tree : async ( ) => ( { name : "Editor" , value : "Scaled text" , children : [ ] } ) ,
1009- } ) ,
1009+ children : async ( ) => [ window ( "Settings" , "Wrong window" ) , window ( "Editor" , "Scaled text" ) ] ,
10101010 } ) ;
10111011 let metadata = "" ;
10121012 return Effect . scoped (
@@ -1015,6 +1015,7 @@ it.effect("matches Windows accessibility windows on a scaled display", () => {
10151015 yield * service . configure ( enabledSettings ( ) ) ;
10161016 yield * service . capture ;
10171017 const saved = yield * decodePendingMetadata ( metadata ) ;
1018+ assert . deepEqual ( regionCaptureMock . mock . calls [ 0 ] ?. [ 0 ] , active . bounds ) ;
10181019 assert . include ( saved . source . accessibleText , "Scaled text" ) ;
10191020 assert . deepEqual (
10201021 saved . source . accessibility ?. format === "element-tree"
@@ -1402,7 +1403,7 @@ it.each(["darwin", "win32", "linux"] as const)(
14021403 accessibilityByPidMock . mockReset ( ) . mockResolvedValue ( { children : async ( ) => [ window ] } ) ;
14031404 accessibilityForegroundMock
14041405 . mockReset ( )
1405- . mockResolvedValue ( { pid : 123 , asElement : ( ) => window } ) ;
1406+ . mockResolvedValue ( { pid : 123 , children : async ( ) => [ window ] } ) ;
14061407
14071408 const result = await readAccessibleWindowContext (
14081409 { title : "Editor" , bounds, owner : { processId : 123 } } ,
@@ -1442,7 +1443,7 @@ it.each(["darwin", "win32"] as const)(
14421443 accessibilityByPidMock . mockReset ( ) . mockResolvedValue ( { children : async ( ) => [ window ] } ) ;
14431444 accessibilityForegroundMock
14441445 . mockReset ( )
1445- . mockResolvedValue ( { pid : 123 , asElement : ( ) => window } ) ;
1446+ . mockResolvedValue ( { pid : 123 , children : async ( ) => [ window ] } ) ;
14461447 try {
14471448 assert . isUndefined (
14481449 await readAccessibleWindowText (
@@ -1484,7 +1485,7 @@ it.each([
14841485 accessibilityByPidMock . mockReset ( ) . mockResolvedValue ( { children : async ( ) => [ window ] } ) ;
14851486 accessibilityForegroundMock
14861487 . mockReset ( )
1487- . mockResolvedValue ( { pid : 123 , asElement : ( ) => window } ) ;
1488+ . mockResolvedValue ( { pid : 123 , children : async ( ) => [ window ] } ) ;
14881489 try {
14891490 const result = await readAccessibleWindowContext (
14901491 { title : "Editor" , bounds, owner : { processId : 123 } } ,
0 commit comments