Example #1
0
        protected async Task PreLaunch(IGameLauncher launcher)
        {
            LaunchChecks();
            await HandleUserLaunchChecks(launcher).ConfigureAwait(false);

            await launcher.Notify(new PreGameLaunchEvent(this)).ConfigureAwait(false);
        }
 // 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;
 }
Example #3
0
 /// <summary>
 /// Generate light-weight version of <see cref="DebugEngineFactoryCompRoot"/>
 /// with most methods and properties mocked for testing.
 /// </summary>
 /// <param name="factory"><see cref="IDebugSessionLauncherFactory"/> instance to use
 /// instead of created one.
 /// </param>
 /// <param name="remoteDeploy"><see cref="IRemoteDeploy"/> instance to use during the
 /// deployment process.</param>
 /// <param name="gameLauncher">Game launcher.</param>
 public DebugEngineFactoryCompRootStub(IDebugSessionLauncherFactory factory,
                                       IRemoteDeploy remoteDeploy,
                                       IGameLauncher gameLauncher)
 {
     _debugSessionLauncherFactory = factory;
     _remoteDeploy = remoteDeploy;
     _gameLauncher = gameLauncher;
 }
Example #4
0
        protected async Task <int> RegisterLaunchIf(Process p, IGameLauncher launcher)
        {
            if (p == null)
            {
                return(-1);
            }

            var id = p.Id;

            // TODO: better not to hold on to the process because of info going out of date / Id can't be called when the process is killed etc?
            RegisterRunning(p);
            await launcher.Notify(new GameLaunchedEvent(Running, CalculatedSettings.Server)).ConfigureAwait(false);

            return(id);
        }
Example #5
0
        async Task HandleUserLaunchChecks(IGameLauncher launcher)
        {
            if (Common.Flags.IgnoreErrorDialogs)
            {
                return;
            }

            var preLaunchCancellable = new PreGameLaunchCancelleableEvent(this,
                                                                          CalculatedSettings.Collection, CalculatedSettings.Mission, CalculatedSettings.Server);
            await launcher.Notify(preLaunchCancellable).ConfigureAwait(false);

            if (preLaunchCancellable.Cancel)
            {
                throw new OperationCanceledException("User Cancelled PreLaunch Checks");
            }

            if (Common.AppCommon.IsBusy)
            {
                throw new BusyStateHandler.BusyException();
            }
        }
Example #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);
        }