@@ -18,6 +18,10 @@ import { HarnessAppPathError, HarnessEmulatorConfigError } from '../errors.js';
1818const harnessConfig = {
1919 metroPort : DEFAULT_METRO_PORT ,
2020} as HarnessConfig ;
21+ const harnessConfigWithoutNativeCrashDetection = {
22+ metroPort : DEFAULT_METRO_PORT ,
23+ detectNativeCrashes : false ,
24+ } as HarnessConfig ;
2125const init = {
2226 signal : new AbortController ( ) . signal ,
2327} ;
@@ -504,7 +508,53 @@ describe('Android platform instance', () => {
504508 ) . rejects . toBeInstanceOf ( HarnessEmulatorConfigError ) ;
505509 } ) ;
506510
507- it ( 'keeps physical device behavior unchanged' , async ( ) => {
511+ it ( 'returns a noop emulator app monitor when native crash detection is disabled' , async ( ) => {
512+ vi . spyOn (
513+ await import ( '../environment.js' ) ,
514+ 'ensureAndroidEmulatorEnvironment'
515+ ) . mockResolvedValue ( '/tmp/android-sdk' ) ;
516+ vi . spyOn ( adb , 'getDeviceIds' ) . mockResolvedValue ( [ 'emulator-5554' ] ) ;
517+ vi . spyOn ( adb , 'getEmulatorName' ) . mockResolvedValue ( 'Pixel_8_API_35' ) ;
518+ vi . spyOn ( adb , 'waitForBoot' ) . mockResolvedValue ( 'emulator-5554' ) ;
519+ vi . spyOn ( adb , 'isAppInstalled' ) . mockResolvedValue ( true ) ;
520+ vi . spyOn ( adb , 'reversePort' ) . mockResolvedValue ( undefined ) ;
521+ vi . spyOn ( adb , 'setHideErrorDialogs' ) . mockResolvedValue ( undefined ) ;
522+ vi . spyOn ( adb , 'getAppUid' ) . mockResolvedValue ( 10234 ) ;
523+ vi . spyOn ( sharedPrefs , 'applyHarnessDebugHttpHost' ) . mockResolvedValue (
524+ undefined
525+ ) ;
526+
527+ const instance = await getAndroidEmulatorPlatformInstance (
528+ {
529+ name : 'android' ,
530+ device : {
531+ type : 'emulator' ,
532+ name : 'Pixel_8_API_35' ,
533+ avd : {
534+ apiLevel : 35 ,
535+ profile : 'pixel_8' ,
536+ diskSize : '1G' ,
537+ heapSize : '1G' ,
538+ } ,
539+ } ,
540+ bundleId : 'com.harnessplayground' ,
541+ activityName : '.MainActivity' ,
542+ } ,
543+ harnessConfigWithoutNativeCrashDetection ,
544+ init
545+ ) ;
546+
547+ const listener = vi . fn ( ) ;
548+ const appMonitor = instance . createAppMonitor ( ) ;
549+
550+ await expect ( appMonitor . start ( ) ) . resolves . toBeUndefined ( ) ;
551+ await expect ( appMonitor . stop ( ) ) . resolves . toBeUndefined ( ) ;
552+ await expect ( appMonitor . dispose ( ) ) . resolves . toBeUndefined ( ) ;
553+ expect ( appMonitor . addListener ( listener ) ) . toBeUndefined ( ) ;
554+ expect ( appMonitor . removeListener ( listener ) ) . toBeUndefined ( ) ;
555+ } ) ;
556+
557+ it ( 'returns a noop physical device app monitor when native crash detection is disabled' , async ( ) => {
508558 vi . spyOn ( adb , 'getDeviceIds' ) . mockResolvedValue ( [ '012345' ] ) ;
509559 vi . spyOn ( adb , 'getDeviceInfo' ) . mockResolvedValue ( {
510560 manufacturer : 'motorola' ,
@@ -530,8 +580,31 @@ describe('Android platform instance', () => {
530580 bundleId : 'com.harnessplayground' ,
531581 activityName : '.MainActivity' ,
532582 } ,
533- harnessConfig
583+ harnessConfigWithoutNativeCrashDetection
534584 )
535585 ) . resolves . toBeDefined ( ) ;
586+
587+ const instance = await getAndroidPhysicalDevicePlatformInstance (
588+ {
589+ name : 'android-device' ,
590+ device : {
591+ type : 'physical' ,
592+ manufacturer : 'motorola' ,
593+ model : 'moto g72' ,
594+ } ,
595+ bundleId : 'com.harnessplayground' ,
596+ activityName : '.MainActivity' ,
597+ } ,
598+ harnessConfigWithoutNativeCrashDetection
599+ ) ;
600+
601+ const listener = vi . fn ( ) ;
602+ const appMonitor = instance . createAppMonitor ( ) ;
603+
604+ await expect ( appMonitor . start ( ) ) . resolves . toBeUndefined ( ) ;
605+ await expect ( appMonitor . stop ( ) ) . resolves . toBeUndefined ( ) ;
606+ await expect ( appMonitor . dispose ( ) ) . resolves . toBeUndefined ( ) ;
607+ expect ( appMonitor . addListener ( listener ) ) . toBeUndefined ( ) ;
608+ expect ( appMonitor . removeListener ( listener ) ) . toBeUndefined ( ) ;
536609 } ) ;
537610} ) ;
0 commit comments