public async Task TestCopyFile() { var window = AvaloniaApp.GetMainWindow(); await FocusFilePanelStep.FocusFilePanelAsync(window); CreateNewTabStep.CreateNewTab(window); var viewModel = ActiveFilePanelProvider.GetActiveFilePanelViewModel(window); _directoryFullPath = Path.Combine(viewModel.CurrentDirectory, DirectoryName); Directory.CreateDirectory(_directoryFullPath); _fileFullPath = Path.Combine(viewModel.CurrentDirectory, FileName); await File.WriteAllTextAsync(_fileFullPath, FileContent); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); CreateNewTabStep.CreateNewTab(window); FocusDirectorySelectorStep.FocusDirectorySelector(window); var textSet = SetDirectoryTextStep.SetDirectoryText(window, _directoryFullPath); Assert.True(textSet); await Task.Delay(1000); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); await Task.Delay(100); ToggleSearchPanelStep.ToggleSearchPanelVisibility(window); await Task.Delay(100); SearchNodeStep.SearchNode(window, FileName); await Task.Delay(300); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); Keyboard.PressKey(window, Key.Down); Keyboard.PressKey(window, Key.Down); CopySelectedNodesStep.CopySelectedNodes(window); ToggleSearchPanelStep.ToggleSearchPanelVisibility(window); await Task.Delay(1000); var copiedFullPath = Path.Combine(_directoryFullPath, FileName); var fileExists = await WaitService.WaitForConditionAsync(() => File.Exists(copiedFullPath)); Assert.True(fileExists); var fileContent = await File.ReadAllTextAsync(copiedFullPath); Assert.Equal(FileContent, fileContent); Assert.True(File.Exists(_fileFullPath)); }
public async Task GoToParentDirectoryAndBackTest() { var window = AvaloniaApp.GetMainWindow(); await FocusFilePanelStep.FocusFilePanelAsync(window); CreateNewTabStep.CreateNewTab(window); FocusDirectorySelectorStep.FocusDirectorySelector(window); var filesPanelViewModel = ActiveFilePanelProvider.GetActiveFilePanelViewModel(window); var currentDirectory = filesPanelViewModel.CurrentDirectory; var filesPanelView = ActiveFilePanelProvider.GetActiveFilePanelView(window); var directoryTextBox = filesPanelView .GetVisualDescendants() .OfType <TextBox>() .SingleOrDefault(t => t.Name == "DirectoryTextBox"); Assert.NotNull(directoryTextBox); var separatorPosition = directoryTextBox.Text.LastIndexOf(Path.DirectorySeparatorChar); Assert.True(separatorPosition >= 0); directoryTextBox.CaretIndex = directoryTextBox.Text.Length; var symbolsToRemoveCount = directoryTextBox.Text.Length - separatorPosition; for (var i = 0; i < symbolsToRemoveCount; i++) { Keyboard.PressKey(window, Key.Back); } await Task.Delay(5000); var isParentDirectoryOpened = await DirectoryOpenedCondition.CheckIfParentDirectoryIsOpenedAsync(window, currentDirectory); Assert.True(isParentDirectoryOpened); var directoryName = Path.GetFileNameWithoutExtension(currentDirectory); directoryTextBox.SendText(Path.DirectorySeparatorChar + directoryName); var childDirectoryWasOpened = await DirectoryOpenedCondition.CheckIfDirectoryIsOpenedAsync(window, currentDirectory); Assert.True(childDirectoryWasOpened); }
public async Task TestMoveDirectory() { var window = AvaloniaApp.GetMainWindow(); await FocusFilePanelStep.FocusFilePanelAsync(window); CreateNewTabStep.CreateNewTab(window); var viewModel = ActiveFilePanelProvider.GetActiveFilePanelViewModel(window); _sourceDirectoryFullPath = Path.Combine(viewModel.CurrentDirectory, SourceDirectoryName); Directory.CreateDirectory(_sourceDirectoryFullPath); var fileFullPath = Path.Combine(_sourceDirectoryFullPath, FileName); await File.WriteAllTextAsync(fileFullPath, FileContent); var innerDirectoryPath = Path.Combine(_sourceDirectoryFullPath, InnerDirectoryName); Directory.CreateDirectory(innerDirectoryPath); var innerFileFullPath = Path.Combine(innerDirectoryPath, FileName); await File.WriteAllTextAsync(innerFileFullPath, FileContent); var emptyDirectoryPath = Path.Combine(innerDirectoryPath, EmptyDirectoryName); Directory.CreateDirectory(emptyDirectoryPath); _targetDirectoryFullPath = Path.Combine(viewModel.CurrentDirectory, TargetDirectoryName); Directory.CreateDirectory(_targetDirectoryFullPath); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); CreateNewTabStep.CreateNewTab(window); FocusDirectorySelectorStep.FocusDirectorySelector(window); var textSet = SetDirectoryTextStep.SetDirectoryText(window, _targetDirectoryFullPath); Assert.True(textSet); await Task.Delay(1000); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); await Task.Delay(100); ToggleSearchPanelStep.ToggleSearchPanelVisibility(window); await Task.Delay(100); SearchNodeStep.SearchNode(window, SourceDirectoryName); await Task.Delay(300); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); Keyboard.PressKey(window, Key.Down); Keyboard.PressKey(window, Key.Down); MoveSelectedNodesStep.MoveSelectedNodes(window); ToggleSearchPanelStep.ToggleSearchPanelVisibility(window); await Task.Delay(1000); var copiedFullPath = Path.Combine(_targetDirectoryFullPath, SourceDirectoryName, FileName); var fileExists = await WaitService.WaitForConditionAsync(() => File.Exists(copiedFullPath)); Assert.True(fileExists); var copiedInnerFullPath = Path.Combine(_targetDirectoryFullPath, SourceDirectoryName, InnerDirectoryName, FileName); var innerFileExists = await WaitService.WaitForConditionAsync(() => File.Exists(copiedInnerFullPath)); Assert.True(innerFileExists); var emptyDirPath = Path.Combine(_targetDirectoryFullPath, SourceDirectoryName, InnerDirectoryName, EmptyDirectoryName); var emptyDirExists = await WaitService.WaitForConditionAsync(() => Directory.Exists(emptyDirPath)); Assert.True(emptyDirExists); foreach (var filePath in new[] { copiedFullPath, copiedInnerFullPath }) { var fileContent = await File.ReadAllTextAsync(filePath); Assert.Equal(FileContent, fileContent); } Assert.False(File.Exists(fileFullPath)); Assert.False(File.Exists(innerFileFullPath)); Assert.False(Directory.Exists(emptyDirectoryPath)); Assert.False(Directory.Exists(_sourceDirectoryFullPath)); }