Esempio n. 1
0
 // Create a metrics service with custom configs; used for large tests.
 public MetricsService(JoinableTaskContext taskContext,
                       CredentialConfig.Factory credentialConfigFactory,
                       SdkConfig.Factory sdkConfigFactory, RandomNumberGenerator random,
                       Versions versions)
 {
     _random = random;
 }
        public virtual GgpDebugQueryTarget Create()
        {
            // Factory creation for the YetiGameletDebugger entry point.
            var taskContext = _serviceManager.GetJoinableTaskContext();

            taskContext.ThrowIfNotOnMainThread();
            var fileSystem       = new FileSystem();
            var jsonUtil         = new JsonUtil();
            var sdkConfigFactory = new SdkConfig.Factory(jsonUtil);
            var yetiVsiService   =
                (YetiVSIService)_serviceManager.GetGlobalService(typeof(YetiVSIService));
            var options                 = yetiVsiService.Options;
            var accountOptionLoader     = new VsiAccountOptionLoader(options);
            var credentialConfigFactory = new CredentialConfig.Factory(jsonUtil);
            var credentialManager       =
                new CredentialManager(credentialConfigFactory, accountOptionLoader);
            var cloudConnection = new CloudConnection();
            // NOTE: this CloudRunner is re-used for all subsequent debug sessions.
            var cloudRunner = new CloudRunner(sdkConfigFactory, credentialManager, cloudConnection,
                                              new GgpSDKUtil());
            var applicationClientFactory = GetApplicationClientFactory();
            var gameletClientFactory     = GetGameletClientFactory();
            var testAccountClientFactory = GetTestAccountClientFactory();
            var managedProcessFactory    = new ManagedProcess.Factory();
            var remoteCommand            = GetRemoteCommand(managedProcessFactory);
            var remoteFile   = new RemoteFile(managedProcessFactory);
            var remoteDeploy = new RemoteDeploy(remoteCommand, remoteFile, managedProcessFactory,
                                                fileSystem);
            var metrics               = _serviceManager.GetGlobalService(typeof(SMetrics)) as IMetrics;
            var sdkVersion            = GetSdkVersion();
            var sshManager            = GetSshManager(managedProcessFactory, cloudRunner);
            var launchParamsConverter =
                new LaunchGameParamsConverter(sdkConfigFactory, new QueryParametersParser());
            var debugSessionMetrics = new DebugSessionMetrics(metrics);
            var actionRecorder      = new ActionRecorder(debugSessionMetrics);
            var gameLaunchManager   = new GameLaunchBeHelper(gameletClientFactory.Create(cloudRunner),
                                                             launchParamsConverter);
            var vsiLaunchFactory = new VsiGameLaunchFactory(
                gameletClientFactory.Create(cloudRunner), GetCancelableTaskFactory(),
                gameLaunchManager, actionRecorder, _dialogUtil);
            var gameLauncher = new GameLauncher(gameletClientFactory.Create(cloudRunner),
                                                yetiVsiService, launchParamsConverter,
                                                GetCancelableTaskFactory(), actionRecorder,
                                                _dialogUtil, vsiLaunchFactory);
            var gameletSelectorFactory = new GameletSelectorFactory(
                _dialogUtil, cloudRunner, GetGameletSelectorWindowFactory(),
                GetCancelableTaskFactory(), gameletClientFactory, sshManager, remoteCommand,
                gameLaunchManager, taskContext);
            var serializer             = new JsonUtil();
            var launchCommandFormatter = new ChromeClientLaunchCommandFormatter(serializer);
            var paramsFactory          = new DebugEngine.DebugEngine.Params.Factory(serializer);

            return(new GgpDebugQueryTarget(fileSystem, sdkConfigFactory, gameletClientFactory,
                                           applicationClientFactory, GetCancelableTaskFactory(),
                                           _dialogUtil, remoteDeploy, debugSessionMetrics,
                                           credentialManager, testAccountClientFactory,
                                           gameletSelectorFactory, cloudRunner, sdkVersion,
                                           launchCommandFormatter, paramsFactory, yetiVsiService,
                                           gameLauncher));
        }
 // 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;
 }
 public virtual SdkConfig.Factory GetSdkConfigFactory()
 {
     if (_sdkConfigFactory == null)
     {
         _sdkConfigFactory = new SdkConfig.Factory(GetJsonUtil());
     }
     return(_sdkConfigFactory);
 }
Esempio n. 5
0
        public void SetUp()
        {
            _filesystem = new MockFileSystem();
            _filesystem.AddDirectory(SDKUtil.GetUserConfigPath());

            _jsonUtil      = new JsonUtil(_filesystem);
            _configFactory = new SdkConfig.Factory(_jsonUtil);
        }
Esempio n. 6
0
        public void SetUp()
        {
            sdkConfigFactory  = Substitute.For <SdkConfig.Factory>();
            credentialManager = Substitute.For <ICredentialManager>();
            cloudConnection   = Substitute.For <ICloudConnection>();
            funcToRun         = Substitute.For <GrpcProjectFunction>();
            // Since a channel doesn't initialize the connection until an API is called, and since
            // we don't call any APIs we can use a real channel object. Use an empty host - if
            // this behaviour changes in the future, the channel will fail to connect.
            var channel = new Channel("", ChannelCredentials.Insecure);

            cloudConnection.CreateChannel(Arg.Any <string>(), Arg.Any <string>()).Returns(channel);
            cloudRunner = new CloudRunner(sdkConfigFactory, credentialManager, cloudConnection,
                                          new GgpSDKUtil());
        }
Esempio n. 7
0
        public CoreAttachWindow(IServiceProvider serviceProvider)
        {
            var serviceManager = new ServiceManager();

            _taskContext = serviceManager.GetJoinableTaskContext();

            _dialogUtil = new DialogUtil();
            IExtensionOptions options =
                ((YetiVSIService)serviceManager.RequireGlobalService(typeof(YetiVSIService)))
                .Options;
            var managedProcessFactory = new ManagedProcess.Factory();
            var progressDialogFactory = new ProgressDialog.Factory();

            _cancelableTaskFactory =
                new CancelableTask.Factory(_taskContext, progressDialogFactory);
            _coreListRequest = new CoreListRequest.Factory().Create();
            var jsonUtil = new JsonUtil();
            var credentialConfigFactory = new CredentialConfig.Factory(jsonUtil);
            var accountOptionLoader     = new VsiAccountOptionLoader(options);
            var credentialManager       =
                new CredentialManager(credentialConfigFactory, accountOptionLoader);

            _developerAccount = credentialManager.LoadAccount();
            IRemoteCommand remoteCommand = new RemoteCommand(managedProcessFactory);

            _remoteFile = new RemoteFile(managedProcessFactory);
            var cloudConnection  = new CloudConnection();
            var sdkConfigFactory = new SdkConfig.Factory(jsonUtil);

            // NOTE: the lifetime of this CloudRunner is limited to the current CoreAttachWindow.
            _cloudRunner = new CloudRunner(sdkConfigFactory, credentialManager, cloudConnection,
                                           new GgpSDKUtil());
            _gameletClientFactory = new GameletClient.Factory();
            var sshKeyLoader        = new SshKeyLoader(managedProcessFactory);
            var sshKnownHostsWriter = new SshKnownHostsWriter();

            _sshManager = new SshManager(_gameletClientFactory, _cloudRunner, sshKeyLoader,
                                         sshKnownHostsWriter, remoteCommand);
            _debugSessionMetrics = new DebugSessionMetrics(
                serviceProvider.GetService(typeof(SMetrics)) as IMetrics);
            _debugSessionMetrics.UseNewDebugSessionId();
            _actionRecorder = new ActionRecorder(_debugSessionMetrics);

            InitializeComponent();
            _instanceSelectionWindowFactory = new ProjectInstanceSelection.Factory();
            _paramsFactory = new DebugEngine.DebugEngine.Params.Factory(jsonUtil);
            SelectInstanceOnInit();
        }
Esempio n. 8
0
        // Creates a DebugPortSupplier.  This will be invoked by Visual Studio based on this class
        // Guid being in the registry.
        public DebugPortSupplier()
        {
            // Factory creation for the PortSupplier entry point.
            var serviceManager        = new ServiceManager();
            IExtensionOptions options =
                ((YetiVSIService)serviceManager.RequireGlobalService(typeof(YetiVSIService)))
                .Options;
            var taskContext               = serviceManager.GetJoinableTaskContext();
            var debugPropertyFactory      = new DebugProperty.Factory();
            var debugProgramFactory       = new DebugProgram.Factory(debugPropertyFactory, options);
            var debugProcessFactory       = new DebugProcess.Factory(debugProgramFactory);
            var managedProcessFactory     = new ManagedProcess.Factory();
            var processListRequestFactory = new ProcessListRequest.Factory(managedProcessFactory);
            var jsonUtil                = new JsonUtil();
            var sdkConfigFactory        = new SdkConfig.Factory(jsonUtil);
            var credentialConfigFactory = new CredentialConfig.Factory(jsonUtil);
            var accountOptionLoader     = new VsiAccountOptionLoader(options);
            var credentialManager       =
                new CredentialManager(credentialConfigFactory, accountOptionLoader);

            _developerAccount = credentialManager.LoadAccount();
            _dialogUtil       = new DialogUtil();
            var progressDialogFactory = new ProgressDialog.Factory();

            _cancelableTaskFactory = new CancelableTask.Factory(taskContext, progressDialogFactory);
            var cloudConnection = new CloudConnection();

            // NOTE: this CloudRunner is re-used for all subsequent Attach to Process windows.
            _cloudRunner = new CloudRunner(sdkConfigFactory, credentialManager, cloudConnection,
                                           new GgpSDKUtil());
            var sshKeyLoader        = new SshKeyLoader(managedProcessFactory);
            var sshKnownHostsWriter = new SshKnownHostsWriter();

            _gameletClientFactory = new GameletClient.Factory();
            var sshManager =
                new SshManager(_gameletClientFactory, _cloudRunner, sshKeyLoader,
                               sshKnownHostsWriter, new RemoteCommand(managedProcessFactory));

            _metrics          = (IMetrics)serviceManager.RequireGlobalService(typeof(SMetrics));
            _debugPortFactory = new DebugPort.Factory(
                debugProcessFactory, processListRequestFactory, _cancelableTaskFactory, _dialogUtil,
                sshManager, _metrics, _developerAccount);
        }