danwalmsley
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
55 additions and
12 deletions
-
.ncrunch/Avalonia.Desktop.v3.ncrunchproject
-
.ncrunch/Avalonia.net461.v3.ncrunchproject
-
Avalonia.v3.ncrunchsolution
-
src/Avalonia.Styling/Styling/TypeNameAndClassSelector.cs
-
tests/Avalonia.Styling.UnitTests/SelectorTests_Multiple.cs
|
|
|
@ -0,0 +1,5 @@ |
|
|
|
<ProjectConfiguration> |
|
|
|
<Settings> |
|
|
|
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|
|
|
</Settings> |
|
|
|
</ProjectConfiguration> |
|
|
|
@ -0,0 +1,5 @@ |
|
|
|
<ProjectConfiguration> |
|
|
|
<Settings> |
|
|
|
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|
|
|
</Settings> |
|
|
|
</ProjectConfiguration> |
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
<Settings> |
|
|
|
<AdditionalFilesToIncludeForSolution> |
|
|
|
<Value>tests\TestFiles\**.*</Value> |
|
|
|
<Value>src\Avalonia.Build.Tasks\bin\Debug\netstandard2.0\Avalonia.Build.Tasks.dll</Value> |
|
|
|
</AdditionalFilesToIncludeForSolution> |
|
|
|
<AllowParallelTestExecution>True</AllowParallelTestExecution> |
|
|
|
<ProjectConfigStoragePathRelativeToSolutionDir>.ncrunch</ProjectConfigStoragePathRelativeToSolutionDir> |
|
|
|
|
|
|
|
@ -116,11 +116,9 @@ namespace Avalonia.Styling |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (Name != null) |
|
|
|
if (Name != null && control.Name != Name) |
|
|
|
{ |
|
|
|
return control.Name == Name ? |
|
|
|
SelectorMatch.AlwaysThisInstance : |
|
|
|
SelectorMatch.NeverThisInstance; |
|
|
|
return SelectorMatch.NeverThisInstance; |
|
|
|
} |
|
|
|
|
|
|
|
if (_classes.IsValueCreated && _classes.Value.Count > 0) |
|
|
|
@ -130,17 +128,13 @@ namespace Avalonia.Styling |
|
|
|
var observable = new ClassObserver(control.Classes, _classes.Value); |
|
|
|
return new SelectorMatch(observable); |
|
|
|
} |
|
|
|
else |
|
|
|
else if (!Matches(control.Classes)) |
|
|
|
{ |
|
|
|
return Matches(control.Classes) ? |
|
|
|
SelectorMatch.AlwaysThisInstance : |
|
|
|
SelectorMatch.NeverThisInstance; |
|
|
|
return SelectorMatch.NeverThisInstance; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return SelectorMatch.AlwaysThisType; |
|
|
|
} |
|
|
|
|
|
|
|
return Name == null ? SelectorMatch.AlwaysThisType : SelectorMatch.AlwaysThisInstance; |
|
|
|
} |
|
|
|
|
|
|
|
protected override Selector MovePrevious() => _previous; |
|
|
|
|
|
|
|
@ -85,6 +85,44 @@ namespace Avalonia.Styling.UnitTests |
|
|
|
Assert.Equal(SelectorMatchResult.NeverThisType, match.Result); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Named_Class_Template_Child_Of_Control() |
|
|
|
{ |
|
|
|
var template = new FuncControlTemplate(parent => |
|
|
|
{ |
|
|
|
return new Border |
|
|
|
{ |
|
|
|
Name = "border", |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
var control = new Button |
|
|
|
{ |
|
|
|
Template = template, |
|
|
|
}; |
|
|
|
|
|
|
|
control.ApplyTemplate(); |
|
|
|
|
|
|
|
var selector = default(Selector) |
|
|
|
.OfType<Button>() |
|
|
|
.Template() |
|
|
|
.Name("border") |
|
|
|
.Class("foo"); |
|
|
|
|
|
|
|
var border = (Border)((IVisual)control).VisualChildren.Single(); |
|
|
|
var values = new List<bool>(); |
|
|
|
var match = selector.Match(border); |
|
|
|
|
|
|
|
Assert.Equal(SelectorMatchResult.Sometimes, match.Result); |
|
|
|
match.Activator.Subscribe(x => values.Add(x)); |
|
|
|
|
|
|
|
Assert.Equal(new[] { false }, values); |
|
|
|
border.Classes.AddRange(new[] { "foo" }); |
|
|
|
Assert.Equal(new[] { false, true }, values); |
|
|
|
border.Classes.Remove("foo"); |
|
|
|
Assert.Equal(new[] { false, true, false }, values); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void TargetType_OfType() |
|
|
|
{ |
|
|
|
|