mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 09:08:53 +01:00
testing: greatly improve decoration syncing (#161446)
* testing: greatly improve decoration syncing - Mark a descoration as synced to a range on _any_ assignment to its range. https://github.com/microsoft/vscode/issues/161320 - Improve re-usage of testing decorations. Better performance and less unnecessary flickering. * tweak
This commit is contained in:
@@ -18,6 +18,7 @@ import { TestDiffOpType, TestItemExpandState, TestMessageType, TestsDiff } from
|
||||
import { TestId } from 'vs/workbench/contrib/testing/common/testId';
|
||||
import type { TestItem, TestRunRequest } from 'vscode';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import * as editorRange from 'vs/editor/common/core/range';
|
||||
|
||||
const simplify = (item: TestItem) => ({
|
||||
id: item.id,
|
||||
@@ -153,7 +154,7 @@ suite('ExtHost Testing', () => {
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
{
|
||||
op: TestDiffOpType.Update,
|
||||
item: { extId: new TestId(['ctrlId', 'id-a']).toString(), docv: undefined, item: { description: 'Hello world' } },
|
||||
item: { extId: new TestId(['ctrlId', 'id-a']).toString(), item: { description: 'Hello world' } },
|
||||
}
|
||||
]);
|
||||
});
|
||||
@@ -254,7 +255,7 @@ suite('ExtHost Testing', () => {
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
{
|
||||
op: TestDiffOpType.Update,
|
||||
item: { extId: new TestId(['ctrlId', 'id-a']).toString(), expand: TestItemExpandState.Expanded, docv: undefined, item: { label: 'Hello world' } },
|
||||
item: { extId: new TestId(['ctrlId', 'id-a']).toString(), expand: TestItemExpandState.Expanded, item: { label: 'Hello world' } },
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -262,7 +263,7 @@ suite('ExtHost Testing', () => {
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
{
|
||||
op: TestDiffOpType.Update,
|
||||
item: { extId: new TestId(['ctrlId', 'id-a']).toString(), docv: undefined, item: { label: 'still connected' } }
|
||||
item: { extId: new TestId(['ctrlId', 'id-a']).toString(), item: { label: 'still connected' } }
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -289,7 +290,7 @@ suite('ExtHost Testing', () => {
|
||||
},
|
||||
{
|
||||
op: TestDiffOpType.Update,
|
||||
item: { extId: TestId.fromExtHostTestItem(oldAB, 'ctrlId').toString(), docv: undefined, item: { label: 'Hello world' } },
|
||||
item: { extId: TestId.fromExtHostTestItem(oldAB, 'ctrlId').toString(), item: { label: 'Hello world' } },
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -299,11 +300,11 @@ suite('ExtHost Testing', () => {
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
{
|
||||
op: TestDiffOpType.Update,
|
||||
item: { extId: new TestId(['ctrlId', 'id-a', 'id-aa']).toString(), docv: undefined, item: { label: 'still connected1' } }
|
||||
item: { extId: new TestId(['ctrlId', 'id-a', 'id-aa']).toString(), item: { label: 'still connected1' } }
|
||||
},
|
||||
{
|
||||
op: TestDiffOpType.Update,
|
||||
item: { extId: new TestId(['ctrlId', 'id-a', 'id-ab']).toString(), docv: undefined, item: { label: 'still connected2' } }
|
||||
item: { extId: new TestId(['ctrlId', 'id-a', 'id-ab']).toString(), item: { label: 'still connected2' } }
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -333,13 +334,65 @@ suite('ExtHost Testing', () => {
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
{
|
||||
op: TestDiffOpType.Update,
|
||||
item: { extId: new TestId(['ctrlId', 'id-a', 'id-b']).toString(), docv: undefined, item: { label: 'still connected' } }
|
||||
item: { extId: new TestId(['ctrlId', 'id-a', 'id-b']).toString(), item: { label: 'still connected' } }
|
||||
},
|
||||
]);
|
||||
|
||||
assert.deepStrictEqual([...single.root.children].map(([_, item]) => item), [single.root.children.get('id-a')]);
|
||||
assert.deepStrictEqual(b.parent, a);
|
||||
});
|
||||
|
||||
test('sends document sync events', async () => {
|
||||
await single.expand(single.root.id, 0);
|
||||
single.collectDiff();
|
||||
|
||||
const a = single.root.children.get('id-a') as TestItemImpl;
|
||||
a.range = new Range(new Position(0, 0), new Position(1, 0));
|
||||
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
{
|
||||
op: TestDiffOpType.DocumentSynced,
|
||||
docv: undefined,
|
||||
uri: URI.file('/')
|
||||
},
|
||||
{
|
||||
op: TestDiffOpType.Update,
|
||||
item: {
|
||||
extId: new TestId(['ctrlId', 'id-a']).toString(),
|
||||
item: {
|
||||
range: editorRange.Range.lift({
|
||||
endColumn: 1,
|
||||
endLineNumber: 2,
|
||||
startColumn: 1,
|
||||
startLineNumber: 1
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
// sends on replace even if it's a no-op
|
||||
a.range = a.range;
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
{
|
||||
op: TestDiffOpType.DocumentSynced,
|
||||
docv: undefined,
|
||||
uri: URI.file('/')
|
||||
},
|
||||
]);
|
||||
|
||||
// sends on a child replacement
|
||||
const a2 = new TestItemImpl('ctrlId', 'id-a', 'a', URI.file('/'));
|
||||
a2.range = a.range;
|
||||
single.root.children.replace([a2, single.root.children.get('id-b')!]);
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
{
|
||||
op: TestDiffOpType.DocumentSynced,
|
||||
docv: undefined,
|
||||
uri: URI.file('/')
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user