add test for label change event
This commit is contained in:
parent
176f350454
commit
2db4e12808
2 changed files with 22 additions and 3 deletions
|
@ -749,11 +749,13 @@ export function getUntitledOrFileResource(input: IEditorInput, supportDiff?: boo
|
||||||
|
|
||||||
// File
|
// File
|
||||||
let fileInput = asFileEditorInput(input, supportDiff);
|
let fileInput = asFileEditorInput(input, supportDiff);
|
||||||
return fileInput && fileInput && fileInput.getResource();
|
|
||||||
|
return fileInput && fileInput.getResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO@Ben every editor should have an associated resource
|
||||||
export function getResource(input: IEditorInput): URI {
|
export function getResource(input: IEditorInput): URI {
|
||||||
if (input && typeof (<any>input).getResource === 'function') {
|
if (input instanceof EditorInput && typeof (<any>input).getResource === 'function') {
|
||||||
let candidate = (<any>input).getResource();
|
let candidate = (<any>input).getResource();
|
||||||
if (candidate instanceof URI) {
|
if (candidate instanceof URI) {
|
||||||
return candidate;
|
return candidate;
|
||||||
|
|
|
@ -111,6 +111,10 @@ class TestEditorInput extends EditorInput {
|
||||||
public setDirty(): void {
|
public setDirty(): void {
|
||||||
this._onDidChangeDirty.fire();
|
this._onDidChangeDirty.fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setLabel(): void {
|
||||||
|
this._onDidChangeLabel.fire();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NonSerializableTestEditorInput extends EditorInput {
|
class NonSerializableTestEditorInput extends EditorInput {
|
||||||
|
@ -1641,7 +1645,7 @@ suite('Editor Stacks Model', () => {
|
||||||
assert.equal(input1.isDisposed(), false);
|
assert.equal(input1.isDisposed(), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Stack - Multiple Editors - Editor Emits Dirty', function () {
|
test('Stack - Multiple Editors - Editor Emits Dirty and Label Changed', function () {
|
||||||
const model = create();
|
const model = create();
|
||||||
|
|
||||||
const group1 = model.openGroup('group1');
|
const group1 = model.openGroup('group1');
|
||||||
|
@ -1658,25 +1662,38 @@ suite('Editor Stacks Model', () => {
|
||||||
dirtyCounter++;
|
dirtyCounter++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let labelChangeCounter = 0;
|
||||||
|
model.onEditorLabelChange(() => {
|
||||||
|
labelChangeCounter++;
|
||||||
|
});
|
||||||
|
|
||||||
(<TestEditorInput>input1).setDirty();
|
(<TestEditorInput>input1).setDirty();
|
||||||
|
(<TestEditorInput>input1).setLabel();
|
||||||
|
|
||||||
assert.equal(dirtyCounter, 1);
|
assert.equal(dirtyCounter, 1);
|
||||||
|
assert.equal(labelChangeCounter, 1);
|
||||||
|
|
||||||
(<TestEditorInput>input2).setDirty();
|
(<TestEditorInput>input2).setDirty();
|
||||||
|
(<TestEditorInput>input2).setLabel();
|
||||||
|
|
||||||
assert.equal(dirtyCounter, 2);
|
assert.equal(dirtyCounter, 2);
|
||||||
|
assert.equal(labelChangeCounter, 2);
|
||||||
|
|
||||||
group2.closeAllEditors();
|
group2.closeAllEditors();
|
||||||
|
|
||||||
(<TestEditorInput>input2).setDirty();
|
(<TestEditorInput>input2).setDirty();
|
||||||
|
(<TestEditorInput>input2).setLabel();
|
||||||
|
|
||||||
assert.equal(dirtyCounter, 2);
|
assert.equal(dirtyCounter, 2);
|
||||||
|
assert.equal(labelChangeCounter, 2);
|
||||||
|
|
||||||
model.closeGroups();
|
model.closeGroups();
|
||||||
|
|
||||||
(<TestEditorInput>input1).setDirty();
|
(<TestEditorInput>input1).setDirty();
|
||||||
|
(<TestEditorInput>input1).setLabel();
|
||||||
|
|
||||||
assert.equal(dirtyCounter, 2);
|
assert.equal(dirtyCounter, 2);
|
||||||
|
assert.equal(labelChangeCounter, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Groups - Model change events (structural vs state)', function () {
|
test('Groups - Model change events (structural vs state)', function () {
|
||||||
|
|
Loading…
Reference in a new issue