Exemple #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);

                Keyboard.PressKey(window, Key.Tab);
            }

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

            Assert.True(isTabReopened);

            CloseCurrentTabStep.CloseCurrentTab(window);
        }
Exemple #2
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));
    }
Exemple #3
0
    public async Task TestCreateDirectoryDialog()
    {
        var app    = AvaloniaApp.GetApp();
        var window = AvaloniaApp.GetMainWindow();

        await FocusFilePanelStep.FocusFilePanelAsync(window);

        OpenCreateDirectoryDialogStep.OpenCreateDirectoryDialog(window);
        var isDialogOpened = await DialogOpenedCondition.CheckIfDialogIsOpenedAsync <CreateDirectoryDialog>(app);

        Assert.True(isDialogOpened);

        _dialog = app
                  .Windows
                  .OfType <CreateDirectoryDialog>()
                  .Single();

        var buttons = _dialog
                      .GetVisualDescendants()
                      .OfType <Button>()
                      .ToArray();

        Assert.Equal(2, buttons.Length);
        var createButton = buttons.SingleOrDefault(b => !b.Classes.Contains("transparentDialogButton"));

        Assert.NotNull(createButton);
        Assert.False(createButton.Command.CanExecute(null));
        Assert.True(createButton.IsDefault);

        var directoryNameTextBox = _dialog
                                   .GetVisualDescendants()
                                   .OfType <TextBox>()
                                   .SingleOrDefault();

        Assert.NotNull(directoryNameTextBox);
        Assert.True(string.IsNullOrEmpty(directoryNameTextBox.Text));
        Assert.True(directoryNameTextBox.IsFocused);

        directoryNameTextBox.SendText("DirectoryName");

        await WaitService.WaitForConditionAsync(() => createButton.Command.CanExecute(null));

        var closeButton = buttons.SingleOrDefault(b => b.Classes.Contains("transparentDialogButton"));

        Assert.NotNull(closeButton);
        Assert.True(closeButton.Command.CanExecute(null));
        Assert.False(closeButton.IsDefault);

        closeButton.Command.Execute(null);

        var isDialogClosed = await DialogClosedCondition.CheckIfDialogIsClosedAsync <CreateDirectoryDialog>(app);

        Assert.True(isDialogClosed);
    }
Exemple #4
0
    public async Task ToggleFavouriteDirectoryTest()
    {
        var window = AvaloniaApp.GetMainWindow();

        await FocusFilePanelStep.FocusFilePanelAsync(window);

        Assert.Equal(1, GetFavouriteDirectoriesCount(window));
        Assert.Equal(2, GetFavouriteDirectoriesActiveIconsCount(window));

        ToggleFavouriteDirectoryStep.ToggleFavouriteDirectory(window);
        await WaitService.WaitForConditionAsync(() => GetFavouriteDirectoriesCount(window) == 0);

        await WaitService.WaitForConditionAsync(() => GetFavouriteDirectoriesActiveIconsCount(window) == 0);

        ToggleFavouriteDirectoryStep.ToggleFavouriteDirectory(window);
        await WaitService.WaitForConditionAsync(() => GetFavouriteDirectoriesCount(window) == 1);

        await WaitService.WaitForConditionAsync(() => GetFavouriteDirectoriesActiveIconsCount(window) == 2);
    }
Exemple #5
0
 public static Task <bool> CheckIfLastTabIsOpenedAsync(
     IClassicDesktopStyleApplicationLifetime app) =>
 WaitService.WaitForConditionAsync(() => CheckIfTabIsOpened(app, -1));
 public static Task <bool> CheckIfDialogIsOpenedAsync <TDialog>(IClassicDesktopStyleApplicationLifetime app) =>
 WaitService.WaitForConditionAsync(() => CheckIfDialogIsOpened <TDialog>(app));
    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));
    }
    public static async Task <bool> CheckIfDirectoryIsOpenedAsync(MainWindow mainWindow, string directory)
    {
        var viewModel = ActiveFilePanelProvider.GetActiveFilePanelViewModel(mainWindow);

        return(await WaitService.WaitForConditionAsync(() => CheckIfDirectoryWasOpened(viewModel, directory), 100, 50));
    }