From b9d552dfd9f4dbd078eb902aba207d851bfbdeec Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Thu, 2 Jan 2025 15:48:18 +0530 Subject: [PATCH 1/9] fix commit --- .../src/Handlers/ScrollView/ScrollViewHandler.Android.cs | 7 +++++-- src/Core/src/Platform/Android/MauiScrollView.cs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs b/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs index 3a8a4b3e9741..78ec5b051ad1 100644 --- a/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs +++ b/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs @@ -97,8 +97,11 @@ void ScrollChange(object? sender, AndroidX.Core.Widget.NestedScrollView.ScrollCh return; } - VirtualView.VerticalOffset = Context.FromPixels(e.ScrollY); - VirtualView.HorizontalOffset = Context.FromPixels(e.ScrollX); + // Pass the native ScrollView's ScrollY to the virtual view to maintain the correct vertical offset. + VirtualView.VerticalOffset = Context.FromPixels(PlatformView.ScrollY); + // Need to pass the native HorizontalScrollView's ScrollX position to the virtual view to resolve + // the zero scroll offset issue since the framework returns an improper ScrollX value. + VirtualView.HorizontalOffset = Context.FromPixels(PlatformView._hScrollView?.ScrollX ?? e.ScrollX); } public static void MapContent(IScrollViewHandler handler, IScrollView scrollView) diff --git a/src/Core/src/Platform/Android/MauiScrollView.cs b/src/Core/src/Platform/Android/MauiScrollView.cs index e65995c380a9..b6b204b1c854 100644 --- a/src/Core/src/Platform/Android/MauiScrollView.cs +++ b/src/Core/src/Platform/Android/MauiScrollView.cs @@ -15,7 +15,7 @@ public class MauiScrollView : NestedScrollView, IScrollBarView, NestedScrollView { View? _content; - MauiHorizontalScrollView? _hScrollView; + internal MauiHorizontalScrollView? _hScrollView { get; private set; } bool _isBidirectional; ScrollOrientation _scrollOrientation = ScrollOrientation.Vertical; ScrollBarVisibility _defaultHorizontalScrollVisibility; From 89fc4655ecf2b968e1cf992c6d47c1238540c4d6 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Thu, 2 Jan 2025 16:40:37 +0530 Subject: [PATCH 2/9] fix updated as per comment --- .../ScrollView/ScrollViewHandler.Android.cs | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs b/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs index 78ec5b051ad1..a4bea488cd5c 100644 --- a/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs +++ b/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs @@ -97,11 +97,27 @@ void ScrollChange(object? sender, AndroidX.Core.Widget.NestedScrollView.ScrollCh return; } - // Pass the native ScrollView's ScrollY to the virtual view to maintain the correct vertical offset. - VirtualView.VerticalOffset = Context.FromPixels(PlatformView.ScrollY); - // Need to pass the native HorizontalScrollView's ScrollX position to the virtual view to resolve - // the zero scroll offset issue since the framework returns an improper ScrollX value. - VirtualView.HorizontalOffset = Context.FromPixels(PlatformView._hScrollView?.ScrollX ?? e.ScrollX); + int scrollX = e.ScrollX; + int scrollY = e.ScrollY; + + if (VirtualView.Orientation == ScrollOrientation.Both) + { + if (scrollX == 0 && PlatformView._hScrollView is not null) + { + // Need to pass the native HorizontalScrollView's ScrollX position to the virtual view to resolve + // the zero scroll offset issue since the framework returns an improper ScrollX value. + scrollX = PlatformView._hScrollView.ScrollX; + } + + if (scrollY == 0) + { + // Pass the native ScrollView's ScrollY to the virtual view to maintain the correct vertical offset. + scrollY = PlatformView.ScrollY; + } + } + + VirtualView.HorizontalOffset = context.FromPixels(scrollX); + VirtualView.VerticalOffset = context.FromPixels(scrollY); } public static void MapContent(IScrollViewHandler handler, IScrollView scrollView) From 557239f4f580bf3c45b02f8118adb3827d415dc0 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Thu, 2 Jan 2025 17:27:16 +0530 Subject: [PATCH 3/9] fix code updated as per suggestiion --- src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs | 4 ++-- src/Core/src/Platform/Android/MauiScrollView.cs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs b/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs index a4bea488cd5c..20ddfcb5733a 100644 --- a/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs +++ b/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs @@ -102,11 +102,11 @@ void ScrollChange(object? sender, AndroidX.Core.Widget.NestedScrollView.ScrollCh if (VirtualView.Orientation == ScrollOrientation.Both) { - if (scrollX == 0 && PlatformView._hScrollView is not null) + if (scrollX == 0) { // Need to pass the native HorizontalScrollView's ScrollX position to the virtual view to resolve // the zero scroll offset issue since the framework returns an improper ScrollX value. - scrollX = PlatformView._hScrollView.ScrollX; + scrollX = PlatformView.HorizontalScrollOffset; } if (scrollY == 0) diff --git a/src/Core/src/Platform/Android/MauiScrollView.cs b/src/Core/src/Platform/Android/MauiScrollView.cs index b6b204b1c854..ed6cfda04357 100644 --- a/src/Core/src/Platform/Android/MauiScrollView.cs +++ b/src/Core/src/Platform/Android/MauiScrollView.cs @@ -15,7 +15,7 @@ public class MauiScrollView : NestedScrollView, IScrollBarView, NestedScrollView { View? _content; - internal MauiHorizontalScrollView? _hScrollView { get; private set; } + MauiHorizontalScrollView? _hScrollView; bool _isBidirectional; ScrollOrientation _scrollOrientation = ScrollOrientation.Vertical; ScrollBarVisibility _defaultHorizontalScrollVisibility; @@ -26,6 +26,7 @@ public class MauiScrollView : NestedScrollView, IScrollBarView, NestedScrollView internal float LastY { get; set; } internal bool ShouldSkipOnTouch; + internal int HorizontalScrollOffset => _hScrollView?.ScrollX ?? 0; public MauiScrollView(Context context) : base(context) { From 254cbb3143d088edb6df24297acd4d486e5b99ba Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Fri, 3 Jan 2025 09:37:57 +0530 Subject: [PATCH 4/9] ui test case modification --- .../TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs | 2 +- .../Tests/Issues/Bugzilla/Bugzilla41415.cs | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs index 143433087036..692a2011a460 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs @@ -1,6 +1,6 @@ namespace Maui.Controls.Sample.Issues { - [Issue(IssueTracker.None, 41415, "ScrollX and ScrollY values are not consistent with iOS", PlatformAffected.Android)] + [Issue(IssueTracker.None, 41415, "ScrollX and ScrollY Values Are Not Consistent in 'ScrollOrientation.Both' Mode", PlatformAffected.Android)] public class Bugzilla41415 : ContentPage { const string ButtonId = "ClickId"; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs index 9ee6f950378a..bfabfaf45bcb 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs @@ -1,7 +1,4 @@ -#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_WINDOWS -// On Android ScrollY and ScrollX values are resetted, Issue: https://github.com/dotnet/maui/issues/26747 -// On Windows tests are failing in CI, but not locally. Need to investigate more. -using NUnit.Framework; +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -18,7 +15,7 @@ public Bugzilla41415UITests(TestDevice device) { } - public override string Issue => "ScrollX and ScrollY values are not consistent with iOS"; + public override string Issue => "ScrollX and ScrollY Values Are Not Consistent in 'ScrollOrientation.Both' Mode"; [Test] public void Bugzilla41415Test() @@ -39,4 +36,3 @@ public void Bugzilla41415Test() } } } -#endif From a9974903fd78df927ae33ba6b9fde80c85b659f4 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Fri, 3 Jan 2025 09:39:28 +0530 Subject: [PATCH 5/9] ui test name modifications --- .../tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs | 2 +- .../Tests/Issues/Bugzilla/Bugzilla41415.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs index 692a2011a460..113b648c9865 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs @@ -1,6 +1,6 @@ namespace Maui.Controls.Sample.Issues { - [Issue(IssueTracker.None, 41415, "ScrollX and ScrollY Values Are Not Consistent in 'ScrollOrientation.Both' Mode", PlatformAffected.Android)] + [Issue(IssueTracker.None, 41415, "ScrollX and ScrollY Values are not consistent in 'ScrollOrientation.Both' Mode", PlatformAffected.Android)] public class Bugzilla41415 : ContentPage { const string ButtonId = "ClickId"; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs index bfabfaf45bcb..1ed3c90fc160 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs @@ -15,7 +15,7 @@ public Bugzilla41415UITests(TestDevice device) { } - public override string Issue => "ScrollX and ScrollY Values Are Not Consistent in 'ScrollOrientation.Both' Mode"; + public override string Issue => "ScrollX and ScrollY Values are not consistent in 'ScrollOrientation.Both' Mode"; [Test] public void Bugzilla41415Test() From 6a09e040d3b700e3cf7e9019c8b16666e0f9d199 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Fri, 3 Jan 2025 09:42:22 +0530 Subject: [PATCH 6/9] ui test case title changes --- .../tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs | 2 +- .../Tests/Issues/Bugzilla/Bugzilla41415.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs index 113b648c9865..14e81ee22a68 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs @@ -1,6 +1,6 @@ namespace Maui.Controls.Sample.Issues { - [Issue(IssueTracker.None, 41415, "ScrollX and ScrollY Values are not consistent in 'ScrollOrientation.Both' Mode", PlatformAffected.Android)] + [Issue(IssueTracker.None, 41415, "ScrollX and ScrollY values at the scrolled event are not consistent in 'ScrollOrientation.Both' mode", PlatformAffected.Android)] public class Bugzilla41415 : ContentPage { const string ButtonId = "ClickId"; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs index 1ed3c90fc160..4220da5981ff 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs @@ -15,7 +15,7 @@ public Bugzilla41415UITests(TestDevice device) { } - public override string Issue => "ScrollX and ScrollY Values are not consistent in 'ScrollOrientation.Both' Mode"; + public override string Issue => "ScrollX and ScrollY values at the scrolled event are not consistent in 'ScrollOrientation.Both' mode"; [Test] public void Bugzilla41415Test() From 4ea0f30d0b670c47dd5167e87940011e9631cc3e Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Fri, 3 Jan 2025 09:45:25 +0530 Subject: [PATCH 7/9] ui test title changes --- .../tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs | 2 +- .../Tests/Issues/Bugzilla/Bugzilla41415.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs index 14e81ee22a68..6d8a8422c548 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs @@ -1,6 +1,6 @@ namespace Maui.Controls.Sample.Issues { - [Issue(IssueTracker.None, 41415, "ScrollX and ScrollY values at the scrolled event are not consistent in 'ScrollOrientation.Both' mode", PlatformAffected.Android)] + [Issue(IssueTracker.None, 41415, "ScrollX and ScrollY values at the ScrollView.Scrolled event are not consistent in ScrollOrientation.Both mode", PlatformAffected.Android)] public class Bugzilla41415 : ContentPage { const string ButtonId = "ClickId"; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs index 4220da5981ff..1eb20f684ff2 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs @@ -15,7 +15,7 @@ public Bugzilla41415UITests(TestDevice device) { } - public override string Issue => "ScrollX and ScrollY values at the scrolled event are not consistent in 'ScrollOrientation.Both' mode"; + public override string Issue => "ScrollX and ScrollY values at the ScrollView.Scrolled event are not consistent in ScrollOrientation.Both mode"; [Test] public void Bugzilla41415Test() From 8707ef18358883c3a44b573bbbfdec0369eed6ae Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Fri, 3 Jan 2025 13:40:07 +0530 Subject: [PATCH 8/9] used already available context for platformview --- .../Handlers/ScrollView/ScrollViewHandler.Android.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs b/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs index 20ddfcb5733a..b5651aa46246 100644 --- a/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs +++ b/src/Core/src/Handlers/ScrollView/ScrollViewHandler.Android.cs @@ -90,9 +90,9 @@ static int AdjustSpecForAlignment(int measureSpec, Primitives.LayoutAlignment al void ScrollChange(object? sender, AndroidX.Core.Widget.NestedScrollView.ScrollChangeEventArgs e) { - var context = (sender as View)?.Context; + var platformView = sender as MauiScrollView; - if (context == null) + if (platformView?.Context is null) { return; } @@ -106,18 +106,18 @@ void ScrollChange(object? sender, AndroidX.Core.Widget.NestedScrollView.ScrollCh { // Need to pass the native HorizontalScrollView's ScrollX position to the virtual view to resolve // the zero scroll offset issue since the framework returns an improper ScrollX value. - scrollX = PlatformView.HorizontalScrollOffset; + scrollX = platformView.HorizontalScrollOffset; } if (scrollY == 0) { // Pass the native ScrollView's ScrollY to the virtual view to maintain the correct vertical offset. - scrollY = PlatformView.ScrollY; + scrollY = platformView.ScrollY; } } - VirtualView.HorizontalOffset = context.FromPixels(scrollX); - VirtualView.VerticalOffset = context.FromPixels(scrollY); + VirtualView.HorizontalOffset = platformView.Context.FromPixels(scrollX); + VirtualView.VerticalOffset = platformView.Context.FromPixels(scrollY); } public static void MapContent(IScrollViewHandler handler, IScrollView scrollView) From 65ac84438d52dfa5773db41efe545ef33856d30d Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Mon, 6 Jan 2025 12:56:39 +0530 Subject: [PATCH 9/9] Removed redundant checks on test case Removed redundant labels and check logic from Bugzilla41415Test to simplify the test case also it is getting failed in CI windows machine. --- .../Issues/Bugzilla/Bugzilla41415.cs | 35 +------------------ .../Tests/Issues/Bugzilla/Bugzilla41415.cs | 4 --- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs index 6d8a8422c548..277bdad2a0f1 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla41415.cs @@ -7,8 +7,6 @@ public class Bugzilla41415 : ContentPage const string ButtonText = "Click Me"; float _x; - bool _didXChange, _didYChange; - public Bugzilla41415() { var grid = new Grid @@ -32,8 +30,6 @@ public Bugzilla41415() var labelx = new Label(); var labely = new Label(); - var labelz = new Label(); - var labela = new Label(); var scrollView = new ScrollView { @@ -47,25 +43,6 @@ public Bugzilla41415() { labelx.Text = $"x: {(int)Math.Round(args.ScrollX)}"; labely.Text = $"y: {(int)Math.Round(args.ScrollY)}"; - - // first and second taps - if (_x == 0) - { - if (Math.Round(args.ScrollX) != 0 && Math.Round(args.ScrollX) != 100) - _didXChange = true; - if (Math.Round(args.ScrollY) != 0 && Math.Round(args.ScrollY) != 100) - _didYChange = true; - } - else if (_x == 100) - { - if (Math.Round(args.ScrollX) != _x && Math.Round(args.ScrollX) != _x + 100) - _didXChange = true; - if (Math.Round(args.ScrollY) != 100) - _didYChange = true; - } - - labelz.Text = "z: " + _didXChange.ToString(); - labela.Text = "a: " + _didYChange.ToString(); }; var button = new Button { AutomationId = ButtonId, Text = ButtonText }; @@ -74,10 +51,6 @@ public Bugzilla41415() // reset labelx.Text = null; labely.Text = null; - labelz.Text = null; - labela.Text = null; - _didXChange = false; - _didYChange = false; await scrollView.ScrollToAsync(_x + 100, 100, true); _x = 100; @@ -86,16 +59,12 @@ public Bugzilla41415() Grid.SetRow(button, 0); Grid.SetRow(labelx, 1); Grid.SetRow(labely, 2); - Grid.SetRow(labelz, 3); - Grid.SetRow(labela, 4); - Grid.SetRow(scrollView, 5); + Grid.SetRow(scrollView, 3); Content = new Grid { RowDefinitions = new RowDefinitionCollection { - new RowDefinition { Height = GridLength.Auto }, - new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, @@ -106,8 +75,6 @@ public Bugzilla41415() button, labelx, labely, - labelz, - labela, scrollView, } }; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs index 1eb20f684ff2..1c53fe8eabad 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla41415.cs @@ -25,13 +25,9 @@ public void Bugzilla41415Test() App.WaitForElement(ButtonId); App.WaitForElementTillPageNavigationSettled("x: 100"); App.WaitForElementTillPageNavigationSettled("y: 100"); - App.WaitForElement("z: True"); - App.WaitForElement("a: True"); App.Tap(ButtonId); App.WaitForElement(ButtonId); App.WaitForElementTillPageNavigationSettled("y: 100"); - App.WaitForElement("z: True"); - App.WaitForElement("a: False"); App.WaitForElementTillPageNavigationSettled("x: 200"); } }