提交 42392190 编写于 作者: D Daniel Imms

Fix terminal config tests

上级 d03cc545
......@@ -16,10 +16,6 @@ import { TPromise } from 'vs/base/common/winjs.base';
import Severity from 'vs/base/common/severity';
import { isFedora } from 'vs/workbench/parts/terminal/electron-browser/terminal';
interface IEditorConfiguration {
editor: IEditorOptions;
}
const DEFAULT_LINE_HEIGHT = 1.0;
const MINIMUM_FONT_SIZE = 6;
......@@ -90,21 +86,19 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
* terminal.integrated.fontSize, terminal.integrated.lineHeight configuration properties
*/
public getFont(excludeDimensions?: boolean): ITerminalFont {
const config = this._configurationService.getValue();
const editorConfig = (<IEditorConfiguration>config).editor;
const terminalConfig = this.config;
const editorConfig = this._configurationService.getValue<IEditorOptions>('editor');
let fontFamily = terminalConfig.fontFamily || editorConfig.fontFamily;
let fontFamily = this.config.fontFamily || editorConfig.fontFamily;
// Work around bad font on Fedora
if (!terminalConfig.fontFamily) {
if (!this.config.fontFamily) {
if (isFedora) {
fontFamily = '\'DejaVu Sans Mono\'';
}
}
let fontSize = this._toInteger(terminalConfig.fontSize, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize);
const lineHeight = terminalConfig.lineHeight ? Math.max(terminalConfig.lineHeight, 1) : DEFAULT_LINE_HEIGHT;
let fontSize = this._toInteger(this.config.fontSize, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize);
const lineHeight = this.config.lineHeight ? Math.max(this.config.lineHeight, 1) : DEFAULT_LINE_HEIGHT;
if (excludeDimensions) {
return {
......
......@@ -11,6 +11,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { TerminalConfigHelper } from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
import { isFedora } from 'vs/workbench/parts/terminal/electron-browser/terminal';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
class MockConfigurationService implements IConfigurationService {
public _serviceBrand: any;
......@@ -33,33 +34,17 @@ suite('Workbench - TerminalConfigHelper', () => {
});
test('TerminalConfigHelper - getFont fontFamily', function () {
let configurationService: IConfigurationService;
let configHelper: TerminalConfigHelper;
configurationService = new MockConfigurationService({
editor: {
fontFamily: 'foo'
},
terminal: {
integrated: {
fontFamily: 'bar'
}
}
});
configHelper = new TerminalConfigHelper(configurationService, null, null, null);
const configurationService = new TestConfigurationService();
configurationService.setUserConfiguration('editor', { fontFamily: 'foo' });
configurationService.setUserConfiguration('terminal', { integrated: { fontFamily: 'bar' } });
let configHelper = new TerminalConfigHelper(configurationService, null, null, null);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontFamily, 'bar', 'terminal.integrated.fontFamily should be selected over editor.fontFamily');
configurationService = new MockConfigurationService({
editor: {
fontFamily: 'foo'
},
terminal: {
integrated: {
fontFamily: 0
}
}
});
configurationService.setUserConfiguration('terminal', { integrated: { fontFamily: null } });
// Recreate config helper as onDidChangeConfiguration isn't implemented in TestConfigurationService
configHelper = new TerminalConfigHelper(configurationService, null, null, null);
configHelper.panelContainer = fixture;
if (isFedora) {
......@@ -70,64 +55,55 @@ suite('Workbench - TerminalConfigHelper', () => {
});
test('TerminalConfigHelper - getFont fontSize', function () {
let configurationService: IConfigurationService;
let configHelper: TerminalConfigHelper;
configurationService = new MockConfigurationService({
editor: {
fontFamily: 'foo',
fontSize: 9
},
terminal: {
integrated: {
fontFamily: 'bar',
fontSize: 10
}
const configurationService = new TestConfigurationService();
configurationService.setUserConfiguration('editor', {
fontFamily: 'foo',
fontSize: 9
});
configurationService.setUserConfiguration('terminal', {
integrated: {
fontFamily: 'bar',
fontSize: 10
}
});
configHelper = new TerminalConfigHelper(configurationService, null, null, null);
let configHelper = new TerminalConfigHelper(configurationService, null, null, null);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontSize, 10, 'terminal.integrated.fontSize should be selected over editor.fontSize');
configurationService = new MockConfigurationService({
editor: {
fontFamily: 'foo'
},
terminal: {
integrated: {
fontFamily: 0,
fontSize: 0
}
configurationService.setUserConfiguration('editor', {
fontFamily: 'foo'
});
configurationService.setUserConfiguration('terminal', {
integrated: {
fontFamily: null,
fontSize: 0
}
});
configHelper = new TerminalConfigHelper(configurationService, null, null, null);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontSize, 6, 'The minimum terminal font size should be used when terminal.integrated.fontSize less than it');
configurationService = new MockConfigurationService({
editor: {
fontFamily: 'foo'
},
terminal: {
integrated: {
fontFamily: 0,
fontSize: 1500
}
configurationService.setUserConfiguration('editor', {
fontFamily: 'foo'
});
configurationService.setUserConfiguration('terminal', {
integrated: {
fontFamily: 0,
fontSize: 1500
}
});
configHelper = new TerminalConfigHelper(configurationService, null, null, null);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontSize, 25, 'The maximum terminal font size should be used when terminal.integrated.fontSize more than it');
configurationService = new MockConfigurationService({
editor: {
fontFamily: 'foo',
},
terminal: {
integrated: {
fontFamily: 0,
fontSize: null
}
configurationService.setUserConfiguration('editor', {
fontFamily: 'foo'
});
configurationService.setUserConfiguration('terminal', {
integrated: {
fontFamily: 0,
fontSize: null
}
});
configHelper = new TerminalConfigHelper(configurationService, null, null, null);
......@@ -136,35 +112,30 @@ suite('Workbench - TerminalConfigHelper', () => {
});
test('TerminalConfigHelper - getFont lineHeight', function () {
let configurationService: IConfigurationService;
let configHelper: TerminalConfigHelper;
configurationService = new MockConfigurationService({
editor: {
fontFamily: 'foo',
lineHeight: 1
},
terminal: {
integrated: {
fontFamily: 0,
lineHeight: 2
}
const configurationService = new TestConfigurationService();
configurationService.setUserConfiguration('editor', {
fontFamily: 'foo',
lineHeight: 1
});
configurationService.setUserConfiguration('terminal', {
integrated: {
fontFamily: 0,
lineHeight: 2
}
});
configHelper = new TerminalConfigHelper(configurationService, null, null, null);
let configHelper = new TerminalConfigHelper(configurationService, null, null, null);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().lineHeight, 2, 'terminal.integrated.lineHeight should be selected over editor.lineHeight');
configurationService = new MockConfigurationService({
editor: {
fontFamily: 'foo',
lineHeight: 1
},
terminal: {
integrated: {
fontFamily: 0,
lineHeight: 0
}
configurationService.setUserConfiguration('editor', {
fontFamily: 'foo',
lineHeight: 1
});
configurationService.setUserConfiguration('terminal', {
integrated: {
fontFamily: 0,
lineHeight: 0
}
});
configHelper = new TerminalConfigHelper(configurationService, null, null, null);
......
......@@ -21,8 +21,11 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { TPromise } from 'vs/base/common/winjs.base';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
class TestTerminalInstance extends TerminalInstance {
public _getCwd(shell: IShellLaunchConfig, root: Uri): string {
return super._getCwd(shell, root);
}
......@@ -152,6 +155,7 @@ suite('Workbench - TerminalInstance', () => {
let keybindingService = new MockKeybindingService();
let terminalFocusContextKey = contextKeyService.createKey('test', false);
instantiationService = new TestInstantiationService();
instantiationService.stub(IConfigurationService, new TestConfigurationService());
instantiationService.stub(IMessageService, new TestMessageService());
instantiationService.stub(IWorkspaceContextService, new TestContextService());
instantiationService.stub(IKeybindingService, keybindingService);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册