// GetEmulatorMock returns a properly stubbed emulator instance.
// Due to extensive use of globals -- one mock instance is allowed per a test run.
// Don't forget to init one image channel consumer, it will lock-out otherwise.
// Make sure you call shutdownEmulator().
GetEmulatorMock returns a properly stubbed emulator instance.
Due to extensive use of globals -- one mock instance is allowed per a test run.
Don't forget to init one image channel consumer, it will lock-out otherwise.
Make sure you call shutdownEmulator().
// GetEmulatorMock returns a properly stubbed emulator instance . // Due to extensive use of globals -- one mock instance is allowed per a test run . // Don ' t forget to init one image channel consumer it will lock - out otherwise . // Make sure you call shutdownEmulator () .
func GetEmulatorMock(room string, system string) *EmulatorMock {
	rootPath := getRootPath()
	configPath := rootPath + "configs/"
	var conf worker.Config
	if err := config.LoadConfig(&conf, configPath); err != nil {
		panic(err)
	}
	meta := conf.Emulator.GetLibretroCoreConfig(system)
	images := make(chan GameFrame, 30)
	audio := make(chan []int16, 30)
	inputs := make(chan InputEvent, 100)
	store := Storage{
		Path:     os.TempDir(),
		MainSave: room + ".dat",
	}
	emu := &EmulatorMock{
		naEmulator: naEmulator{
			imageChannel: images,
			audioChannel: audio,
			inputChannel: inputs,
			storage:      store,
			meta: emulator.Metadata{
				LibPath:     meta.Lib,
				ConfigPath:  meta.Config,
				Ratio:       meta.Ratio,
				IsGlAllowed: meta.IsGlAllowed,
				UsesLibCo:   meta.UsesLibCo,
				HasMultitap: meta.HasMultitap,
			},
			players: NewPlayerSessionInput(),
			roomID:  room,
			done:    make(chan struct{}, 1),
		},
		canvas: image.NewRGBA(image.Rect(0, 0, meta.Width, meta.Height)),
		core:   path.Base(meta.Lib),
		paths: EmulatorPaths{
			assets: cleanPath(rootPath),
			cores:  cleanPath(rootPath + "assets/cores/"),
			games:  cleanPath(rootPath + "assets/games/"),
		},
		imageInCh:  images,
		audioInCh:  audio,
		inputOutCh: inputs,
	}
	NAEmulator = &emu.naEmulator
	outputImg = emu.canvas
	emu.paths.save = cleanPath(emu.GetHashPath())
	return emu
}
func GetEmulatorMock ( room string , system string ) * EmulatorMock { rootPath := getRootPath ( ) configPath := rootPath + " " var conf worker . Config if err := config . LoadConfig ( & conf , configPath ) ; err != nil { panic ( err ) } meta := conf . Emulator . GetLibretroCoreConfig ( system ) images := make ( chan GameFrame , 30 ) audio := make ( chan [ ] int16 , 30 ) inputs := make ( chan InputEvent , 100 ) store := Storage { Path : os . TempDir ( ) , MainSave : room + " " , } emu := & EmulatorMock { naEmulator : naEmulator { imageChannel : images , audioChannel : audio , inputChannel : inputs , storage : store , meta : emulator . Metadata { LibPath : meta . Lib , ConfigPath : meta . Config , Ratio : meta . Ratio , IsGlAllowed : meta . IsGlAllowed , UsesLibCo : meta . UsesLibCo , HasMultitap : meta . HasMultitap , } , players : NewPlayerSessionInput ( ) , roomID : room , done : make ( chan struct { } , 1 ) , } , canvas : image . NewRGBA ( image . Rect ( 0 , 0 , meta . Width , meta . Height ) ) , core : path . Base ( meta . Lib ) , paths : EmulatorPaths { assets : cleanPath ( rootPath ) , cores : cleanPath ( rootPath + " " ) , games : cleanPath ( rootPath + " " ) , } , imageInCh : images , audioInCh : audio , inputOutCh : inputs , } NAEmulator = & emu . naEmulator outputImg = emu . canvas emu . paths . save = cleanPath ( emu . GetHashPath ( ) ) return emu }
GetEmulatorMock returns a properly stubbed emulator instance.
GetEmulatorMock returns a properly stubbed emulator instance .
// an emu // stub globals