|
| 1 | +using System.Collections.Generic; |
| 2 | +using System.Linq; |
| 3 | +using System.Threading.Tasks; |
| 4 | +using Microsoft.AspNetCore.Components.WebView.Maui; |
| 5 | +using Microsoft.Extensions.DependencyInjection; |
| 6 | +using Microsoft.Extensions.Logging; |
| 7 | +using Microsoft.Maui.MauiBlazorWebView.DeviceTests.Components; |
| 8 | +using Xunit; |
| 9 | + |
| 10 | +namespace Microsoft.Maui.MauiBlazorWebView.DeviceTests.Elements; |
| 11 | + |
| 12 | +public partial class BlazorWebViewTests |
| 13 | +{ |
| 14 | +#if IOS || MACCATALYST |
| 15 | + [Fact] |
| 16 | + public async Task BlazorWebViewScrollBounceDisabledByDefault() |
| 17 | + { |
| 18 | + EnsureHandlerCreated(additionalCreationActions: appBuilder => |
| 19 | + { |
| 20 | + appBuilder.Services.AddMauiBlazorWebView(); |
| 21 | + }); |
| 22 | + |
| 23 | + var bwv = new BlazorWebViewWithCustomFiles |
| 24 | + { |
| 25 | + HostPage = "wwwroot/index.html", |
| 26 | + CustomFiles = new Dictionary<string, string> |
| 27 | + { |
| 28 | + { "index.html", TestStaticFilesContents.DefaultMauiIndexHtmlContent }, |
| 29 | + }, |
| 30 | + }; |
| 31 | + bwv.RootComponents.Add(new RootComponent { ComponentType = typeof(NoOpComponent), Selector = "#app", }); |
| 32 | + |
| 33 | + await InvokeOnMainThreadAsync(async () => |
| 34 | + { |
| 35 | + var bwvHandler = CreateHandler<BlazorWebViewHandler>(bwv); |
| 36 | + var platformWebView = bwvHandler.PlatformView; |
| 37 | + await WebViewHelpers.WaitForWebViewReady(platformWebView); |
| 38 | + |
| 39 | + // Verify that bounce scrolling is disabled by default to make apps feel more native |
| 40 | + Assert.False(platformWebView.ScrollView.Bounces); |
| 41 | + Assert.False(platformWebView.ScrollView.AlwaysBounceVertical); |
| 42 | + Assert.False(platformWebView.ScrollView.AlwaysBounceHorizontal); |
| 43 | + }); |
| 44 | + } |
| 45 | +#endif |
| 46 | +} |
0 commit comments