public async Task TestSettingsDialog()
    {
        var app    = AvaloniaApp.GetApp();
        var window = AvaloniaApp.GetMainWindow();

        await FocusFilePanelStep.FocusFilePanelAsync(window);

        OpenSettingsDialogStep.OpenSettingsDialog(window);
        await DialogOpenedCondition.CheckIfDialogIsOpenedAsync <SettingsDialog>(app);

        _dialog = app
                  .Windows
                  .OfType <SettingsDialog>()
                  .Single();
        var closeButton = _dialog
                          .GetVisualDescendants()
                          .OfType <Button>()
                          .SingleOrDefault(b => b.Classes.Contains("transparentDialogButton"));

        Assert.NotNull(closeButton);

        Assert.True(closeButton.Command.CanExecute(null));
        closeButton.Command.Execute(null);

        var isClosed = await DialogClosedCondition.CheckIfDialogIsClosedAsync <SettingsDialog>(app);

        Assert.True(isClosed);
    }
Exemple #2
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));
    }
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 CreateDirectoryTest()
    {
        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);

        var viewModel = ActiveFilePanelProvider.GetActiveFilePanelViewModel(window);

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

        CreateDirectoryStep.CreateDirectory(app, window, DirectoryName);

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

        Assert.True(isDialogClosed);

        Assert.True(Directory.Exists(_directoryFullPath));
    }
Exemple #5
0
        public async Task CreateAndRemoveDirectoryTest()
        {
            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);

            CreateDirectoryStep.CreateDirectory(app, window, DirectoryName);

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

            Assert.True(isDialogClosed);

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

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

            await Task.Delay(100);

            var selectedItemText = GetSelectedItemText(filesPanel);

            Assert.Equal(DirectoryName, selectedItemText);

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

            Assert.False(Directory.Exists(_directoryFullPath));
        }