Skip to content

Commit

Permalink
test: Add tests to check ControlTheme Nested Selector/Setter Completa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
workgroupengineering committed Apr 4, 2024
1 parent f4b12db commit 206f776
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<AvaloniaTemplatesPackageName>Avalonia.Templates</AvaloniaTemplatesPackageName>
<AvaloniaTemplatesPackageVersion>11.0.10</AvaloniaTemplatesPackageVersion>
<AvaloniaVersion>11.0.7</AvaloniaVersion>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
68 changes: 65 additions & 3 deletions tests/CompletionEngineTests/AdvancedTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Xunit;

Expand Down Expand Up @@ -487,6 +485,70 @@ public void Should_Not_Contain_Abstract_Classes()
}
}

[Fact]
public void ControlTheme_Nested_Selector_Should_Be_Completed()
{
var xaml =
"""
<UserControl.Resources>
<ControlTheme x:Key="MyButton" TargetType="Button">
<Style Selector="
""";
var compl = GetCompletionsFor(xaml).Completions;

Assert.Single(compl);
Assert.Contains(compl, v => v.InsertText == "^");
}

[Fact]
public void ControlTheme_Nested_Selector_Should_Be_Completed_PseudoClass()
{
var xaml =
"""
<UserControl.Resources>
<ControlTheme x:Key="MyButton" TargetType="Button">
<Style Selector="^:
""";
var compl = GetCompletionsFor(xaml).Completions;

Assert.Equal(10, compl.Count);
Assert.Contains(compl, v => v.InsertText == ":disabled");
}

[Fact]
public void ControlTheme_Nested_Selector_Should_Be_Completed_Template()
{
var xaml =
"""
<UserControl.Resources>
<ControlTheme x:Key="MyButton" TargetType="Button">
<Style Selector="^ /template/ C
""";
var compl = GetCompletionsFor(xaml).Completions;

Assert.Contains(compl, v => v.InsertText == "ContentPresenter");
}

[Fact]
public void ControlTheme_Nested_Selector_Should_Be_Completed_Setter()
{
string[] expected = [
"Command",
"CommandParameter",
];

var xaml =
"""
<UserControl.Resources>
<ControlTheme x:Key="MyButton" TargetType="Button">
<Style Selector="^:disabled">
<Setter Property="Com
""";
var compl = GetCompletionsFor(xaml).Completions.Select(c => c.InsertText);

Assert.Equal(expected, compl);
}

public static IEnumerable<object[]> GetStyleSelectors()
{
yield return new object[]
Expand Down Expand Up @@ -609,7 +671,7 @@ public static IEnumerable<object[]> GetStyleSelectors()
new ("AttachedBehavior","local|AttachedBehavior", Avalonia.Ide.CompletionEngine.CompletionKind.Class | Avalonia.Ide.CompletionEngine.CompletionKind.TargetTypeClass),
},
};

yield return new object[]
{
"<Style Selector=\"ToggleSwitch /template/ #",
Expand Down

0 comments on commit 206f776

Please sign in to comment.