-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some problems with progress edits (#194838)
- Loading branch information
Showing
3 changed files
with
102 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as assert from 'assert'; | ||
import { runWithFakedTimers } from 'vs/base/test/common/timeTravelScheduler'; | ||
import { Progress } from 'vs/platform/progress/common/progress'; | ||
|
||
suite('Progress', () => { | ||
test('multiple report calls are processed in sequence', async () => { | ||
await runWithFakedTimers({ useFakeTimers: true, maxTaskCount: 100 }, async () => { | ||
const executionOrder: string[] = []; | ||
const timeout = (time: number) => { | ||
return new Promise<void>(resolve => setTimeout(resolve, time)); | ||
}; | ||
const executor = async (value: number) => { | ||
executionOrder.push(`start ${value}`); | ||
if (value === 1) { | ||
// 1 is slowest | ||
await timeout(100); | ||
} else if (value === 2) { | ||
// 2 is also slow | ||
await timeout(50); | ||
} else { | ||
// 3 is fast | ||
await timeout(10); | ||
} | ||
executionOrder.push(`end ${value}`); | ||
}; | ||
const progress = new Progress<number>(executor, { async: true }); | ||
|
||
progress.report(1); | ||
progress.report(2); | ||
progress.report(3); | ||
|
||
await timeout(1000); | ||
|
||
assert.deepStrictEqual(executionOrder, [ | ||
'start 1', | ||
'end 1', | ||
'start 2', | ||
'end 2', | ||
'start 3', | ||
'end 3', | ||
]); | ||
}); | ||
}); | ||
}); |
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