-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(Style): Implement Style.IsSealed to allow for flattened lists ca…
…ching This update also removes the use of dictionary enumeration for setters application, and delegate to apply the setters.
- Loading branch information
1 parent
669f4d3
commit 1970c77
Showing
11 changed files
with
240 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Uno.UI.Tests.App.Xaml; | ||
using Uno.UI.Tests.Helpers; | ||
using Windows.Foundation; | ||
using Windows.UI; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Media; | ||
|
||
namespace Uno.UI.Tests.Windows_UI_Xaml | ||
{ | ||
[TestClass] | ||
public class Given_Style | ||
{ | ||
[TestInitialize] | ||
public void Init() | ||
{ | ||
UnitTestsApp.App.EnsureApplication(); | ||
} | ||
|
||
[TestMethod] | ||
public void When_Sealed_Style_Add_Setter() | ||
{ | ||
var SUT = new Style(typeof(Control)); | ||
|
||
SUT.Setters.Add(new Setter(Control.IsEnabledProperty, true)); | ||
|
||
SUT.Seal(); | ||
|
||
Assert.IsTrue(SUT.IsSealed); | ||
Assert.IsTrue(SUT.Setters.IsSealed); | ||
Assert.IsTrue(SUT.Setters[0].IsSealed); | ||
|
||
Assert.ThrowsException<InvalidOperationException>(() => SUT.Setters.Add(new Setter(Control.IsHitTestVisibleProperty, true))); | ||
} | ||
|
||
[TestMethod] | ||
public void When_Sealed_Style_Remove() | ||
{ | ||
var SUT = new Style(typeof(Control)); | ||
|
||
SUT.Setters.Add(new Setter(Control.IsEnabledProperty, true)); | ||
|
||
SUT.Seal(); | ||
|
||
Assert.IsTrue(SUT.IsSealed); | ||
Assert.IsTrue(SUT.Setters.IsSealed); | ||
Assert.IsTrue(SUT.Setters[0].IsSealed); | ||
|
||
SUT.Setters.Clear(); | ||
} | ||
|
||
[TestMethod] | ||
public void When_Sealed_Style_Setter_Update() | ||
{ | ||
var SUT = new Style(typeof(Control)); | ||
|
||
Setter s; | ||
SUT.Setters.Add(s = new Setter(Control.IsEnabledProperty, true)); | ||
|
||
SUT.Seal(); | ||
|
||
Assert.IsTrue(SUT.IsSealed); | ||
Assert.IsTrue(SUT.Setters.IsSealed); | ||
Assert.IsTrue(SUT.Setters[0].IsSealed); | ||
|
||
Assert.ThrowsException<InvalidOperationException>(() => s.Value = null); | ||
} | ||
|
||
[TestMethod] | ||
public void When_Sealed_Style_BasedOn_Sealed() | ||
{ | ||
var SUT = new Style(typeof(Control)); | ||
SUT.Setters.Add(new Setter(Control.IsEnabledProperty, true)); | ||
|
||
var SUT2 = new Style(typeof(Control)) { BasedOn = SUT }; | ||
SUT2.Setters.Add(new Setter(Control.IsEnabledProperty, true)); | ||
|
||
SUT2.Seal(); | ||
|
||
Assert.IsTrue(SUT.IsSealed); | ||
Assert.IsTrue(SUT.Setters.IsSealed); | ||
Assert.IsTrue(SUT.Setters[0].IsSealed); | ||
|
||
Assert.IsTrue(SUT2.IsSealed); | ||
Assert.IsTrue(SUT2.Setters.IsSealed); | ||
Assert.IsTrue(SUT2.Setters[0].IsSealed); | ||
} | ||
|
||
[TestMethod] | ||
public void When_Sealed_Style_On_Apply() | ||
{ | ||
var SUT = new Style(typeof(Control)); | ||
SUT.Setters.Add(new Setter(Control.IsEnabledProperty, true)); | ||
|
||
var SUT2 = new Style(typeof(Control)) { BasedOn = SUT }; | ||
SUT2.Setters.Add(new Setter(Control.IsEnabledProperty, true)); | ||
|
||
SUT2.Seal(); | ||
|
||
Control control = new(); | ||
control.Style = SUT2; | ||
|
||
Assert.IsTrue(SUT.IsSealed); | ||
Assert.IsTrue(SUT.Setters.IsSealed); | ||
Assert.IsTrue(SUT.Setters[0].IsSealed); | ||
|
||
Assert.IsTrue(SUT2.IsSealed); | ||
Assert.IsTrue(SUT2.Setters.IsSealed); | ||
Assert.IsTrue(SUT2.Setters[0].IsSealed); | ||
} | ||
} | ||
} |
13 changes: 2 additions & 11 deletions
13
src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml/SetterBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,13 @@ | ||
#pragma warning disable 108 // new keyword hiding | ||
#pragma warning disable 114 // new keyword hiding | ||
using System; | ||
|
||
namespace Windows.UI.Xaml | ||
{ | ||
#if false || false || false || false || false || false || false | ||
[global::Uno.NotImplemented] | ||
#endif | ||
public partial class SetterBase : global::Windows.UI.Xaml.DependencyObject | ||
{ | ||
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__ | ||
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")] | ||
public bool IsSealed | ||
{ | ||
get | ||
{ | ||
throw new global::System.NotImplementedException("The member bool SetterBase.IsSealed is not implemented in Uno."); | ||
} | ||
} | ||
#endif | ||
// Forced skipping of method Windows.UI.Xaml.SetterBase.IsSealed.get | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.