@@ -582,6 +582,96 @@ test('openAndroidApp ensures Android reverse before localhost deep link launch',
582582 ] ) ;
583583} ) ;
584584
585+ test ( 'openAndroidApp ensures Android reverse before IPv6 localhost deep link launch' , async ( ) => {
586+ const device : DeviceInfo = {
587+ platform : 'android' ,
588+ id : 'emulator-5554' ,
589+ name : 'Pixel' ,
590+ kind : 'emulator' ,
591+ booted : true ,
592+ } ;
593+ const calls : Array <
594+ { kind : 'exec' ; args : string [ ] } | { kind : 'reverse' ; local : string ; remote : string }
595+ > = [ ] ;
596+
597+ await withAndroidAdbProvider (
598+ {
599+ exec : async ( args ) => {
600+ calls . push ( { kind : 'exec' , args } ) ;
601+ return { stdout : '' , stderr : '' , exitCode : 0 } ;
602+ } ,
603+ reverse : {
604+ ensure : async ( mapping ) => {
605+ calls . push ( { kind : 'reverse' , local : mapping . local , remote : mapping . remote } ) ;
606+ } ,
607+ remove : async ( ) => { } ,
608+ removeAllOwned : async ( ) => { } ,
609+ } ,
610+ } ,
611+ { serial : 'emulator-5554' } ,
612+ async ( ) => await openAndroidApp ( device , 'http://[::1]:8081/status' ) ,
613+ ) ;
614+
615+ assert . deepEqual ( calls , [
616+ { kind : 'reverse' , local : 'tcp:8081' , remote : 'tcp:8081' } ,
617+ {
618+ kind : 'exec' ,
619+ args : [
620+ 'shell' ,
621+ 'am' ,
622+ 'start' ,
623+ '-W' ,
624+ '-a' ,
625+ 'android.intent.action.VIEW' ,
626+ '-d' ,
627+ 'http://[::1]:8081/status' ,
628+ ] ,
629+ } ,
630+ ] ) ;
631+ } ) ;
632+
633+ test ( 'openAndroidApp leaves localhost deep links without a port unchanged' , async ( ) => {
634+ const device : DeviceInfo = {
635+ platform : 'android' ,
636+ id : 'emulator-5554' ,
637+ name : 'Pixel' ,
638+ kind : 'emulator' ,
639+ booted : true ,
640+ } ;
641+ const calls : string [ ] [ ] = [ ] ;
642+
643+ await withAndroidAdbProvider (
644+ {
645+ exec : async ( args ) => {
646+ calls . push ( args ) ;
647+ return { stdout : '' , stderr : '' , exitCode : 0 } ;
648+ } ,
649+ reverse : {
650+ ensure : async ( ) => {
651+ throw new Error ( 'reverse should not run without a URL port' ) ;
652+ } ,
653+ remove : async ( ) => { } ,
654+ removeAllOwned : async ( ) => { } ,
655+ } ,
656+ } ,
657+ { serial : 'emulator-5554' } ,
658+ async ( ) => await openAndroidApp ( device , 'http://localhost/path' ) ,
659+ ) ;
660+
661+ assert . deepEqual ( calls , [
662+ [
663+ 'shell' ,
664+ 'am' ,
665+ 'start' ,
666+ '-W' ,
667+ '-a' ,
668+ 'android.intent.action.VIEW' ,
669+ '-d' ,
670+ 'http://localhost/path' ,
671+ ] ,
672+ ] ) ;
673+ } ) ;
674+
585675test ( 'openAndroidApp leaves non-localhost deep links unchanged' , async ( ) => {
586676 const device : DeviceInfo = {
587677 platform : 'android' ,
0 commit comments