From d6b99429ddaac71cb23c5e9921374a33f49e0bd9 Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Fri, 11 Nov 2016 08:21:50 -0800 Subject: [PATCH] Ensure telemetry service is available in affected tests (#15321) --- src/vs/test/utils/servicesTestUtils.ts | 1 + src/vs/workbench/common/editor/editorStacksModel.ts | 8 ++------ .../test/browser/editorStacksModel.test.ts | 13 +++++++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/vs/test/utils/servicesTestUtils.ts b/src/vs/test/utils/servicesTestUtils.ts index 688ff9a4f96..8ea86ac5247 100644 --- a/src/vs/test/utils/servicesTestUtils.ts +++ b/src/vs/test/utils/servicesTestUtils.ts @@ -354,6 +354,7 @@ export class TestEditorGroupService implements IEditorGroupService { services.set(IWorkspaceContextService, new TestContextService()); const lifecycle = new TestLifecycleService(); services.set(ILifecycleService, lifecycle); + services.set(ITelemetryService, NullTelemetryService); let inst = new InstantiationService(services); diff --git a/src/vs/workbench/common/editor/editorStacksModel.ts b/src/vs/workbench/common/editor/editorStacksModel.ts index 91f6ff99986..85f67228449 100644 --- a/src/vs/workbench/common/editor/editorStacksModel.ts +++ b/src/vs/workbench/common/editor/editorStacksModel.ts @@ -1122,9 +1122,7 @@ export class EditorStacksModel implements IEditorStacksModel { } private handleOnEditorOpened(editor: EditorInput): void { - if (this.telemetryService) { - this.telemetryService.publicLog('editorOpened', editor.getTelemetryDescriptor()); - } + this.telemetryService.publicLog('editorOpened', editor.getTelemetryDescriptor()); } private handleOnEditorClosed(event: GroupEvent): void { @@ -1144,9 +1142,7 @@ export class EditorStacksModel implements IEditorStacksModel { } } - if (this.telemetryService) { - this.telemetryService.publicLog('editorClosed', editor.getTelemetryDescriptor()); - } + this.telemetryService.publicLog('editorClosed', editor.getTelemetryDescriptor()); } public isOpen(resource: URI): boolean; diff --git a/src/vs/workbench/test/browser/editorStacksModel.test.ts b/src/vs/workbench/test/browser/editorStacksModel.test.ts index a55d91e090c..7e5a616daeb 100644 --- a/src/vs/workbench/test/browser/editorStacksModel.test.ts +++ b/src/vs/workbench/test/browser/editorStacksModel.test.ts @@ -19,6 +19,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace import { Registry } from 'vs/platform/platform'; import { Position, Direction } from 'vs/platform/editor/common/editor'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { ITelemetryService, NullTelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import 'vs/workbench/browser/parts/editor/baseEditor'; @@ -27,6 +28,7 @@ function create(): EditorStacksModel { inst.stub(IStorageService, new TestStorageService()); inst.stub(ILifecycleService, new TestLifecycleService()); inst.stub(IWorkspaceContextService, new TestContextService()); + inst.stub(ITelemetryService, NullTelemetryService); const config = new TestConfigurationService(); config.setUserConfiguration('workbench', { editor: { openPositioning: 'right' } }); @@ -641,6 +643,7 @@ suite('Editor Stacks Model', () => { inst.stub(IStorageService, new TestStorageService()); inst.stub(ILifecycleService, new TestLifecycleService()); inst.stub(IWorkspaceContextService, new TestContextService()); + inst.stub(ITelemetryService, NullTelemetryService); const config = new TestConfigurationService(); inst.stub(IConfigurationService, config); @@ -1175,6 +1178,8 @@ suite('Editor Stacks Model', () => { inst.stub(IWorkspaceContextService, new TestContextService()); const lifecycle = new TestLifecycleService(); inst.stub(ILifecycleService, lifecycle); + inst.stub(ITelemetryService, NullTelemetryService); + const config = new TestConfigurationService(); config.setUserConfiguration('workbench', { editor: { openPositioning: 'right' } }); inst.stub(IConfigurationService, config); @@ -1217,6 +1222,8 @@ suite('Editor Stacks Model', () => { inst.stub(IWorkspaceContextService, new TestContextService()); const lifecycle = new TestLifecycleService(); inst.stub(ILifecycleService, lifecycle); + inst.stub(ITelemetryService, NullTelemetryService); + const config = new TestConfigurationService(); config.setUserConfiguration('workbench', { editor: { openPositioning: 'right' } }); inst.stub(IConfigurationService, config); @@ -1298,6 +1305,8 @@ suite('Editor Stacks Model', () => { inst.stub(IWorkspaceContextService, new TestContextService()); const lifecycle = new TestLifecycleService(); inst.stub(ILifecycleService, lifecycle); + inst.stub(ITelemetryService, NullTelemetryService); + const config = new TestConfigurationService(); config.setUserConfiguration('workbench', { editor: { openPositioning: 'right' } }); inst.stub(IConfigurationService, config); @@ -1347,6 +1356,8 @@ suite('Editor Stacks Model', () => { inst.stub(IWorkspaceContextService, new TestContextService()); const lifecycle = new TestLifecycleService(); inst.stub(ILifecycleService, lifecycle); + inst.stub(ITelemetryService, NullTelemetryService); + const config = new TestConfigurationService(); config.setUserConfiguration('workbench', { editor: { openPositioning: 'right' } }); inst.stub(IConfigurationService, config); @@ -1387,6 +1398,8 @@ suite('Editor Stacks Model', () => { inst.stub(IStorageService, new TestStorageService()); const lifecycle = new TestLifecycleService(); inst.stub(ILifecycleService, lifecycle); + inst.stub(ITelemetryService, NullTelemetryService); + const config = new TestConfigurationService(); config.setUserConfiguration('workbench', { editor: { openPositioning: 'right' } }); inst.stub(IConfigurationService, config); -- GitLab