@@ -50,11 +50,13 @@ test.skipIf(process.platform === 'win32')(
5050 fs . writeFileSync (
5151 adbPath ,
5252 '#!/usr/bin/env node\n' +
53- 'process.stdout.write(JSON.stringify({args: process.argv.slice(2), port: process.env.ANDROID_ADB_SERVER_PORT ?? null, address: process.env.ANDROID_ADB_SERVER_ADDRESS ?? null}));\n' ,
53+ 'process.stdout.write(JSON.stringify({args: process.argv.slice(2), port: process.env.ANDROID_ADB_SERVER_PORT ?? null, address: process.env.ANDROID_ADB_SERVER_ADDRESS ?? null, socket: process.env.ADB_SERVER_SOCKET ?? null }));\n' ,
5454 ) ;
5555 fs . chmodSync ( adbPath , 0o755 ) ;
5656 const previousPath = process . env . PATH ;
5757 const previousPort = process . env . ANDROID_ADB_SERVER_PORT ;
58+ const previousSocket = process . env . ADB_SERVER_SOCKET ;
59+ process . env . ADB_SERVER_SOCKET = 'tcp:inherited.example:9999' ;
5860 process . env . PATH = `${ tmpDir } ${ path . delimiter } ${ previousPath ?? '' } ` ;
5961 try {
6062 const provider = createLocalAndroidAdbProvider (
@@ -101,6 +103,17 @@ test.skipIf(process.platform === 'win32')(
101103 [ 'nodaemon' , '-H' , 'foreign.example' ] ,
102104 [ 'server' , '-P' , '9999' ] ,
103105 [ 'fork-server' , '-s' , 'foreign-device' ] ,
106+ [ 'kill-server' ] ,
107+ [ 'start-server' ] ,
108+ [ 'connect' , 'foreign.example' ] ,
109+ [ 'disconnect' ] ,
110+ [ 'reconnect' , 'offline' ] ,
111+ [ 'attach' , 'foreign-device' ] ,
112+ [ 'detach' , 'foreign-device' ] ,
113+ [ 'pair' , 'foreign.example' , '123456' ] ,
114+ [ 'wait-for-device' , 'kill-server' ] ,
115+ [ 'wait-for-device' , 'disconnect' ] ,
116+ [ 'wait-for-any-device' , 'pair' , 'foreign.example' , '123456' ] ,
104117 ] ) {
105118 await assert . rejects ( adb ( [ ...selector , 'shell' , 'id' ] ) , {
106119 details : { reason : 'managed-device-transport-mismatch' } ,
@@ -114,16 +127,26 @@ test.skipIf(process.platform === 'win32')(
114127 args : [ '-P' , '15037' , '-s' , 'emulator-5554' , 'shell' , 'id' ] ,
115128 port : '15037' ,
116129 address : '127.0.0.1' ,
130+ socket : null ,
117131 } ) ;
118132 assert . deepEqual ( serialWithWrongPort , serial ) ;
119133 assert . deepEqual ( serialWithWrongEnvironment , serial ) ;
134+ const waited = JSON . parse ( ( await adb ( [ 'wait-for-device' , 'shell' , 'id' ] ) ) . stdout ) ;
135+ assert . deepEqual ( waited , {
136+ ...serial ,
137+ args : [ '-P' , '15037' , '-s' , 'emulator-5554' , 'wait-for-device' , 'shell' , 'id' ] ,
138+ } ) ;
120139 assert . deepEqual ( host , {
121140 args : [ '-P' , '15038' , 'devices' ] ,
122141 port : '15038' ,
123142 address : '127.0.0.1' ,
143+ socket : null ,
124144 } ) ;
125145 assert . equal ( process . env . ANDROID_ADB_SERVER_PORT , previousPort ) ;
146+ assert . equal ( process . env . ADB_SERVER_SOCKET , 'tcp:inherited.example:9999' ) ;
126147 } finally {
148+ if ( previousSocket === undefined ) delete process . env . ADB_SERVER_SOCKET ;
149+ else process . env . ADB_SERVER_SOCKET = previousSocket ;
127150 if ( previousPath === undefined ) delete process . env . PATH ;
128151 else process . env . PATH = previousPath ;
129152 }
0 commit comments