提交 25bf5d9d 编写于 作者: D Daniel Imms

Fix tests, add test for onExitAndWindowClose restore

上级 d71cb023
......@@ -17,10 +17,12 @@ import { EnvironmentService } from 'vs/platform/environment/node/environmentServ
import { parseArgs } from 'vs/platform/environment/node/argv';
import { BackupMainService } from 'vs/platform/backup/electron-main/backupMainService';
import { IBackupWorkspacesFormat } from 'vs/platform/backup/common/backup';
import { HotExitConfiguration } from 'vs/platform/files/common/files';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
class TestBackupMainService extends BackupMainService {
constructor(backupHome: string, backupWorkspacesPath: string) {
super(new EnvironmentService(parseArgs(process.argv), process.execPath), null);
constructor(backupHome: string, backupWorkspacesPath: string, configService: TestConfigurationService) {
super(new EnvironmentService(parseArgs(process.argv), process.execPath), configService);
this.backupHome = backupHome;
this.workspacesJsonPath = backupWorkspacesPath;
......@@ -59,9 +61,11 @@ suite('BackupMainService', () => {
const barFile = Uri.file(platform.isWindows ? 'C:\\bar' : '/bar');
let service: TestBackupMainService;
let configService: TestConfigurationService;
setup(done => {
service = new TestBackupMainService(backupHome, backupWorkspacesPath);
configService = new TestConfigurationService();
service = new TestBackupMainService(backupHome, backupWorkspacesPath, configService);
// Delete any existing backups completely and then re-create it.
extfs.del(backupHome, os.tmpdir(), () => {
......@@ -166,6 +170,14 @@ suite('BackupMainService', () => {
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
});
test('getWorkspaceBackupPaths() should return [] when files.hotExit = "onExitAndWindowClose"', () => {
service.registerWindowForBackupsSync(1, false, null, fooFile.fsPath.toUpperCase());
assert.deepEqual(service.getWorkspaceBackupPaths(), [fooFile.fsPath.toUpperCase()]);
configService.setUserConfiguration('files.hotExit', HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE);
service.loadSync();
assert.deepEqual(service.getWorkspaceBackupPaths(), []);
});
test('getEmptyWorkspaceBackupPaths() should return [] when workspaces.json doesn\'t exist', () => {
assert.deepEqual(service.getEmptyWorkspaceBackupPaths(), []);
});
......
......@@ -355,7 +355,7 @@ export abstract class TextFileService implements ITextFileService {
}
// Hot exit
const hotExitMode = configuration && configuration.files ? configuration.files.hotExit : HotExitConfiguration.ON_EXIT;
const hotExitMode = configuration && configuration.files ? configuration.files.hotExit : HotExitConfiguration.OFF;
// Handle the legacy case where hot exit was a boolean
if (<any>hotExitMode === false) {
this.configuredHotExit = HotExitConfiguration.OFF;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册