Beispiel #1
0
    public async Task CreateAndCloseTabTest()
    {
        var window = AvaloniaApp.GetMainWindow();

        await FocusFilePanelStep.FocusFilePanelAsync(window);

        var initialCount = GetTabsCount(window);

        for (var i = 0; i < 2; i++)
        {
            CreateNewTabStep.CreateNewTab(window);
            var isNewTabOpened = await WaitService.WaitForConditionAsync(() => initialCount + 1 == GetTabsCount(window));

            Assert.True(isNewTabOpened);

            CloseCurrentTabStep.CloseCurrentTab(window);
            var isTabClosed = await WaitService.WaitForConditionAsync(() => initialCount == GetTabsCount(window));

            Assert.True(isTabClosed);

            ChangeActiveFilePanelStep.ChangeActiveFilePanel(window);
        }

        ReopenClosedTabStep.ReopenClosedTab(window);
        var isTabReopened = await WaitService.WaitForConditionAsync(() => initialCount + 1 == GetTabsCount(window));

        Assert.True(isTabReopened);

        CloseCurrentTabStep.CloseCurrentTab(window);
    }
Beispiel #2
0
    public async Task TestSearch()
    {
        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);

        var filesPanel = ActiveFilePanelProvider.GetActiveFilePanelView(window);

        Assert.NotNull(filesPanel);

        ToggleSearchPanelStep.ToggleSearchPanelVisibility(window);

        await Task.Delay(100);

        var searchPanel = filesPanel
                          .GetVisualDescendants()
                          .OfType <SearchView>()
                          .SingleOrDefault();

        Assert.NotNull(searchPanel);

        var searchTextBox = searchPanel
                            .GetVisualDescendants()
                            .OfType <TextBox>()
                            .SingleOrDefault();

        Assert.NotNull(searchTextBox);

        searchTextBox.SendText(DirectoryName);

        await Task.Delay(1000);

        ChangeActiveFilePanelStep.ChangeActiveFilePanel(window);
        ChangeActiveFilePanelStep.ChangeActiveFilePanel(window);
        Keyboard.PressKey(window, Key.Down);
        Keyboard.PressKey(window, Key.Down);

        await Task.Delay(100);

        var selectedItemText = GetSelectedItemText(filesPanel);

        Assert.Equal(DirectoryName, selectedItemText);

        _fileFullPath = Path.Combine(viewModel.CurrentDirectory, FileName);
        await File.Create(_fileFullPath).DisposeAsync();

        await Task.Delay(1000);

        var fileIsVisible = CheckIfFilesExist(filesPanel);

        Assert.False(fileIsVisible);
    }
 public static void GoToParentDirectoryViaFilePanel(MainWindow window)
 {
     ChangeActiveFilePanelStep.ChangeActiveFilePanel(window);
     ChangeActiveFilePanelStep.ChangeActiveFilePanel(window);
     Keyboard.PressKey(window, Key.Down);
     Keyboard.PressKey(window, Key.Up);
     Keyboard.PressKey(window, Key.Up);
     Keyboard.PressKey(window, Key.Enter);
 }
Beispiel #4
0
    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));
    }
Beispiel #5
0
    public async Task TestRemoveDirectory(bool removePermanently)
    {
        var app    = AvaloniaApp.GetApp();
        var window = AvaloniaApp.GetMainWindow();

        await FocusFilePanelStep.FocusFilePanelAsync(window);

        var viewModel = ActiveFilePanelProvider.GetActiveFilePanelViewModel(window);

        _directoryFullPath = Path.Combine(viewModel.CurrentDirectory, DirectoryName);
        Directory.CreateDirectory(_directoryFullPath);

        ToggleSearchPanelStep.ToggleSearchPanelVisibility(window);

        await Task.Delay(100);

        var filesPanel = ActiveFilePanelProvider.GetActiveFilePanelView(window);

        Assert.NotNull(filesPanel);

        SearchNodeStep.SearchNode(window, DirectoryName);

        await Task.Delay(1000);

        ChangeActiveFilePanelStep.ChangeActiveFilePanel(window);
        ChangeActiveFilePanelStep.ChangeActiveFilePanel(window);
        Keyboard.PressKey(window, Key.Down);
        Keyboard.PressKey(window, Key.Down);

        if (removePermanently)
        {
            OpenRemoveDialogStep.OpenPermanentRemoveDialog(window);
        }
        else
        {
            OpenRemoveDialogStep.OpenRemoveDialog(window);
        }

        var isRemoveDialogOpened =
            await DialogOpenedCondition.CheckIfDialogIsOpenedAsync <RemoveNodesConfirmationDialog>(app);

        Assert.True(isRemoveDialogOpened);

        Keyboard.PressKey(window, Key.Enter);
        await Task.Delay(100);

        var isRemoveDialogClosed =
            await DialogClosedCondition.CheckIfDialogIsClosedAsync <RemoveNodesConfirmationDialog>(app);

        Assert.True(isRemoveDialogClosed);

        ToggleSearchPanelStep.ToggleSearchPanelVisibility(window);

        Assert.False(Directory.Exists(_directoryFullPath));
    }
Beispiel #6
0
    public void Dispose()
    {
        var window = AvaloniaApp.GetMainWindow();

        for (var i = 0; i < 2; i++)
        {
            ChangeActiveFilePanelStep.ChangeActiveFilePanel(window);
            CloseCurrentTabStep.CloseCurrentTab(window);
        }

        if (!string.IsNullOrEmpty(_directoryFullPath) && Directory.Exists(_directoryFullPath))
        {
            Directory.Delete(_directoryFullPath, true);
        }

        if (!string.IsNullOrEmpty(_fileFullPath) && File.Exists(_fileFullPath))
        {
            File.Delete(_fileFullPath);
        }
    }
Beispiel #7
0
    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));
    }