@@ -17,8 +17,7 @@ const scope: PlatformRequestScope = {
1717const RUNNING_EMULATOR_PROBES : ReadonlyArray < readonly [ string , string ] > = [
1818 [ 'ro.boot.qemu.avd_name' , 'Pixel_9_Pro_XL\n' ] ,
1919 [ 'sys.boot_completed' , '1\n' ] ,
20- [ 'ro.product.model' , 'sdk_gphone16k_arm64\n' ] ,
21- [ 'ro.build.version.release' , '17\n' ] ,
20+ [ 'ro.product.model' , 'sdk_gphone16k_arm64\n17\n' ] ,
2221 [ 'ro.build.characteristics' , 'phone\n' ] ,
2322 [ 'has-feature' , 'false\n' ] ,
2423 [ 'pm\0list\0features' , '' ] ,
@@ -70,30 +69,39 @@ test.each([
7069 } ,
7170) ;
7271
73- test ( 'Android inventory leaves model and OS version unset when the getprop probe fails' , async ( ) => {
74- const host = createHost ( async ( request ) => {
75- const key = request . args . join ( '\0' ) ;
76- if ( key === 'devices\0-l' )
77- return result ( 'List of devices attached\nR5CT1 device model:SM_S921B\n' ) ;
78- if ( key . includes ( 'ro.product.model' ) || key . includes ( 'ro.build.version.release' ) ) {
79- return result ( '' , 'error: closed' , 1 ) ;
80- }
81- if ( key . includes ( 'sys.boot_completed' ) ) return result ( '1\n' ) ;
82- if ( key . includes ( 'ro.build.characteristics' ) ) return result ( 'phone\n' ) ;
83- if ( key . includes ( 'has-feature' ) ) return result ( 'false\n' ) ;
84- if ( key . includes ( 'pm\0list\0features' ) ) return result ( '' ) ;
85- throw new Error ( `Unexpected command: ${ request . executable } ${ request . args . join ( ' ' ) } ` ) ;
86- } ) ;
72+ test . each ( [
73+ [ 'exits non-zero' , async ( ) => result ( '' , 'error: closed' , 1 ) ] ,
74+ [
75+ 'times out' ,
76+ async ( ) => {
77+ throw new AppError ( 'COMMAND_FAILED' , 'adb timed out after 10000ms' , { timeoutMs : 10_000 } ) ;
78+ } ,
79+ ] ,
80+ ] as const ) (
81+ 'Android inventory leaves model and OS version unset when the description probe %s' ,
82+ async ( _case , describeProbe ) => {
83+ const host = createHost ( async ( request ) => {
84+ const key = request . args . join ( '\0' ) ;
85+ if ( key === 'devices\0-l' ) {
86+ return result ( 'List of devices attached\nR5CT1 device model:SM_S921B\n' ) ;
87+ }
88+ if ( key . includes ( 'ro.product.model' ) ) return await describeProbe ( ) ;
89+ const probe = RUNNING_EMULATOR_PROBES . find ( ( [ fragment ] ) => key . includes ( fragment ) ) ;
90+ if ( probe ) return result ( probe [ 1 ] ) ;
91+ throw new Error ( `Unexpected command: ${ request . executable } ${ request . args . join ( ' ' ) } ` ) ;
92+ } ) ;
8793
88- const [ device ] = await createAndroidInventory ( host ) . discover (
89- { androidAvdSelection : 'running-only' } ,
90- scope ,
91- ) ;
94+ const [ device ] = await createAndroidInventory ( host ) . discover (
95+ { androidAvdSelection : 'running-only' } ,
96+ scope ,
97+ ) ;
9298
93- assert . equal ( device ?. name , 'SM S921B' ) ;
94- assert . equal ( device ?. model , undefined ) ;
95- assert . equal ( device ?. osVersion , undefined ) ;
96- } ) ;
99+ assert . equal ( device ?. name , 'SM S921B' ) ;
100+ assert . equal ( device ?. booted , true ) ;
101+ assert . equal ( device ?. model , undefined ) ;
102+ assert . equal ( device ?. osVersion , undefined ) ;
103+ } ,
104+ ) ;
97105
98106test ( 'Android inventory fails closed when adb is unavailable' , async ( ) => {
99107 const host = createHost ( async ( ) => result ( '' ) , { adb : undefined } ) ;
0 commit comments