diff --git a/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs b/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs index 4cbe11c278d2..b7291125d35a 100644 --- a/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs +++ b/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs @@ -136,7 +136,6 @@ internal static IMauiHandlersCollection AddControlsHandlers(this IMauiHandlersCo handlersCollection.AddHandler(); handlersCollection.AddHandler(); handlersCollection.AddHandler(); - handlersCollection.AddHandler(); handlersCollection.AddHandler(); handlersCollection.AddHandler(); handlersCollection.AddHandler(); @@ -163,6 +162,18 @@ internal static IMauiHandlersCollection AddControlsHandlers(this IMauiHandlersCo } #else handlersCollection.AddHandler(); +#endif +#if ANDROID + if (RuntimeFeature.IsMaterial3Enabled) + { + handlersCollection.AddHandler(); + } + else + { + handlersCollection.AddHandler(); + } +#else + handlersCollection.AddHandler(); #endif handlersCollection.AddHandler(); handlersCollection.AddHandler(); diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3FontImageWithFontColorGreen.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3FontImageWithFontColorGreen.png new file mode 100644 index 000000000000..da24642bdfc3 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3FontImageWithFontColorGreen.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3FontImageWithFontSize.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3FontImageWithFontSize.png new file mode 100644 index 000000000000..201d93ac51d2 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3FontImageWithFontSize.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithFileSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithFileSource.png new file mode 100644 index 000000000000..ba26e5fe5861 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithFileSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithFontImageSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithFontImageSource.png new file mode 100644 index 000000000000..7910b04191c1 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithFontImageSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithStreamSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithStreamSource.png new file mode 100644 index 000000000000..6288410f5c4c Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithStreamSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithUriSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithUriSource.png new file mode 100644 index 000000000000..a7e374890fa2 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFillWithUriSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithFileSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithFileSource.png new file mode 100644 index 000000000000..9daee150f1ed Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithFileSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithFontImageSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithFontImageSource.png new file mode 100644 index 000000000000..bee9ef704f18 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithFontImageSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithStreamSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithStreamSource.png new file mode 100644 index 000000000000..c855d20c7265 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithStreamSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithUriSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithUriSource.png new file mode 100644 index 000000000000..235d60955c01 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_AspectFitWithUriSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithFileSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithFileSource.png new file mode 100644 index 000000000000..a90a629a5580 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithFileSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithFontImageSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithFontImageSource.png new file mode 100644 index 000000000000..68171cb80841 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithFontImageSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithStreamSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithStreamSource.png new file mode 100644 index 000000000000..045114bd0918 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithStreamSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithUriSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithUriSource.png new file mode 100644 index 000000000000..24effaa88f6e Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_CenterWithUriSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithFileSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithFileSource.png new file mode 100644 index 000000000000..4c6edc94d89d Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithFileSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithFontImageSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithFontImageSource.png new file mode 100644 index 000000000000..d76ceb80c1a5 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithFontImageSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithStreamSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithStreamSource.png new file mode 100644 index 000000000000..55f16403145d Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithStreamSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithUriSource.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithUriSource.png new file mode 100644 index 000000000000..148152222b2e Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageAspect_FillWithUriSource.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageFlowDirectionRTL.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageFlowDirectionRTL.png new file mode 100644 index 000000000000..3e8d213e4a05 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageFlowDirectionRTL.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageWithShadow.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageWithShadow.png new file mode 100644 index 000000000000..d8dcd9488b5c Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android-notch-36/VerifyMaterial3ImageWithShadow.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/Material3ImageFeatureTests.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/Material3ImageFeatureTests.cs new file mode 100644 index 000000000000..08bf2ca0374c --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/Material3ImageFeatureTests.cs @@ -0,0 +1,356 @@ +#if ANDROID +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests; + +public class Material3ImageFeatureTests : _GalleryUITest +{ + public const string ImageFeatureMatrix = "Image Feature Matrix"; + public const string Options = "Options"; + public const string Apply = "Apply"; + public const string ImageAspectFit = "ImageAspectFit"; + public const string ImageAspectFill = "ImageAspectFill"; + public const string ImageFill = "ImageFill"; + public const string ImageCenter = "ImageCenter"; + public const string SourceTypeFile = "SourceTypeFile"; + public const string SourceTypeFontImage = "SourceTypeFontImage"; + public const string SourceTypeStream = "SourceTypeStream"; + public const string SourceTypeUri = "SourceTypeUri"; + public const string IsVisibleFalseRadio = "IsVisibleFalseRadio"; + public const string FlowDirectionRTL = "FlowDirectionRTL"; + public const string ShadowCheckBox = "ShadowCheckBox"; + public const string IsAnimationTrue = "IsAnimationTrue"; + public const string IsAnimationFalse = "IsAnimationFalse"; + + public override string GalleryPageName => ImageFeatureMatrix; + + public Material3ImageFeatureTests(TestDevice device) + : base(device) + { + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_AspectFitWithFileSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageAspectFit); + App.Tap(ImageAspectFit); + App.WaitForElement(SourceTypeFile); + App.Tap(SourceTypeFile); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_AspectFitWithUriSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageAspectFit); + App.Tap(ImageAspectFit); + App.WaitForElement(SourceTypeUri); + App.Tap(SourceTypeUri); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl", timeout: TimeSpan.FromSeconds(3)); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_AspectFitWithStreamSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageAspectFit); + App.Tap(ImageAspectFit); + App.WaitForElement(SourceTypeStream); + App.Tap(SourceTypeStream); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_AspectFitWithFontImageSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageAspectFit); + App.Tap(ImageAspectFit); + App.WaitForElement(SourceTypeFontImage); + App.Tap(SourceTypeFontImage); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_AspectFillWithFileSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageAspectFill); + App.Tap(ImageAspectFill); + App.WaitForElement(SourceTypeFile); + App.Tap(SourceTypeFile); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_AspectFillWithUriSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageAspectFill); + App.Tap(ImageAspectFill); + App.WaitForElement(SourceTypeUri); + App.Tap(SourceTypeUri); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl", timeout: TimeSpan.FromSeconds(3)); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_AspectFillWithStreamSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageAspectFill); + App.Tap(ImageAspectFill); + App.WaitForElement(SourceTypeStream); + App.Tap(SourceTypeStream); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_AspectFillWithFontImageSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageAspectFill); + App.Tap(ImageAspectFill); + App.WaitForElement(SourceTypeFontImage); + App.Tap(SourceTypeFontImage); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_FillWithFileSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageFill); + App.Tap(ImageFill); + App.WaitForElement(SourceTypeFile); + App.Tap(SourceTypeFile); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_FillWithUriSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageFill); + App.Tap(ImageFill); + App.WaitForElement(SourceTypeUri); + App.Tap(SourceTypeUri); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl", timeout: TimeSpan.FromSeconds(3)); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_FillWithStreamSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageFill); + App.Tap(ImageFill); + App.WaitForElement(SourceTypeStream); + App.Tap(SourceTypeStream); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_FillWithFontImageSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageFill); + App.Tap(ImageFill); + App.WaitForElement(SourceTypeFontImage); + App.Tap(SourceTypeFontImage); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_CenterWithFileSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageCenter); + App.Tap(ImageCenter); + App.WaitForElement(SourceTypeFile); + App.Tap(SourceTypeFile); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_CenterWithUriSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageCenter); + App.Tap(ImageCenter); + App.WaitForElement(SourceTypeUri); + App.Tap(SourceTypeUri); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl", timeout: TimeSpan.FromSeconds(3)); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_CenterWithStreamSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageCenter); + App.Tap(ImageCenter); + App.WaitForElement(SourceTypeStream); + App.Tap(SourceTypeStream); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageAspect_CenterWithFontImageSource() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(ImageCenter); + App.Tap(ImageCenter); + App.WaitForElement(SourceTypeFontImage); + App.Tap(SourceTypeFontImage); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3FontImageWithFontColorGreen() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(SourceTypeFontImage); + App.Tap(SourceTypeFontImage); + App.WaitForElement("FontColorGreen"); + App.Tap("FontColorGreen"); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3FontImageWithFontSize() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(SourceTypeFontImage); + App.Tap(SourceTypeFontImage); + App.WaitForElement("EntryFontSize"); + App.ClearText("EntryFontSize"); + App.Tap("EntryFontSize"); + App.EnterText("EntryFontSize", "100"); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageWithShadow() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(SourceTypeFile); + App.Tap(SourceTypeFile); + App.WaitForElement(ShadowCheckBox); + App.Tap(ShadowCheckBox); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } + + [Test] + [Category(UITestCategories.Material3)] + public void VerifyMaterial3ImageFlowDirectionRTL() + { + App.WaitForElement(Options); + App.Tap(Options); + App.WaitForElement(SourceTypeFile); + App.Tap(SourceTypeFile); + App.WaitForElement(FlowDirectionRTL); + App.Tap(FlowDirectionRTL); + App.WaitForElement(Apply); + App.Tap(Apply); + App.WaitForElement("ImageControl"); + VerifyScreenshot(tolerance: 0.5, retryTimeout: TimeSpan.FromSeconds(2)); + } +} +#endif diff --git a/src/Core/src/Handlers/Image/ImageHandler2.Android.cs b/src/Core/src/Handlers/Image/ImageHandler2.Android.cs new file mode 100644 index 000000000000..9c526dce6957 --- /dev/null +++ b/src/Core/src/Handlers/Image/ImageHandler2.Android.cs @@ -0,0 +1,20 @@ +using Google.Android.Material.ImageView; + +namespace Microsoft.Maui.Handlers; + +// TODO: make it public in .net 11 +internal class ImageHandler2 : ImageHandler +{ + protected override ShapeableImageView CreatePlatformView() + { + var imageView = new ShapeableImageView(MauiMaterialContextThemeWrapper.Create(Context)); + + // Enable view bounds adjustment on measure. + // This allows the ImageView's OnMeasure method to account for the image's intrinsic + // aspect ratio during measurement, which gives us more useful values during constrained + // measurement passes. + imageView.SetAdjustViewBounds(true); + + return imageView; + } +} \ No newline at end of file diff --git a/src/Core/src/Platform/Android/ImageViewExtensions.cs b/src/Core/src/Platform/Android/ImageViewExtensions.cs index 52f8b28f2fcb..2d46f3fae4fd 100644 --- a/src/Core/src/Platform/Android/ImageViewExtensions.cs +++ b/src/Core/src/Platform/Android/ImageViewExtensions.cs @@ -18,7 +18,12 @@ public static void Clear(this ImageView imageView) public static void UpdateAspect(this ImageView imageView, IImage image) { - if (image.Aspect == Aspect.AspectFill) + // Apply bounds adjustment for Image control, but not for ImageButton control + // ShapeableImageView is used by both ImageButton and ImageHandler2 (Image control) + // Skip bounds adjustment only if it's a ShapeableImageView AND it's an IImageButton + bool shouldSkipBoundsAdjustment = imageView is ShapeableImageView && image is IImageButton; + + if (!shouldSkipBoundsAdjustment) { imageView.SetAdjustViewBounds(false); }