-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vscode] Support TestRunRequest.preserveFocus
Add a progress service for tests to support activation of views Forward Test Run to be started event to progress service to activate view if needed fixes #13759 contributed on behalf of STMicroelectronics Signed-off-by: Remi Schnekenburger <rschnekenburger@eclipsesource.com>
- Loading branch information
1 parent
f1420d1
commit 33ea608
Showing
12 changed files
with
149 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/test/src/browser/test-execution-progress-service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 STMicroelectronics and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { inject, injectable } from '@theia/core/shared/inversify'; | ||
import { Widget } from '@theia/core/lib/browser'; | ||
import { TestResultViewContribution } from './view/test-result-view-contribution'; | ||
import { TestViewContribution } from './view/test-view-contribution'; | ||
import { TestPreferences } from './test-preferences'; | ||
|
||
export interface TestExecutionProgressService { | ||
onTestRunRequested(preserveFocus: boolean): Promise<void>; | ||
} | ||
|
||
export const TestExecutionProgressService = Symbol('TestExecutionProgressService'); | ||
|
||
@injectable() | ||
export class DefaultTestExecutionProgressService implements TestExecutionProgressService { | ||
|
||
@inject(TestResultViewContribution) | ||
protected readonly testResultView: TestResultViewContribution; | ||
|
||
@inject(TestViewContribution) | ||
protected readonly testView: TestViewContribution; | ||
|
||
@inject(TestPreferences) | ||
protected readonly testPreferences: TestPreferences; | ||
|
||
async onTestRunRequested(preserveFocus: boolean): Promise<void> { | ||
if (!preserveFocus) { | ||
const openTesting = this.testPreferences['testing.openTesting']; | ||
if (openTesting === 'openOnTestStart') { | ||
this.openTestResultView(); | ||
} | ||
} | ||
} | ||
|
||
async openTestResultView(): Promise<Widget> { | ||
return this.testResultView.openView({ activate: true }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 STMicroelectronics and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { interfaces } from '@theia/core/shared/inversify'; | ||
import { createPreferenceProxy, PreferenceProxy, PreferenceService, PreferenceContribution, PreferenceSchema } from '@theia/core/lib/browser'; | ||
import { nls } from '@theia/core/lib/common/nls'; | ||
|
||
export const TestConfigSchema: PreferenceSchema = { | ||
type: 'object', | ||
properties: { | ||
'testing.openTesting': { | ||
type: 'string', | ||
enum: ['neverOpen', 'openOnTestStart'], | ||
enumDescriptions: [ | ||
nls.localizeByDefault('Never automatically open the testing views'), | ||
nls.localizeByDefault('Open the test results view when tests start'), | ||
], | ||
description: nls.localizeByDefault('Controls when the testing view should open.'), | ||
default: 'neverOpen', | ||
scope: 'resource', | ||
} | ||
} | ||
}; | ||
|
||
export interface TestConfiguration { | ||
'testing.openTesting': 'neverOpen' | 'openOnTestStart'; | ||
} | ||
|
||
export const TestPreferenceContribution = Symbol('TestPreferenceContribution'); | ||
export const TestPreferences = Symbol('TestPreferences'); | ||
export type TestPreferences = PreferenceProxy<TestConfiguration>; | ||
|
||
export function createTestPreferences(preferences: PreferenceService, schema: PreferenceSchema = TestConfigSchema): TestPreferences { | ||
return createPreferenceProxy(preferences, schema); | ||
} | ||
|
||
export const bindTestPreferences = (bind: interfaces.Bind): void => { | ||
bind(TestPreferences).toDynamicValue(ctx => { | ||
const preferences = ctx.container.get<PreferenceService>(PreferenceService); | ||
const contribution = ctx.container.get<PreferenceContribution>(TestPreferenceContribution); | ||
return createTestPreferences(preferences, contribution.schema); | ||
}).inSingletonScope(); | ||
bind(TestPreferenceContribution).toConstantValue({ schema: TestConfigSchema }); | ||
bind(PreferenceContribution).toService(TestPreferenceContribution); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters