Skip to content
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25943.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue25943"
xmlns:controls="clr-namespace:Maui.Controls.Sample.Issues"
x:DataType="controls:_25943MainPageViewModel">
<VerticalStackLayout Padding="30,0" Spacing="25">
<DatePicker HorizontalOptions="Center" VerticalOptions="Center" AutomationId="DatePicker" Date="{Binding Date}" MaximumDate="{Binding MaxDate}" MinimumDate="{Binding MinDate}"></DatePicker>
</VerticalStackLayout>
</ContentPage>
66 changes: 66 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25943.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System.ComponentModel;

namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Github, 25943, "[Android] DatePicker Graphical Bug", PlatformAffected.Android)]
public partial class Issue25943 : ContentPage
{
public Issue25943()
{
BindingContext = new _25943MainPageViewModel();
InitializeComponent();
}
}

public class _25943MainPageViewModel : INotifyPropertyChanged
{
private DateTime _date = new DateTime(2024, 1, 1);
public DateTime Date
{
get => _date;
set
{
if (_date != value)
{
_date = value;
OnPropertyChanged(nameof(Date));
}
}
}

private DateTime _maxDate = new DateTime(2024, 2, 29);
public DateTime MaxDate
{
get => _maxDate;
set
{
if (_maxDate != value)
{
_maxDate = value;
OnPropertyChanged(nameof(MaxDate));
}
}
}

private DateTime _minDate = new DateTime(2023, 11, 1);
public DateTime MinDate
{
get => _minDate;
set
{
if (_minDate != value)
{
_minDate = value;
OnPropertyChanged(nameof(MinDate));
}
}
}

public event PropertyChangedEventHandler PropertyChanged;

protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_IOS //VerifyScreenShot() is not implemented on Mac, and the DatePicker UI behaves differently on iOS and doesn't have a DatePickerDialog like on other platforms.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue25943 : _IssuesUITest
{
public Issue25943(TestDevice device) : base(device)
{
}

public override string Issue => "[Android] DatePicker Graphical Bug";

[Test]
[Category(UITestCategories.DatePicker)]
public void DatePickerShouldDisplayProperSelectedDate()
{
App.WaitForElement("DatePicker");
App.Tap("DatePicker");
#if ANDROID
App.Tap(AppiumQuery.ByXPath("//android.widget.ImageButton[@content-desc='Next month']"));
#elif WINDOWS
App.Tap("NextButton");
#endif
VerifyScreenshot();
}
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override MauiDatePicker CreatePlatformView()
var date = VirtualView?.Date;

if (date != null)
_dialog = CreateDatePickerDialog(date.Value.Year, date.Value.Month, date.Value.Day);
_dialog = CreateDatePickerDialog(date.Value.Year, date.Value.Month - 1, date.Value.Day);

return mauiDatePicker;
}
Expand Down
Loading