Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a test to validate loading images #20147

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample
{
internal class ImageLoadingGalleryPage : CoreGalleryBasePage
{
protected override void Build()
{
Add(Test.ImageLoading.FromBundleSvg, ImageSource.FromFile("dotnet_bot.png"));

Add(Test.ImageLoading.FromBundlePng, ImageSource.FromFile("groceries.png"));

Add(Test.ImageLoading.FromBundleJpg, ImageSource.FromFile("oasis.jpg"));

Add(Test.ImageLoading.FromBundleGif, ImageSource.FromFile("animated_heart.gif"));
}

ViewContainer<Image> Add(Test.ImageLoading test, ImageSource image) =>
Add(test, new Image
{
Source = image,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Start
});

ViewContainer<Image> Add(Test.ImageLoading test, Image image) =>
Add(new ViewContainer<Image>(test, image));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public override string ToString()
new GalleryPageFactory(() => new DragAndDropGallery(), "Drag and Drop Gallery"),
new GalleryPageFactory(() => new GestureRecognizerGallery(), "Gesture Recognizer Gallery"),
new GalleryPageFactory(() => new InputTransparencyGalleryPage(), "Input Transparency Gallery"),
new GalleryPageFactory(() => new ImageLoadingGalleryPage(), "Image Loading Gallery"),
// Elements
new GalleryPageFactory(() => new ActivityIndicatorCoreGalleryPage(), "ActivityIndicator Gallery"),
new GalleryPageFactory(() => new BoxViewCoreGalleryPage(), "Box Gallery"),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/Controls/samples/Controls.Sample.UITests/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,14 @@ public enum CarouselView
IsBounceEnabled
}

public enum ImageLoading
{
FromBundleSvg,
FromBundlePng,
FromBundleJpg,
FromBundleGif,
}

public enum InputTransparency
{
Default,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Maui.Controls.Sample;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.AppiumTests
{
public class ImageLoadingGalleryTests : CoreGalleryBasePageTest
{
public ImageLoadingGalleryTests(TestDevice device)
: base(device)
{
}

protected override void NavigateToGallery()
{
App.NavigateToGallery("Image Loading Gallery");
}

[Test]
public void LoadAndVerifyPng() => LoadAndVerify(Test.ImageLoading.FromBundlePng);
mattleibow marked this conversation as resolved.
Show resolved Hide resolved

[Test]
public void LoadAndVerifyJpg() => LoadAndVerify(Test.ImageLoading.FromBundleJpg);

[Test]
public void LoadAndVerifyGif() => LoadAndVerify(Test.ImageLoading.FromBundleGif);

[Test]
public void LoadAndVerifySvg() => LoadAndVerify(Test.ImageLoading.FromBundleSvg);

void LoadAndVerify(Test.ImageLoading test)
{
var remote = new EventViewContainerRemote(UITestContext, test);
remote.GoTo(test.ToString());

App.WaitForElement($"{test}VisualElement");
Thread.Sleep(1000); // android has some button animations that need to finish

VerifyScreenshot();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading