diff --git a/src/vs/editor/contrib/bracketMatching/test/bracketMatching.test.ts b/src/vs/editor/contrib/bracketMatching/test/bracketMatching.test.ts index e17f3025abdf13a0d6756a46dbb84a2099708151..58cb2281fff20600ca483a693cd1856bd41007aa 100644 --- a/src/vs/editor/contrib/bracketMatching/test/bracketMatching.test.ts +++ b/src/vs/editor/contrib/bracketMatching/test/bracketMatching.test.ts @@ -5,7 +5,7 @@ 'use strict'; import * as assert from 'assert'; -import { withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { Position } from 'vs/editor/common/core/position'; import { Model } from 'vs/editor/common/model/model'; import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry'; @@ -34,7 +34,7 @@ suite('bracket matching', () => { let mode = new BracketMode(); let model = Model.createFromString('var x = (3 + (5-7)) + ((5+3)+5);', undefined, mode.getLanguageIdentifier()); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { let bracketMatchingController = editor.registerAndInstantiateContribution(BracketMatchingController); // start on closing bracket @@ -66,7 +66,7 @@ suite('bracket matching', () => { let mode = new BracketMode(); let model = Model.createFromString('var x = (3 + (5-7)); y();', undefined, mode.getLanguageIdentifier()); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { let bracketMatchingController = editor.registerAndInstantiateContribution(BracketMatchingController); // start position between brackets diff --git a/src/vs/editor/contrib/find/test/find.test.ts b/src/vs/editor/contrib/find/test/find.test.ts index 5f0f3a7fac19179ecd4d06c360a59f489c3b163e..0e55f535bdd63d6201fe372d23e253fd1f2efe5e 100644 --- a/src/vs/editor/contrib/find/test/find.test.ts +++ b/src/vs/editor/contrib/find/test/find.test.ts @@ -8,13 +8,13 @@ import * as assert from 'assert'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { getSelectionSearchString } from 'vs/editor/contrib/find/common/find'; -import { withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; suite('Find', () => { test('search string at position', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'ABC DEF', '0123 456' ], {}, (editor, cursor) => { @@ -37,7 +37,7 @@ suite('Find', () => { }); test('search string with selection', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'ABC DEF', '0123 456' ], {}, (editor, cursor) => { @@ -61,7 +61,7 @@ suite('Find', () => { }); test('search string with multiline selection', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'ABC DEF', '0123 456' ], {}, (editor, cursor) => { diff --git a/src/vs/editor/contrib/find/test/findController.test.ts b/src/vs/editor/contrib/find/test/findController.test.ts index 44a412b6796c122a5c256910bc9e5e02299fcef0..0c2c9f7da9bbebe221d63f2cb00806f6b2ebb146 100644 --- a/src/vs/editor/contrib/find/test/findController.test.ts +++ b/src/vs/editor/contrib/find/test/findController.test.ts @@ -13,7 +13,7 @@ import { Selection } from 'vs/editor/common/core/selection'; import { Range } from 'vs/editor/common/core/range'; import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; import { CommonFindController, FindStartFocusAction, IFindStartOptions, NextMatchFindAction, StartFindAction } from 'vs/editor/contrib/find/common/findController'; -import { withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { HistoryNavigator } from 'vs/base/common/history'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IStorageService } from 'vs/platform/storage/common/storage'; @@ -78,7 +78,7 @@ suite('FindController', () => { } as IStorageService); test('issue #1857: F3, Find Next, acts like "Find Under Cursor"', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'ABC', 'ABC', 'XYZ', @@ -136,7 +136,7 @@ suite('FindController', () => { }); test('issue #3090: F3 does not loop with two matches on a single line', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'import nls = require(\'vs/nls\');' ], { serviceCollection: serviceCollection }, (editor, cursor) => { @@ -159,7 +159,7 @@ suite('FindController', () => { }); test('issue #6149: Auto-escape highlighted text for search and replace regex mode', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'var x = (3 * 5)', 'var y = (3 * 5)', 'var z = (3 * 5)', @@ -185,7 +185,7 @@ suite('FindController', () => { }); test('issue #9043: Clear search scope when find widget is hidden', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'var x = (3 * 5)', 'var y = (3 * 5)', 'var z = (3 * 5)', @@ -213,7 +213,7 @@ suite('FindController', () => { }); test('find term is added to history on state change', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'var x = (3 * 5)', 'var y = (3 * 5)', 'var z = (3 * 5)', @@ -229,7 +229,7 @@ suite('FindController', () => { }); test('find term is added with delay', (done) => { - withMockCodeEditor([ + withTestCodeEditor([ 'var x = (3 * 5)', 'var y = (3 * 5)', 'var z = (3 * 5)', @@ -249,7 +249,7 @@ suite('FindController', () => { }); test('show previous find term', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'var x = (3 * 5)', 'var y = (3 * 5)', 'var z = (3 * 5)', @@ -266,7 +266,7 @@ suite('FindController', () => { }); test('show previous find term do not update history', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'var x = (3 * 5)', 'var y = (3 * 5)', 'var z = (3 * 5)', @@ -283,7 +283,7 @@ suite('FindController', () => { }); test('show next find term', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'var x = (3 * 5)', 'var y = (3 * 5)', 'var z = (3 * 5)', @@ -303,7 +303,7 @@ suite('FindController', () => { }); test('show next find term do not update history', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'var x = (3 * 5)', 'var y = (3 * 5)', 'var z = (3 * 5)', @@ -323,7 +323,7 @@ suite('FindController', () => { }); test('issue #18111: Regex replace with single space replaces with no space', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'HRESULT OnAmbientPropertyChange(DISPID dispid);' ], { serviceCollection: serviceCollection }, (editor, cursor) => { @@ -348,7 +348,7 @@ suite('FindController', () => { }); test('issue #24714: Regular expression with ^ in search & replace', () => { - withMockCodeEditor([ + withTestCodeEditor([ '', 'line2', 'line3' @@ -399,7 +399,7 @@ suite('FindController query options persistence', () => { } as IStorageService); test('matchCase', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'abc', 'ABC', 'XYZ', @@ -426,7 +426,7 @@ suite('FindController query options persistence', () => { queryState = { 'editor.isRegex': false, 'editor.matchCase': false, 'editor.wholeWord': true }; test('wholeWord', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'ABC', 'AB', 'XYZ', @@ -451,7 +451,7 @@ suite('FindController query options persistence', () => { }); test('toggling options is saved', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'ABC', 'AB', 'XYZ', diff --git a/src/vs/editor/contrib/find/test/findModel.test.ts b/src/vs/editor/contrib/find/test/findModel.test.ts index 6079fce664dd5b907ab5a1fefd31c9154d3625db..b6ceed484375f8e98e53a3e00a1d4e19908548be 100644 --- a/src/vs/editor/contrib/find/test/findModel.test.ts +++ b/src/vs/editor/contrib/find/test/findModel.test.ts @@ -12,14 +12,14 @@ import { Range } from 'vs/editor/common/core/range'; import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; import { FindModelBoundToEditorModel } from 'vs/editor/contrib/find/common/findModel'; import { FindReplaceState } from 'vs/editor/contrib/find/common/findState'; -import { withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { CoreNavigationCommands } from 'vs/editor/common/controller/coreCommands'; suite('FindModel', () => { function findTest(testName: string, callback: (editor: ICommonCodeEditor, cursor: Cursor) => void): void { test(testName, () => { - withMockCodeEditor([ + withTestCodeEditor([ '// my cool header', '#include "cool.h"', '#include ', diff --git a/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts b/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts index a8fc5304f4f5be65e9060941a5071775541e32b0..7ef9e72ab3b453f9790c8d17b64a8934f1db14ac 100644 --- a/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts +++ b/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts @@ -8,7 +8,7 @@ import * as assert from 'assert'; import { Selection } from 'vs/editor/common/core/selection'; import { Position } from 'vs/editor/common/core/position'; import { Handler, IModel, DefaultEndOfLine } from 'vs/editor/common/editorCommon'; -import { withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { DeleteAllLeftAction, JoinLinesAction, TransposeAction, UpperCaseAction, LowerCaseAction, DeleteAllRightAction, InsertLineBeforeAction, InsertLineAfterAction, IndentLinesAction } from 'vs/editor/contrib/linesOperations/common/linesOperations'; import { Cursor } from 'vs/editor/common/controller/cursor'; import { Model } from 'vs/editor/common/model/model'; @@ -17,7 +17,7 @@ import { CoreEditingCommands } from 'vs/editor/common/controller/coreCommands'; suite('Editor Contrib - Line Operations', () => { suite('DeleteAllLeftAction', () => { test('should delete to the left of the cursor', function () { - withMockCodeEditor( + withTestCodeEditor( [ 'one', 'two', @@ -38,7 +38,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('should work in multi cursor mode', function () { - withMockCodeEditor( + withTestCodeEditor( [ 'hello', 'world', @@ -75,7 +75,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('issue #36234: should push undo stop', () => { - withMockCodeEditor( + withTestCodeEditor( [ 'one', 'two', @@ -103,7 +103,7 @@ suite('Editor Contrib - Line Operations', () => { suite('JoinLinesAction', () => { test('should join lines and insert space if necessary', function () { - withMockCodeEditor( + withTestCodeEditor( [ 'hello', 'world', @@ -148,7 +148,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('should work in multi cursor mode', function () { - withMockCodeEditor( + withTestCodeEditor( [ 'hello', 'world', @@ -192,7 +192,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('should push undo stop', function () { - withMockCodeEditor( + withTestCodeEditor( [ 'hello', 'world' @@ -218,7 +218,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('transpose', function () { - withMockCodeEditor( + withTestCodeEditor( [ 'hello world', '', @@ -256,7 +256,7 @@ suite('Editor Contrib - Line Operations', () => { ); // fix #16633 - withMockCodeEditor( + withTestCodeEditor( [ '', '', @@ -294,7 +294,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('toggle case', function () { - withMockCodeEditor( + withTestCodeEditor( [ 'hello world', 'öçşğü' @@ -335,7 +335,7 @@ suite('Editor Contrib - Line Operations', () => { } ); - withMockCodeEditor( + withTestCodeEditor( [ '', ' ' @@ -369,7 +369,7 @@ suite('Editor Contrib - Line Operations', () => { suite('DeleteAllRightAction', () => { test('should be noop on empty', () => { - withMockCodeEditor([''], {}, (editor, cursor) => { + withTestCodeEditor([''], {}, (editor, cursor) => { const model = editor.getModel(); const action = new DeleteAllRightAction(); @@ -390,7 +390,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('should delete selected range', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'hello', 'world' ], {}, (editor, cursor) => { @@ -415,7 +415,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('should delete to the right of the cursor', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'hello', 'world' ], {}, (editor, cursor) => { @@ -435,7 +435,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('should join two lines, if at the end of the line', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'hello', 'world' ], {}, (editor, cursor) => { @@ -460,7 +460,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('should work with multiple cursors', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'hello', 'there', 'world' @@ -509,7 +509,7 @@ suite('Editor Contrib - Line Operations', () => { }); test('should work with undo/redo', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'hello', 'there', 'world' @@ -551,7 +551,7 @@ suite('Editor Contrib - Line Operations', () => { 'Second line', 'Third line' ]; - withMockCodeEditor(TEXT, {}, (editor, cursor) => { + withTestCodeEditor(TEXT, {}, (editor, cursor) => { editor.setPosition(new Position(lineNumber, column)); let insertLineBeforeAction = new InsertLineBeforeAction(); @@ -592,7 +592,7 @@ suite('Editor Contrib - Line Operations', () => { 'Second line', 'Third line' ]; - withMockCodeEditor(TEXT, {}, (editor, cursor) => { + withTestCodeEditor(TEXT, {}, (editor, cursor) => { editor.setPosition(new Position(lineNumber, column)); let insertLineAfterAction = new InsertLineAfterAction(); @@ -641,7 +641,7 @@ suite('Editor Contrib - Line Operations', () => { } ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { let indentLinesAction = new IndentLinesAction(); editor.setPosition(new Position(1, 2)); diff --git a/src/vs/editor/contrib/multicursor/test/multicursor.test.ts b/src/vs/editor/contrib/multicursor/test/multicursor.test.ts index a691ec737e1e4924faab2ceeeead02ecfe66884b..d493132974aa3072384239c577d81b039299e4ec 100644 --- a/src/vs/editor/contrib/multicursor/test/multicursor.test.ts +++ b/src/vs/editor/contrib/multicursor/test/multicursor.test.ts @@ -5,7 +5,7 @@ 'use strict'; import * as assert from 'assert'; -import { withMockCodeEditor, MockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor, TestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { Selection } from 'vs/editor/common/core/selection'; import { Range } from 'vs/editor/common/core/range'; import { InsertCursorAbove, InsertCursorBelow, MultiCursorSelectionController, SelectHighlightsAction, AddSelectionToNextFindMatchAction } from 'vs/editor/contrib/multicursor/common/multicursor'; @@ -17,7 +17,7 @@ import { CommonFindController } from 'vs/editor/contrib/find/common/findControll suite('Multicursor', () => { test('issue #2205: Multi-cursor pastes in reverse order', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'abc', 'def' ], {}, (editor, cursor) => { @@ -35,7 +35,7 @@ suite('Multicursor', () => { }); test('issue #1336: Insert cursor below on last line adds a cursor to the end of the current line', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'abc' ], {}, (editor, cursor) => { let addCursorDownAction = new InsertCursorBelow(); @@ -60,7 +60,7 @@ suite('Multicursor selection', () => { } as IStorageService); test('issue #8817: Cursor position changes when you cancel multicursor', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'var x = (3 * 5)', 'var y = (3 * 5)', 'var z = (3 * 5)', @@ -89,7 +89,7 @@ suite('Multicursor selection', () => { }); test('issue #5400: "Select All Occurrences of Find Match" does not select all if find uses regex', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'something', 'someething', 'someeething', @@ -120,7 +120,7 @@ suite('Multicursor selection', () => { }); test('AddSelectionToNextFindMatchAction can work with multiline', () => { - withMockCodeEditor([ + withTestCodeEditor([ '', 'qwe', 'rty', @@ -154,7 +154,7 @@ suite('Multicursor selection', () => { }); test('issue #6661: AddSelectionToNextFindMatchAction can work with touching ranges', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'abcabc', 'abc', 'abcabc', @@ -203,7 +203,7 @@ suite('Multicursor selection', () => { }); test('issue #23541: Multiline Ctrl+D does not work in CRLF files', () => { - withMockCodeEditor([ + withTestCodeEditor([ '', 'qwe', 'rty', @@ -238,8 +238,8 @@ suite('Multicursor selection', () => { }); }); - function testMulticursor(text: string[], callback: (editor: MockCodeEditor, findController: CommonFindController) => void): void { - withMockCodeEditor(text, { serviceCollection: serviceCollection }, (editor, cursor) => { + function testMulticursor(text: string[], callback: (editor: TestCodeEditor, findController: CommonFindController) => void): void { + withTestCodeEditor(text, { serviceCollection: serviceCollection }, (editor, cursor) => { let findController = editor.registerAndInstantiateContribution(CommonFindController); let multiCursorSelectController = editor.registerAndInstantiateContribution(MultiCursorSelectionController); @@ -250,7 +250,7 @@ suite('Multicursor selection', () => { }); } - function testAddSelectionToNextFindMatchAction(text: string[], callback: (editor: MockCodeEditor, action: AddSelectionToNextFindMatchAction, findController: CommonFindController) => void): void { + function testAddSelectionToNextFindMatchAction(text: string[], callback: (editor: TestCodeEditor, action: AddSelectionToNextFindMatchAction, findController: CommonFindController) => void): void { testMulticursor(text, (editor, findController) => { let action = new AddSelectionToNextFindMatchAction(); callback(editor, action, findController); diff --git a/src/vs/editor/contrib/quickFix/test/quickFixModel.test.ts b/src/vs/editor/contrib/quickFix/test/quickFixModel.test.ts index 895913f5169a32ab219ded6c0d46d85922dd60d7..69536a0dda92ff1d2f3de9c3e0dcf755759c6e0e 100644 --- a/src/vs/editor/contrib/quickFix/test/quickFixModel.test.ts +++ b/src/vs/editor/contrib/quickFix/test/quickFixModel.test.ts @@ -9,7 +9,7 @@ import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { Model } from 'vs/editor/common/model/model'; -import { mockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { MarkerService } from 'vs/platform/markers/common/markerService'; import { QuickFixOracle } from 'vs/editor/contrib/quickFix/browser/quickFixModel'; import { CodeActionProviderRegistry, LanguageIdentifier } from 'vs/editor/common/modes'; @@ -33,7 +33,7 @@ suite('QuickFix', () => { }); markerService = new MarkerService(); model = Model.createFromString('foobar foo bar\nfarboo far boo', undefined, languageIdentifier, uri); - editor = mockCodeEditor([], { model }); + editor = createTestCodeEditor(model); editor.setPosition({ lineNumber: 1, column: 1 }); }); diff --git a/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts b/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts index 48d89a54298f2dc673eee91b798fae024b170437..659d79504c77af6f4d0148b89f21a814bbdc6a3a 100644 --- a/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts +++ b/src/vs/editor/contrib/snippet/test/snippetController2.old.test.ts @@ -8,7 +8,7 @@ import * as assert from 'assert'; import { Position } from 'vs/editor/common/core/position'; import { Selection } from 'vs/editor/common/core/selection'; import { SnippetController2 } from 'vs/editor/contrib/snippet/browser/snippetController2'; -import { MockCodeEditor, withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { TestCodeEditor, withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { Cursor } from 'vs/editor/common/controller/cursor'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; @@ -30,7 +30,7 @@ class TestSnippetController extends SnippetController2 { suite('SnippetController', () => { - function snippetTest(cb: (editor: MockCodeEditor, cursor: Cursor, template: string, snippetController: TestSnippetController) => void, lines?: string[]): void { + function snippetTest(cb: (editor: TestCodeEditor, cursor: Cursor, template: string, snippetController: TestSnippetController) => void, lines?: string[]): void { if (!lines) { lines = [ @@ -42,7 +42,7 @@ suite('SnippetController', () => { ]; } - withMockCodeEditor(lines, {}, (editor, cursor) => { + withTestCodeEditor(lines, {}, (editor, cursor) => { editor.getModel().updateOptions({ insertSpaces: false }); diff --git a/src/vs/editor/contrib/snippet/test/snippetController2.test.ts b/src/vs/editor/contrib/snippet/test/snippetController2.test.ts index d897c970623dbf8a98aefa104712380d4922f519..33be2e031bb9407f9fa07515dfbe4782f90966d4 100644 --- a/src/vs/editor/contrib/snippet/test/snippetController2.test.ts +++ b/src/vs/editor/contrib/snippet/test/snippetController2.test.ts @@ -8,7 +8,7 @@ import * as assert from 'assert'; import { Selection } from 'vs/editor/common/core/selection'; import { SnippetController2 } from 'vs/editor/contrib/snippet/browser/snippetController2'; import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; -import { mockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { Model } from 'vs/editor/common/model/model'; import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKeybindingService'; @@ -35,7 +35,7 @@ suite('SnippetController2', function () { setup(function () { contextKeys = new MockContextKeyService(); model = Model.createFromString('if\n $state\nfi'); - editor = mockCodeEditor([], { model }); + editor = createTestCodeEditor(model); editor.setSelections([new Selection(1, 1, 1, 1), new Selection(2, 5, 2, 5)]); assert.equal(model.getEOL(), '\n'); }); diff --git a/src/vs/editor/contrib/snippet/test/snippetSession.test.ts b/src/vs/editor/contrib/snippet/test/snippetSession.test.ts index df92906da2fe8294fa1e9cbd102654f40d837bf1..59f1c212945b1c6f1eb37056b268886e24513dfd 100644 --- a/src/vs/editor/contrib/snippet/test/snippetSession.test.ts +++ b/src/vs/editor/contrib/snippet/test/snippetSession.test.ts @@ -10,7 +10,7 @@ import { Range } from 'vs/editor/common/core/range'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { SnippetSession } from 'vs/editor/contrib/snippet/browser/snippetSession'; import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; -import { mockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { Model } from 'vs/editor/common/model/model'; suite('SnippetSession', function () { @@ -28,7 +28,7 @@ suite('SnippetSession', function () { setup(function () { model = Model.createFromString('function foo() {\n console.log(a);\n}'); - editor = mockCodeEditor([], { model }); + editor = createTestCodeEditor(model); editor.setSelections([new Selection(1, 1, 1, 1), new Selection(2, 5, 2, 5)]); assert.equal(model.getEOL(), '\n'); }); diff --git a/src/vs/editor/contrib/suggest/test/suggestModel.test.ts b/src/vs/editor/contrib/suggest/test/suggestModel.test.ts index 97d52af80edc1cd22992c252a7c67263490f9e8b..77f5fda5725b2132e1507149041e437d6669fd7f 100644 --- a/src/vs/editor/contrib/suggest/test/suggestModel.test.ts +++ b/src/vs/editor/contrib/suggest/test/suggestModel.test.ts @@ -13,7 +13,7 @@ import { Model } from 'vs/editor/common/model/model'; import { ICommonCodeEditor, Handler } from 'vs/editor/common/editorCommon'; import { ISuggestSupport, ISuggestResult, SuggestRegistry, SuggestTriggerKind } from 'vs/editor/common/modes'; import { SuggestModel, LineContext } from 'vs/editor/contrib/suggest/browser/suggestModel'; -import { MockCodeEditor, MockScopeLocation } from 'vs/editor/test/browser/testCodeEditor'; +import { TestCodeEditor, MockScopeLocation } from 'vs/editor/test/browser/testCodeEditor'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; @@ -23,7 +23,7 @@ import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtil import { EditOperation } from 'vs/editor/common/core/editOperation'; import { Range } from 'vs/editor/common/core/range'; -function createMockEditor(model: Model): MockCodeEditor { +function createMockEditor(model: Model): TestCodeEditor { const contextKeyService = new MockContextKeyService(); const telemetryService = NullTelemetryService; const instantiationService = new InstantiationService(new ServiceCollection( @@ -31,7 +31,7 @@ function createMockEditor(model: Model): MockCodeEditor { [ITelemetryService, telemetryService] )); - const editor = new MockCodeEditor(new MockScopeLocation(), {}, instantiationService, contextKeyService); + const editor = new TestCodeEditor(new MockScopeLocation(), {}, instantiationService, contextKeyService); editor.setModel(model); return editor; } diff --git a/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts b/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts index 7af33d389f685fbcd3829c2e8553023e0a5eaba6..a3a5a4b34ef6b92a3889ffd6998a97cf25a429ec 100644 --- a/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts +++ b/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts @@ -8,7 +8,7 @@ import * as assert from 'assert'; import { Position } from 'vs/editor/common/core/position'; import { Selection } from 'vs/editor/common/core/selection'; import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; -import { withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { CursorWordLeft, CursorWordLeftSelect, CursorWordStartLeft, CursorWordEndLeft, CursorWordStartLeftSelect, CursorWordEndLeftSelect, @@ -81,7 +81,7 @@ suite('WordOperations', () => { } test('move word left', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -118,7 +118,7 @@ suite('WordOperations', () => { }); test('move word left selection', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -132,7 +132,7 @@ suite('WordOperations', () => { }); test('issue #832: moveWordLeft', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some more text a+= 3 +5-3 + 7 */ ' ], {}, (editor, _) => { editor.setPosition(new Position(1, 50)); @@ -156,7 +156,7 @@ suite('WordOperations', () => { }); test('moveWordStartLeft', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some more text a+= 3 +5-3 + 7 */ ' ], {}, (editor, _) => { editor.setPosition(new Position(1, 50)); @@ -180,7 +180,7 @@ suite('WordOperations', () => { }); test('moveWordEndLeft', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some more text a+= 3 +5-3 + 7 */ ' ], {}, (editor, _) => { editor.setPosition(new Position(1, 50)); @@ -205,7 +205,7 @@ suite('WordOperations', () => { }); test('move word right', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -240,7 +240,7 @@ suite('WordOperations', () => { }); test('move word right selection', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -254,7 +254,7 @@ suite('WordOperations', () => { }); test('issue #832: moveWordRight', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some more text a+= 3 +5-3 + 7 */ ' ], {}, (editor, _) => { editor.setPosition(new Position(1, 1)); @@ -280,7 +280,7 @@ suite('WordOperations', () => { }); test('moveWordEndRight', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some more text a+= 3 +5-3 + 7 */ ' ], {}, (editor, _) => { editor.setPosition(new Position(1, 1)); @@ -306,7 +306,7 @@ suite('WordOperations', () => { }); test('moveWordStartRight', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some more text a+= 3 +5-3 + 7 */ ' ], {}, (editor, _) => { editor.setPosition(new Position(1, 1)); @@ -331,7 +331,7 @@ suite('WordOperations', () => { }); test('delete word left for non-empty selection', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -347,7 +347,7 @@ suite('WordOperations', () => { }); test('delete word left for caret at beginning of document', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -363,7 +363,7 @@ suite('WordOperations', () => { }); test('delete word left for caret at end of whitespace', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -379,7 +379,7 @@ suite('WordOperations', () => { }); test('delete word left for caret just behind a word', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -395,7 +395,7 @@ suite('WordOperations', () => { }); test('delete word left for caret inside of a word', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -411,7 +411,7 @@ suite('WordOperations', () => { }); test('delete word right for non-empty selection', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -427,7 +427,7 @@ suite('WordOperations', () => { }); test('delete word right for caret at end of document', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -443,7 +443,7 @@ suite('WordOperations', () => { }); test('delete word right for caret at beggining of whitespace', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -459,7 +459,7 @@ suite('WordOperations', () => { }); test('delete word right for caret just before a word', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -475,7 +475,7 @@ suite('WordOperations', () => { }); test('delete word right for caret inside of a word', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' \tMy First Line\t ', '\tMy Second Line', ' Third Line🐶', @@ -491,7 +491,7 @@ suite('WordOperations', () => { }); test('issue #832: deleteWordLeft', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some text a+= 3 +5 */ ' ], {}, (editor, _) => { const model = editor.getModel(); @@ -512,7 +512,7 @@ suite('WordOperations', () => { }); test('deleteWordStartLeft', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some text a+= 3 +5 */ ' ], {}, (editor, _) => { const model = editor.getModel(); @@ -533,7 +533,7 @@ suite('WordOperations', () => { }); test('deleteWordEndLeft', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some text a+= 3 +5 */ ' ], {}, (editor, _) => { const model = editor.getModel(); @@ -553,7 +553,7 @@ suite('WordOperations', () => { }); test('issue #24947', () => { - withMockCodeEditor([ + withTestCodeEditor([ '{', '}' ], {}, (editor, _) => { @@ -562,7 +562,7 @@ suite('WordOperations', () => { deleteWordLeft(editor); assert.equal(model.getLineContent(1), '{}'); }); - withMockCodeEditor([ + withTestCodeEditor([ '{', '}' ], {}, (editor, _) => { @@ -571,7 +571,7 @@ suite('WordOperations', () => { deleteWordStartLeft(editor); assert.equal(model.getLineContent(1), '{}'); }); - withMockCodeEditor([ + withTestCodeEditor([ '{', '}' ], {}, (editor, _) => { @@ -582,7 +582,7 @@ suite('WordOperations', () => { }); test('issue #832: deleteWordRight', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some text a+= 3 +5-3 */ ' ], {}, (editor, _) => { const model = editor.getModel(); @@ -604,7 +604,7 @@ suite('WordOperations', () => { }); test('issue #3882: deleteWordRight', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'public void Add( int x,', ' int y )' ], {}, (editor, _) => { @@ -615,7 +615,7 @@ suite('WordOperations', () => { }); test('issue #3882: deleteWordStartRight', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'public void Add( int x,', ' int y )' ], {}, (editor, _) => { @@ -626,7 +626,7 @@ suite('WordOperations', () => { }); test('issue #3882: deleteWordEndRight', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'public void Add( int x,', ' int y )' ], {}, (editor, _) => { @@ -637,7 +637,7 @@ suite('WordOperations', () => { }); test('deleteWordStartRight', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some text a+= 3 +5-3 */ ' ], {}, (editor, _) => { const model = editor.getModel(); @@ -660,7 +660,7 @@ suite('WordOperations', () => { }); test('deleteWordEndRight', () => { - withMockCodeEditor([ + withTestCodeEditor([ ' /* Just some text a+= 3 +5-3 */ ' ], {}, (editor, _) => { const model = editor.getModel(); @@ -681,7 +681,7 @@ suite('WordOperations', () => { }); test('issue #3882 (1): Ctrl+Delete removing entire line when used at the end of line', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'A line with text.', ' And another one' ], {}, (editor, _) => { @@ -692,7 +692,7 @@ suite('WordOperations', () => { }); test('issue #3882 (2): Ctrl+Delete removing entire line when used at the end of line', () => { - withMockCodeEditor([ + withTestCodeEditor([ 'A line with text.', ' And another one' ], {}, (editor, _) => { diff --git a/src/vs/editor/test/browser/commands/sideEditing.test.ts b/src/vs/editor/test/browser/commands/sideEditing.test.ts index dfe1e4d33bab4c92a2b7350e8c0a9860af694329..1f37e96e96d9427f0d95fb63d3de4bfb3d058a71 100644 --- a/src/vs/editor/test/browser/commands/sideEditing.test.ts +++ b/src/vs/editor/test/browser/commands/sideEditing.test.ts @@ -10,14 +10,14 @@ import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; import { IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon'; -import { withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { Model } from 'vs/editor/common/model/model'; import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration'; import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl'; import { Cursor } from 'vs/editor/common/controller/cursor'; function testCommand(lines: string[], selections: Selection[], edits: IIdentifiedSingleEditOperation[], expectedLines: string[], expectedSelections: Selection[]): void { - withMockCodeEditor(lines, {}, (editor, cursor) => { + withTestCodeEditor(lines, {}, (editor, cursor) => { const model = editor.getModel(); cursor.setSelections('tests', selections); diff --git a/src/vs/editor/test/browser/controller/cursor.test.ts b/src/vs/editor/test/browser/controller/cursor.test.ts index 092b53e7a4afd44bac9fa0600ec898b5bf74d754..e23fea93877b8596938fd3283995d82611fd34fd 100644 --- a/src/vs/editor/test/browser/controller/cursor.test.ts +++ b/src/vs/editor/test/browser/controller/cursor.test.ts @@ -23,7 +23,7 @@ import { MockMode } from 'vs/editor/test/common/mocks/mockMode'; import { LanguageIdentifier } from 'vs/editor/common/modes'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { CoreNavigationCommands, CoreEditingCommands } from 'vs/editor/common/controller/coreCommands'; -import { withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { TextModel } from 'vs/editor/common/model/textModel'; import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl'; let H = Handler; @@ -696,7 +696,7 @@ suite('Editor Controller - Cursor', () => { }); test('column select 1', () => { - withMockCodeEditor([ + withTestCodeEditor([ '\tprivate compute(a:number): boolean {', '\t\tif (a + 3 === 0 || a + 5 === 0) {', '\t\t\treturn false;', @@ -1146,7 +1146,7 @@ suite('Editor Controller - Regression tests', () => { }, ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursor.setSelections('test', [new Selection(1, 1, 1, 13)]); // Check that indenting maintains the selection start at column 1 @@ -1171,7 +1171,7 @@ suite('Editor Controller - Regression tests', () => { }, ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursorCommand(cursor, H.Type, { text: '\n' }, 'keyboard'); assert.equal(model.getValue(EndOfLinePreference.LF), '\n', 'assert1'); @@ -1237,7 +1237,7 @@ suite('Editor Controller - Regression tests', () => { mode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 1, 6, false); assertCursor(cursor, new Selection(1, 6, 1, 6)); @@ -1264,7 +1264,7 @@ suite('Editor Controller - Regression tests', () => { } ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 1, 7, false); assertCursor(cursor, new Selection(1, 7, 1, 7)); @@ -1296,7 +1296,7 @@ suite('Editor Controller - Regression tests', () => { }, ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 7, 1, false); assertCursor(cursor, new Selection(7, 1, 7, 1)); @@ -1311,7 +1311,7 @@ suite('Editor Controller - Regression tests', () => { test('bug #16740: [editor] Cut line doesn\'t quite cut the last line', () => { // Part 1 => there is text on the last line - withMockCodeEditor([ + withTestCodeEditor([ 'asdasd', 'qwerty' ], {}, (editor, cursor) => { @@ -1327,7 +1327,7 @@ suite('Editor Controller - Regression tests', () => { }); // Part 2 => there is no text on the last line - withMockCodeEditor([ + withTestCodeEditor([ 'asdasd', '' ], {}, (editor, cursor) => { @@ -1385,7 +1385,7 @@ suite('Editor Controller - Regression tests', () => { }, ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 3, 2, false); moveTo(cursor, 1, 14, true); assertCursor(cursor, new Selection(3, 2, 1, 14)); @@ -1434,7 +1434,7 @@ suite('Editor Controller - Regression tests', () => { } ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 1, 1, false); moveTo(cursor, 3, 4, true); @@ -1516,7 +1516,7 @@ suite('Editor Controller - Regression tests', () => { } ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 3, 2, false); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(3), '\t \tx: 3'); @@ -1540,7 +1540,7 @@ suite('Editor Controller - Regression tests', () => { } ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 1, 15, false); moveTo(cursor, 1, 22, true); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -1636,7 +1636,7 @@ suite('Editor Controller - Regression tests', () => { ].join('\n') ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { CoreNavigationCommands.WordSelect.runCoreEditorCommand(cursor, { position: new Position(1, 8) }); assert.deepEqual(cursor.getSelection(), new Selection(1, 6, 1, 10)); @@ -1744,7 +1744,7 @@ suite('Editor Controller - Regression tests', () => { test('issue #36740: wordwrap creates an extra step / character at the wrapping point', () => { // a single model line => 4 view lines - withMockCodeEditor([ + withTestCodeEditor([ [ 'Lorem ipsum ', 'dolor sit amet ', @@ -1824,7 +1824,7 @@ suite('Editor Controller - Cursor Configuration', () => { } ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { // Tab on column 1 CoreNavigationCommands.MoveTo.runCoreEditorCommand(cursor, { position: new Position(2, 1) }); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -2053,7 +2053,7 @@ suite('Editor Controller - Cursor Configuration', () => { } ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 3, 1); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -2097,7 +2097,7 @@ suite('Editor Controller - Cursor Configuration', () => { } ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { // Move cursor to the end, verify that we do not trim whitespaces if line has values moveTo(cursor, 1, model.getLineContent(1).length + 1); @@ -2163,7 +2163,7 @@ suite('Editor Controller - Cursor Configuration', () => { } ); - withMockCodeEditor(null, { model: model, useTabStops: false }, (editor, cursor) => { + withTestCodeEditor(null, { model: model, useTabStops: false }, (editor, cursor) => { // DeleteLeft removes just one whitespace moveTo(cursor, 2, 9); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); @@ -2189,7 +2189,7 @@ suite('Editor Controller - Cursor Configuration', () => { } ); - withMockCodeEditor(null, { model: model, useTabStops: true }, (editor, cursor) => { + withTestCodeEditor(null, { model: model, useTabStops: true }, (editor, cursor) => { // DeleteLeft does not remove tab size, because some text exists before moveTo(cursor, 2, model.getLineContent(2).length + 1); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); @@ -2260,7 +2260,7 @@ suite('Editor Controller - Cursor Configuration', () => { } ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursorCommand(cursor, H.Type, { text: '\n' }, 'keyboard'); assert.equal(model.getValue(EndOfLinePreference.LF), '\n', 'assert1'); @@ -2428,7 +2428,7 @@ suite('Editor Controller - Indentation Rules', () => { mode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model, autoIndent: true }, (editor, cursor) => { + withTestCodeEditor(null, { model: model, autoIndent: true }, (editor, cursor) => { moveTo(cursor, 2, 11, false); assertCursor(cursor, new Selection(2, 11, 2, 11)); @@ -2907,7 +2907,7 @@ suite('Editor Controller - Indentation Rules', () => { mode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 4, 1, false); assertCursor(cursor, new Selection(4, 1, 4, 1)); @@ -2939,7 +2939,7 @@ suite('Editor Controller - Indentation Rules', () => { mode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 4, 2, false); assertCursor(cursor, new Selection(4, 2, 4, 2)); @@ -2971,7 +2971,7 @@ suite('Editor Controller - Indentation Rules', () => { mode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 4, 1, false); assertCursor(cursor, new Selection(4, 1, 4, 1)); @@ -3002,7 +3002,7 @@ suite('Editor Controller - Indentation Rules', () => { mode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 4, 3, false); assertCursor(cursor, new Selection(4, 3, 4, 3)); @@ -3033,7 +3033,7 @@ suite('Editor Controller - Indentation Rules', () => { mode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 4, 4, false); assertCursor(cursor, new Selection(4, 4, 4, 4)); @@ -3064,7 +3064,7 @@ suite('Editor Controller - Indentation Rules', () => { mode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { moveTo(cursor, 3, 1); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -3100,7 +3100,7 @@ suite('Editor Controller - Indentation Rules', () => { rubyMode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model, autoIndent: true }, (editor, cursor) => { + withTestCodeEditor(null, { model: model, autoIndent: true }, (editor, cursor) => { moveTo(cursor, 4, 7, false); assertCursor(cursor, new Selection(4, 7, 4, 7)); @@ -3237,7 +3237,7 @@ suite('Editor Controller - Indentation Rules', () => { mode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model, autoIndent: false }, (editor, cursor) => { + withTestCodeEditor(null, { model: model, autoIndent: false }, (editor, cursor) => { moveTo(cursor, 7, 6, false); assertCursor(cursor, new Selection(7, 6, 7, 6)); @@ -3841,7 +3841,7 @@ suite('autoClosingPairs', () => { mode.getLanguageIdentifier() ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursor.setSelections('test', [ new Selection(1, 4, 1, 4), new Selection(1, 10, 1, 10), @@ -3870,7 +3870,7 @@ suite('autoClosingPairs', () => { ].join('\n') ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { CoreNavigationCommands.WordSelect.runEditorCommand(null, editor, { position: new Position(3, 7) }); @@ -3894,7 +3894,7 @@ suite('Undo stops', () => { ].join('\n') ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursor.setSelections('test', [new Selection(1, 3, 1, 3)]); cursorCommand(cursor, H.Type, { text: 'first' }, 'keyboard'); assert.equal(model.getLineContent(1), 'A first line'); @@ -3923,7 +3923,7 @@ suite('Undo stops', () => { ].join('\n') ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursor.setSelections('test', [new Selection(1, 3, 1, 3)]); cursorCommand(cursor, H.Type, { text: 'first' }, 'keyboard'); assert.equal(model.getLineContent(1), 'A first line'); @@ -3952,7 +3952,7 @@ suite('Undo stops', () => { ].join('\n') ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursor.setSelections('test', [new Selection(2, 8, 2, 8)]); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); @@ -3986,7 +3986,7 @@ suite('Undo stops', () => { ].join('\n') ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursor.setSelections('test', [new Selection(2, 8, 2, 8)]); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); @@ -4024,7 +4024,7 @@ suite('Undo stops', () => { ].join('\n') ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursor.setSelections('test', [new Selection(2, 9, 2, 9)]); CoreEditingCommands.DeleteRight.runEditorCommand(null, editor, null); CoreEditingCommands.DeleteRight.runEditorCommand(null, editor, null); @@ -4055,7 +4055,7 @@ suite('Undo stops', () => { ].join('\n') ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursor.setSelections('test', [new Selection(2, 9, 2, 9)]); CoreEditingCommands.DeleteRight.runEditorCommand(null, editor, null); CoreEditingCommands.DeleteRight.runEditorCommand(null, editor, null); @@ -4091,7 +4091,7 @@ suite('Undo stops', () => { ].join('\n') ); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursor.setSelections('test', [new Selection(1, 3, 1, 3)]); cursorCommand(cursor, H.Type, { text: 'first and interesting' }, 'keyboard'); assert.equal(model.getLineContent(1), 'A first and interesting line'); diff --git a/src/vs/editor/test/browser/testCodeEditor.ts b/src/vs/editor/test/browser/testCodeEditor.ts index 599112cbb1c65ab34b1789087599f09361332946..138a47e11c716f13f57cbf18efbf38b3bb4b6f9c 100644 --- a/src/vs/editor/test/browser/testCodeEditor.ts +++ b/src/vs/editor/test/browser/testCodeEditor.ts @@ -17,7 +17,7 @@ import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration import * as editorOptions from 'vs/editor/common/config/editorOptions'; import { IDisposable } from 'vs/base/common/lifecycle'; -export class MockCodeEditor extends CommonCodeEditor { +export class TestCodeEditor extends CommonCodeEditor { public _isFocused = true; @@ -67,7 +67,7 @@ export class MockScopeLocation implements IContextKeyServiceTarget { getAttribute(attr: string): string { return undefined; } } -export interface MockCodeEditorCreationOptions extends editorOptions.IEditorOptions { +export interface TestCodeEditorCreationOptions extends editorOptions.IEditorOptions { /** * The initial model associated with this code editor. */ @@ -75,7 +75,7 @@ export interface MockCodeEditorCreationOptions extends editorOptions.IEditorOpti serviceCollection?: ServiceCollection; } -export function withMockCodeEditor(text: string[], options: MockCodeEditorCreationOptions, callback: (editor: MockCodeEditor, cursor: Cursor) => void): void { +export function withTestCodeEditor(text: string[], options: TestCodeEditorCreationOptions, callback: (editor: TestCodeEditor, cursor: Cursor) => void): void { // create a model if necessary and remember it in order to dispose it. let modelToDispose: Model = null; if (!options.model) { @@ -83,7 +83,7 @@ export function withMockCodeEditor(text: string[], options: MockCodeEditorCreati options.model = modelToDispose; } - let editor = _mockCodeEditor(options); + let editor = _createTestCodeEditor(options); callback(editor, editor.getCursor()); if (modelToDispose) { @@ -92,15 +92,11 @@ export function withMockCodeEditor(text: string[], options: MockCodeEditorCreati editor.dispose(); } -export function mockCodeEditor(text: string[], options: MockCodeEditorCreationOptions): CommonCodeEditor { - // TODO: who owns this model now? - if (!options.model) { - options.model = Model.createFromString(text.join('\n')); - } - return _mockCodeEditor(options); +export function createTestCodeEditor(model: editorCommon.IModel): CommonCodeEditor { + return _createTestCodeEditor({ model: model }); } -function _mockCodeEditor(options: MockCodeEditorCreationOptions): CommonCodeEditor { +function _createTestCodeEditor(options: TestCodeEditorCreationOptions): CommonCodeEditor { let contextKeyService = new MockContextKeyService(); @@ -108,7 +104,7 @@ function _mockCodeEditor(options: MockCodeEditorCreationOptions): CommonCodeEdit services.set(IContextKeyService, contextKeyService); let instantiationService = new InstantiationService(services); - let editor = new MockCodeEditor(new MockScopeLocation(), options, instantiationService, contextKeyService); + let editor = new TestCodeEditor(new MockScopeLocation(), options, instantiationService, contextKeyService); editor.setModel(options.model); return editor; } diff --git a/src/vs/editor/test/browser/testCommand.ts b/src/vs/editor/test/browser/testCommand.ts index a3a425a3cc0623c6d0a1fd31fbf5e63761f3840e..43d166bf8b9e80b7e70ea78c02f7a2a680d6ba53 100644 --- a/src/vs/editor/test/browser/testCommand.ts +++ b/src/vs/editor/test/browser/testCommand.ts @@ -10,7 +10,7 @@ import { Selection } from 'vs/editor/common/core/selection'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { Model } from 'vs/editor/common/model/model'; import { LanguageIdentifier } from 'vs/editor/common/modes'; -import { withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; export function testCommand( lines: string[], @@ -21,7 +21,7 @@ export function testCommand( expectedSelection: Selection ): void { let model = Model.createFromString(lines.join('\n'), undefined, languageIdentifier); - withMockCodeEditor(null, { model: model }, (editor, cursor) => { + withTestCodeEditor(null, { model: model }, (editor, cursor) => { cursor.setSelections('tests', [selection]); diff --git a/src/vs/workbench/parts/emmet/test/electron-browser/emmetAction.test.ts b/src/vs/workbench/parts/emmet/test/electron-browser/emmetAction.test.ts index 112ba96409aa83cc51f16ca040471fa6d721bc73..b72c00c8ddaa6edd0bbef751a26f29c8bd06068c 100644 --- a/src/vs/workbench/parts/emmet/test/electron-browser/emmetAction.test.ts +++ b/src/vs/workbench/parts/emmet/test/electron-browser/emmetAction.test.ts @@ -6,7 +6,7 @@ 'use strict'; import { IGrammarContributions, ILanguageIdentifierResolver, EmmetEditorAction } from 'vs/workbench/parts/emmet/electron-browser/emmetActions'; -import { withMockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import assert = require('assert'); import { LanguageId, LanguageIdentifier } from 'vs/editor/common/modes'; @@ -43,7 +43,7 @@ class MockGrammarContributions implements IGrammarContributions { suite('Emmet', () => { test('Get language mode and parent mode for emmet', () => { - withMockCodeEditor([], {}, (editor) => { + withTestCodeEditor([], {}, (editor) => { function testIsEnabled(mode: string, scopeName: string, expectedLanguage?: string, expectedParentLanguage?: string) { const languageIdentifier = new LanguageIdentifier(mode, 73); diff --git a/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts b/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts index 318b5cede96dd089d62e679a5d5db1f9395053dd..f55b059cac9a11ccdadec151a1c4a474531ad768 100644 --- a/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts @@ -13,7 +13,7 @@ import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl'; import WorkbenchEditorService = require('vs/workbench/services/editor/common/editorService'); import { RangeHighlightDecorations } from 'vs/workbench/common/editor/rangeDecorations'; import { Model } from 'vs/editor/common/model/model'; -import { mockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { IEditorInput } from 'vs/platform/editor/common/editor'; import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput'; @@ -41,7 +41,7 @@ suite('Editor - Range decorations', () => { instantiationService.stub(IModelService, stubModelService(instantiationService)); text = 'LINE1' + '\n' + 'LINE2' + '\n' + 'LINE3' + '\n' + 'LINE4' + '\r\n' + 'LINE5'; model = aModel(URI.file('some_file')); - codeEditor = mockCodeEditor([], { model }); + codeEditor = createTestCodeEditor(model); mockEditorService(codeEditor.getModel().uri); instantiationService.stub(WorkbenchEditorService.IWorkbenchEditorService, 'getActiveEditor', { getControl: () => { return codeEditor; } }); diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts index 9d967a617051f140b20147d86f159a6b1ff85053..520fd6faaa11064ba8605c8f9baeded58947a5c4 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts @@ -14,7 +14,7 @@ import { MockCodeEditorService } from 'vs/editor/test/common/mocks/mockCodeEdito import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { ExtHostDocumentsAndEditorsShape, IDocumentsAndEditorsDelta } from 'vs/workbench/api/node/extHost.protocol'; -import { mockCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; +import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { mock } from 'vs/workbench/test/electron-browser/api/mock'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import Event from 'vs/base/common/event'; @@ -103,7 +103,7 @@ suite('MainThreadDocumentsAndEditors', () => { this.timeout(1000 * 60); // increase timeout for this one test const model = modelService.createModel(hugeModelString, null, null); - const editor = mockCodeEditor(null, { model, wordWrap: 'off', wordWrapMinified: false }); + const editor = createTestCodeEditor(model); assert.equal(deltas.length, 1); deltas.length = 0; @@ -112,7 +112,7 @@ suite('MainThreadDocumentsAndEditors', () => { }); test('ignore editor w/o model', () => { - const editor = mockCodeEditor([], {}); + const editor = createTestCodeEditor(null); editor.setModel(null); codeEditorService.addCodeEditor(editor); assert.equal(deltas.length, 1); @@ -128,7 +128,7 @@ suite('MainThreadDocumentsAndEditors', () => { deltas.length = 0; const model = modelService.createModel('farboo', null, null); - codeEditorService.addCodeEditor(mockCodeEditor(null, { model })); + codeEditorService.addCodeEditor(createTestCodeEditor(model)); assert.equal(deltas.length, 2); const [first, second] = deltas; @@ -148,7 +148,7 @@ suite('MainThreadDocumentsAndEditors', () => { test('editor with dispos-ed/-ing model', () => { modelService.createModel('foobar', null, null); const model = modelService.createModel('farboo', null, null); - const editor = mockCodeEditor(null, { model }); + const editor = createTestCodeEditor(model); codeEditorService.addCodeEditor(editor); // ignore things until now