unoplatform / uno.toolkit.ui

A set of custom controls for the WinUI and the Uno Platform not offered out of the box by WinUI, such as Card, TabBar, NavigationBar, etc.
https://platform.uno/
MIT License
82 stars 27 forks source link

[AutoLayout] restore disabled When_Hug_With_CounterAlignment test #1203

Open Xiaoy312 opened 1 month ago

Xiaoy312 commented 1 month ago

this test is failing for android since we upgraded from 5.0.154 to 5.4.0-dev.738

rajamatt commented 3 weeks ago

@kazo0 The test starts failing with 5.2.80

Expected value to approximate 0.0 +/- 1.0, but 106.47618865966797 differed by 106.47618865966797.

Full test case

<test-run id="b2224ae4-e526-4089-8bc0-74b754d79eb8" name="Runtime Tests" testcasecount="3" result="Failed" time="0" total="3" errors="0" passed="2" failed="1" inconclusive="0" skipped="0" asserts="0" run-date="2024-08-16" start-time="11:34:15" end-time="11:34:15">
  <test-suite type="Assembly" name="Uno.Toolkit.RuntimeTests">
    <environment machine-name="localhost" platform="n/a" />
    <test-suite type="TestFixture" name="b2224ae4-e526-4089-8bc0-74b754d79eb8" executed="true" testcasecount="3" result="Failed" time="0" total="3" errors="0" passed="2" failed="1" inconclusive="0" skipped="0" asserts="0">
      <test-case name="When_Hug_With_CounterAlignment()" fullname="When_Hug_With_CounterAlignment()" duration="0.4237915" time="0" result="Failed">
        <failure>
          <message>Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Expected value to approximate 0.0 +/- 1.0, but 106.47618865966797 differed by 106.47618865966797.
   at FluentAssertions.Execution.LateBoundTestFramework.Throw(String message) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\LateBoundTestFramework.cs:line 21
   at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\TestFrameworkProvider.cs:line 40
   at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\DefaultAssertionStrategy.cs:line 29
   at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\AssertionScope.cs:line 223
   at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\AssertionScope.cs:line 196
   at FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\AssertionScope.cs:line 238
   at FluentAssertions.NumericAssertionsExtensions.FailIfDifferenceOutsidePrecision[Double](Boolean differenceWithinPrecision, NumericAssertions`1 parent, Double expectedValue, Double precision, Double actualDifference, String because, Object[] becauseArgs) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\NumericAssertionsExtensions.cs:line 959
   at FluentAssertions.NumericAssertionsExtensions.BeApproximately(NumericAssertions`1 parent, Double expectedValue, Double precision, String because, Object[] becauseArgs) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\NumericAssertionsExtensions.cs:line 848
   at Uno.Toolkit.RuntimeTests.Tests.AutoLayoutTest.When_Hug_With_CounterAlignment() in C:\P\uno.toolkit.ui\src\Uno.Toolkit.RuntimeTests\Tests\AutoLayoutTest.cs:line 772
   at Uno.UI.RuntimeTests.UnitTestsControl.&lt;&gt;c__DisplayClass66_0.&lt;&lt;ExecuteTestsForInstance&gt;g__WaitResult|3&gt;d.MoveNext() in C:\Users\MatthewRajala\.nuget\packages\uno.ui.runtimetests.engine\0.25.0-dev.99\src\Engine\UI\UnitTestsControl.cs:line 1034
--- End of stack trace from previous location ---
   at Uno.UI.RuntimeTests.UnitTestsControl.&lt;&gt;c__DisplayClass66_3.&lt;&lt;ExecuteTestsForInstance&gt;g__DoInvoke|9&gt;d.MoveNext() in C:\Users\MatthewRajala\.nuget\packages\uno.ui.runtimetests.engine\0.25.0-dev.99\src\Engine\UI\UnitTestsControl.cs:line 910
--- End of stack trace from previous location ---
   at Uno.UI.RuntimeTests.UnitTestsControl.&lt;&gt;c__DisplayClass68_0.&lt;&lt;ExecuteOnDispatcher&gt;b__0&gt;d.MoveNext() in C:\Users\MatthewRajala\.nuget\packages\uno.ui.runtimetests.engine\0.25.0-dev.99\src\Engine\UI\UnitTestsControl.cs:line 1055
--- End of stack trace from previous location ---
   at Uno.UI.RuntimeTests.UnitTestsControl.ExecuteOnDispatcher(Func`1 asyncAction, CancellationToken ct) in C:\Users\MatthewRajala\.nuget\packages\uno.ui.runtimetests.engine\0.25.0-dev.99\src\Engine\UI\UnitTestsControl.cs:line 1065
   at Uno.UI.RuntimeTests.UnitTestsControl.&lt;&gt;c__DisplayClass66_2.&lt;&lt;ExecuteTestsForInstance&gt;g__InvokeTestMethod|5&gt;d.MoveNext() in C:\Users\MatthewRajala\.nuget\packages\uno.ui.runtimetests.engine\0.25.0-dev.99\src\Engine\UI\UnitTestsControl.cs:line 899</message>
        </failure>
      </test-case>
    </test-suite>
  </test-suite>
</test-run>
kazo0 commented 3 weeks ago

@rajamatt it looks like 5.2.80 is the first stable version that this started failing on. But it'll be easier to narrow down the cause if we can find the first -dev.XXX version of 5.2 that this started happening with. So I tested 5.1.104 and it works and it fails on 5.2.0-dev.2114 so somewhere in one of the 5.2.0-dev.XXX builds is where it started to fail. Can you try and narrow it down and find the specific build?

kazo0 commented 3 weeks ago

Ah this is because of https://github.com/unoplatform/uno.toolkit.ui/issues/1051. There is an outstanding issue if the AutoLayout is the absolute root element of the application Window. Which is not a common scenario outside of UI Tests that are replacing the window content. For now we can workaround this by wrapping the AutoLayout in a Border.