public void SetUp()
        {
            taskContext = new JoinableTaskContext();
            mockMemoryMappedFileFactory = Substitute.For <MemoryMappedFileFactory>();
            transportSessionFactory     = new LldbTransportSession.Factory(mockMemoryMappedFileFactory);
            mockManagedProcessFactory   = Substitute.For <ManagedProcess.Factory>();
            mockGrpcCallInvoker         = Substitute.ForPartsOf <PipeCallInvoker>(_numGrpcPipePairs);
            mockGrpcCallInvokerFactory  = Substitute.For <PipeCallInvokerFactory>();
            mockGrpcCallInvokerFactory.Create().Returns(mockGrpcCallInvoker);
            mockGrpcConnectionFactory = Substitute.For <GrpcConnectionFactory>();
            optionPageGrid            = Substitute.For <IExtensionOptions>();
            service = new YetiVSIService(optionPageGrid);
            var mockVsOutputWindow = Substitute.For <IVsOutputWindow>();

            mockDialogUtil     = Substitute.For <IDialogUtil>();
            yetiDebugTransport = new YetiDebugTransport(taskContext, transportSessionFactory,
                                                        mockGrpcCallInvokerFactory,
                                                        mockGrpcConnectionFactory,
                                                        onAsyncRpcCompleted: null,
                                                        managedProcessFactory:
                                                        mockManagedProcessFactory,
                                                        dialogUtil: mockDialogUtil,
                                                        vsOutputWindow: mockVsOutputWindow,
                                                        yetiVSIService: service);

            abortError = null;
            yetiDebugTransport.OnStop += e => { abortError = e; };
        }
Ejemplo n.º 2
0
 // Constructor for tests.
 public GgpDebugQueryTarget(IFileSystem fileSystem, SdkConfig.Factory sdkConfigFactory,
                            IGameletClientFactory gameletClientFactory,
                            IApplicationClientFactory applicationClientFactory,
                            CancelableTask.Factory cancelableTaskFactory,
                            IDialogUtil dialogUtil, IRemoteDeploy remoteDeploy,
                            DebugSessionMetrics metrics,
                            ICredentialManager credentialManager,
                            ITestAccountClientFactory testAccountClientFactory,
                            IGameletSelectorFactory gameletSelectorFactory,
                            ICloudRunner cloudRunner, Versions.SdkVersion sdkVersion,
                            ChromeClientLaunchCommandFormatter launchCommandFormatter,
                            DebugEngine.DebugEngine.Params.Factory paramsFactory,
                            IYetiVSIService yetiVsiService, IGameLauncher gameLauncher)
 {
     _fileSystem               = fileSystem;
     _sdkConfigFactory         = sdkConfigFactory;
     _gameletClientFactory     = gameletClientFactory;
     _applicationClientFactory = applicationClientFactory;
     _cancelableTaskFactory    = cancelableTaskFactory;
     _dialogUtil               = dialogUtil;
     _remoteDeploy             = remoteDeploy;
     _metrics                  = metrics;
     _credentialManager        = credentialManager;
     _testAccountClientFactory = testAccountClientFactory;
     _cloudRunner              = cloudRunner;
     _yetiVsiService           = yetiVsiService;
     _gameletSelectorFactory   = gameletSelectorFactory;
     _sdkVersion               = sdkVersion;
     _launchCommandFormatter   = launchCommandFormatter;
     _paramsFactory            = paramsFactory;
     _gameLauncher             = gameLauncher;
 }
Ejemplo n.º 3
0
 public GameLauncher(IGameletClient gameletClient, IYetiVSIService vsiService,
                     ILaunchGameParamsConverter launchGameParamsConverter,
                     CancelableTask.Factory cancelableTaskFactory,
                     ActionRecorder actionRecorder, IDialogUtil dialogUtil,
                     IVsiGameLaunchFactory vsiLaunchFactory)
 {
     _gameletClient             = gameletClient;
     _vsiService                = vsiService;
     _cancelableTaskFactory     = cancelableTaskFactory;
     _actionRecorder            = actionRecorder;
     _launchGameParamsConverter = launchGameParamsConverter;
     _dialogUtil                = dialogUtil;
     _vsiLaunchFactory          = vsiLaunchFactory;
 }
Ejemplo n.º 4
0
        public YetiDebugTransport(JoinableTaskContext taskContext,
                                  LldbTransportSession.Factory transportSessionFactory,
                                  PipeCallInvokerFactory grpcCallInvokerFactory,
                                  GrpcConnectionFactory grpcConnectionFactory,
                                  Action onAsyncRpcCompleted,
                                  ManagedProcess.Factory managedProcessFactory,
                                  IDialogUtil dialogUtil, IVsOutputWindow vsOutputWindow,
                                  IYetiVSIService yetiVSIService)
        {
            taskContext.ThrowIfNotOnMainThread();

            this.taskContext             = taskContext;
            this.grpcCallInvokerFactory  = grpcCallInvokerFactory;
            this.grpcConnectionFactory   = grpcConnectionFactory;
            this.onAsyncRpcCompleted     = onAsyncRpcCompleted;
            this.managedProcessFactory   = managedProcessFactory;
            this.transportSessionFactory = transportSessionFactory;
            this.dialogUtil = dialogUtil;

            Guid debugPaneGuid = VSConstants.GUID_OutWindowDebugPane;

            vsOutputWindow?.GetPane(ref debugPaneGuid, out debugPane);
            this.yetiVSIService = yetiVSIService;
        }
Ejemplo n.º 5
0
        public void Setup()
        {
            _cancelable            = Substitute.For <ICancelableTask>();
            _action                = Substitute.For <IAction>();
            _gameletClient         = Substitute.For <IGameletClient>();
            _paramsConverter       = Substitute.For <ILaunchGameParamsConverter>();
            _cancelableTaskFactory = Substitute.For <CancelableTask.Factory>();
            _yetiVsiService        = Substitute.For <IYetiVSIService>();
            _metrics               = Substitute.For <IMetrics>();
            _actionRecorder        = Substitute.For <ActionRecorder>(_metrics);
            _devEvent              = SetupCreateLaunchEvent();
            _dialogUtil            = Substitute.For <IDialogUtil>();
            _vsiGameLaunchFactory  = Substitute.For <IVsiGameLaunchFactory>();
            _vsiGameLaunch         = Substitute.For <IVsiGameLaunch>();
            _vsiGameLaunchFactory.Create(_gameLaunchName, Arg.Any <bool>()).Returns(_vsiGameLaunch);
            _vsiGameLaunch.LaunchName.Returns(_gameLaunchName);
            _vsiGameLaunch.LaunchId.Returns(_gameLaunchId);

            _target = new GameLauncher(_gameletClient, _yetiVsiService, _paramsConverter,
                                       _cancelableTaskFactory, _actionRecorder, _dialogUtil,
                                       _vsiGameLaunchFactory);

            SetupCancelableTask();
        }
Ejemplo n.º 6
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);
        }