Пример #1
0
        public override IDebugEngineFactory CreateDebugEngineFactory()
        {
            ServiceManager serviceManager      = CreateServiceManager();
            var            joinableTaskContext = GetJoinableTaskContext();
            var            vsiService          = GetVsiService();

            joinableTaskContext.ThrowIfNotOnMainThread();

            var debugEngineCommands =
                new DebugEngineCommands(joinableTaskContext, null, false);

            var actionRecorder           = new ActionRecorder(GetDebugSessionMetrics());
            var backgroundProcessFactory = new BackgroundProcess.Factory();

            var processFactory = new ManagedProcess.Factory();
            var binaryFileUtil = new ElfFileUtil(processFactory);
            var lldbModuleUtil = new LldbModuleUtil();

            IModuleFileFinder moduleFileFinder = Substitute.For <IModuleFileFinder>();
            var moduleFileLoadRecorderFactory  =
                new ModuleFileLoadMetricsRecorder.Factory(lldbModuleUtil, moduleFileFinder);
            var grpcInterceptors = CreateGrpcInterceptors(vsiService.DebuggerOptions);
            var vsOutputWindow   =
                serviceManager.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            var callInvokerFactory      = new PipeCallInvokerFactory();
            var transportSessionFactory =
                new LldbTransportSession.Factory(new MemoryMappedFileFactory());
            var yetiTransport = new YetiDebugTransport(
                joinableTaskContext, transportSessionFactory, callInvokerFactory,
                new GrpcConnectionFactory(joinableTaskContext.Factory, grpcInterceptors.ToArray()),
                GetTaskExecutor().CancelAsyncOperationIfRequested, processFactory, _dialogUtil,
                vsOutputWindow, vsiService);

            var chromeLauncher            = new ChromeLauncher(backgroundProcessFactory);
            var testClientLauncherFactory = new ChromeClientsLauncher.Factory(
                new ChromeClientLaunchCommandFormatter(GetJsonUtil()), GetSdkConfigFactory(),
                chromeLauncher);

            var exitDialogUtil         = new ExitDialogUtil(_dialogUtil, GetDialogExecutionContext());
            var preflightBinaryChecker =
                new PreflightBinaryChecker(GetFileSystem(), binaryFileUtil);

            var paramsFactory = new YetiVSI.DebugEngine.DebugEngine.Params.Factory(GetJsonUtil());

            var  cancelableTaskFactory  = GetCancelableTaskFactory();
            bool deployLldbServer       = true;
            IDebugEngineFactory factory = new YetiVSI.DebugEngine.DebugEngine.Factory(
                joinableTaskContext, serviceManager, GetDebugSessionMetrics(), yetiTransport,
                actionRecorder, null, moduleFileLoadRecorderFactory, moduleFileFinder,
                testClientLauncherFactory, GetNatvis(), GetNatvisDiagnosticLogger(),
                exitDialogUtil, preflightBinaryChecker, _debugSessionLauncherFactory, paramsFactory,
                _remoteDeploy, cancelableTaskFactory, _dialogUtil,
                GetNatvisLoggerOutputWindowListener(), GetSolutionExplorer(), debugEngineCommands,
                GetDebugEventCallbackDecorator(vsiService.DebuggerOptions),
                GetSymbolSettingsProvider(), deployLldbServer, _gameLauncher);

            return(GetFactoryDecorator().Decorate(factory));
        }
Пример #2
0
        public void SetUp()
        {
            _targetPath = "/any/old/target/path";
            var fileSystem = new MockFileSystem();

            fileSystem.AddFile(_targetPath, new MockFileData(""));

            _outputDirectory = Path.GetTempPath();

            _project = Substitute.For <IAsyncProject>();
            _project.GetTargetPathAsync().Returns(_targetPath);
            _project.GetTargetDirectoryAsync().Returns(Path.GetDirectoryName(_targetPath));
            _project.GetTargetFileNameAsync().Returns(Path.GetFileName(_targetPath));
            _project.GetOutputDirectoryAsync().Returns(_outputDirectory);
            _project.GetAbsoluteRootPathAsync().Returns(_testProjectDir);
            _project.GetApplicationAsync().Returns(_testApplicationName);
            _project.GetQueryParamsAsync().Returns(_customQueryParams);

            var sdkConfigFactory = Substitute.For <SdkConfig.Factory>();
            var sdkConfig        = new SdkConfig();

            sdkConfig.OrganizationId = _testOrganizationId;
            sdkConfig.ProjectId      = _testProjectId;
            sdkConfigFactory.LoadOrDefault().Returns(sdkConfig);

            _gameletClient = Substitute.For <IGameletClient>();
            var gameletClientFactory = Substitute.For <GameletClient.Factory>();

            gameletClientFactory.Create(Arg.Any <ICloudRunner>()).Returns(_gameletClient);

            var remoteCommand = Substitute.For <IRemoteCommand>();

            _remoteDeploy = Substitute.For <IRemoteDeploy>();
            _dialogUtil   = Substitute.For <IDialogUtil>();

            var credentialManager = Substitute.For <YetiCommon.ICredentialManager>();

            credentialManager.LoadAccount().Returns(_testAccount);

            var cancelableTaskFactory =
                FakeCancelableTask.CreateFactory(new JoinableTaskContext(), false);

            _applicationClient = Substitute.For <IApplicationClient>();
            var application = new Application
            {
                Id = _testApplicationId, Name = _testApplicationName
            };

            _applicationClient.LoadByNameOrIdAsync(_testApplicationName)
            .Returns(Task.FromResult(application));
            var applicationClientFactory = Substitute.For <ApplicationClient.Factory>();

            applicationClientFactory.Create(Arg.Any <ICloudRunner>()).Returns(_applicationClient);

            _testAccountClientFactory = Substitute.For <TestAccountClient.Factory>();
            var testAccount = new TestAccount()
            {
                Name = $"organizations/{_testOrganizationId}" +
                       $"/projects/{_testProjectId}/testAccounts/{_testTestAccountId}"
            };
            var testAccountClient = Substitute.For <ITestAccountClient>();

            testAccountClient
            .LoadByIdOrGamerTagAsync(_testOrganizationId, _testProjectId, _testTestAccountId)
            .Returns(new List <TestAccount> {
                testAccount
            });
            _testAccountClientFactory.Create(Arg.Any <ICloudRunner>()).Returns(testAccountClient);

            Substitute.For <IExtensionOptions>();

            _yetiVsiService = Substitute.For <IYetiVSIService>();
            var options         = Substitute.For <IExtensionOptions>();
            var debuggerOptions = new YetiVSI.DebuggerOptions.DebuggerOptions();

            _yetiVsiService.DebuggerOptions.Returns(debuggerOptions);
            options.LaunchGameApiFlow.Returns(LaunchGameApiFlow.DISABLED);
            _yetiVsiService.Options.Returns(options);
            _metrics = Substitute.For <IMetrics>();
            _metrics.NewDebugSessionId().Returns(_testDebugSessionId);
            var debugMetrics = new DebugSessionMetrics(_metrics);
            var cloudRunner  = new CloudRunner(sdkConfigFactory, credentialManager,
                                               new CloudConnection(), new GgpSDKUtil());

            _gameletSelector        = Substitute.For <IGameletSelector>();
            _gameletSelectorFactory = Substitute.For <IGameletSelectorFactory>();
            _gameletSelectorFactory.Create(Arg.Any <bool>(), Arg.Any <ActionRecorder>())
            .Returns(_gameletSelector);
            var serializer = new JsonUtil();

            _launchCommandFormatter = new ChromeClientLaunchCommandFormatter(serializer);
            _paramsFactory          = new YetiVSI.DebugEngine.DebugEngine.Params.Factory(serializer);

            _gameLauncher = Substitute.For <IGameLauncher>();
            _gameLauncher.LaunchGameApiEnabled.Returns(false);
            _gameLaunch = Substitute.For <IVsiGameLaunch>();
            _gameLaunch.LaunchName.Returns("launch_name");
            _ggpDebugQueryTarget = new GgpDebugQueryTarget(fileSystem, sdkConfigFactory,
                                                           gameletClientFactory,
                                                           applicationClientFactory,
                                                           cancelableTaskFactory, _dialogUtil,
                                                           _remoteDeploy, debugMetrics,
                                                           credentialManager,
                                                           _testAccountClientFactory,
                                                           _gameletSelectorFactory, cloudRunner,
                                                           _sdkVersion, _launchCommandFormatter,
                                                           _paramsFactory, _yetiVsiService,
                                                           _gameLauncher);
        }