Skip to content

Commit

Permalink
fix: AutoSuggestBox Reason with inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
iury committed May 20, 2022
1 parent 3dbff07 commit 8d8686d
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,24 @@ public void PasswordBox_With_Description()
using var screenshot = TakeScreenshot("AutoSuggestBox Description", new ScreenshotOptions() { IgnoreInSnapshotCompare = true });
ImageAssert.HasColorAt(screenshot, autoSuggestBoxRect.X + autoSuggestBoxRect.Width / 2, autoSuggestBoxRect.Y + autoSuggestBoxRect.Height - 50, Color.Red);
}

[Test]
[AutoRetry]
[ActivePlatforms(Platform.iOS, Platform.Browser)] // Android not working currently. https://github.com/unoplatform/uno/issues/8836
public void AutoSuggestBox_Reason()
{
Run("UITests.Windows_UI_Xaml_Controls.AutoSuggestBoxTests.AutoSuggestBox_Reason", skipInitialScreenshot: true);
var SUT = _app.Marked("ReasonAutoSuggestBox");
_app.WaitForElement(SUT);

_app.FastTap("btnPopulate");
_app.WaitForText("txtConsole", "ProgrammaticChange");
//Entering Text as User
SUT.EnterText("m");
_app.WaitForText("txtConsole", "UserInput");

//Missing SuggestionChosen
//Uno UI Test does not support keyboard yet
}
}
}
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\AutoSuggestBoxTests\AutoSuggestBox_Reason.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\BitmapIconTests\BitmapIcon_Generic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -5338,6 +5342,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\AutoSuggestBoxTests\AutoSuggestBox_Icons.xaml.cs">
<DependentUpon>AutoSuggestBox_Icons.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\AutoSuggestBoxTests\AutoSuggestBox_Reason.xaml.cs">
<DependentUpon>AutoSuggestBox_Reason.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\AutoSuggestBoxTests\MeasuredBitmapIcon.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\BitmapIconTests\BitmapIcon_Sizing.xaml.cs">
<DependentUpon>BitmapIcon_Sizing.xaml</DependentUpon>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Page
x:Class="UITests.Windows_UI_Xaml_Controls.AutoSuggestBoxTests.AutoSuggestBox_Reason"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Windows_UI_Xaml_Controls.AutoSuggestBoxTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel>
<TextBlock x:Name="txtConsole"></TextBlock>
<Button Click="PopulateClick" x:Name="btnPopulate">Populate</Button>
<AutoSuggestBox x:Name="ReasonAutoSuggestBox"/>
</StackPanel>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Uno.UI.Samples.Controls;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace UITests.Windows_UI_Xaml_Controls.AutoSuggestBoxTests
{
[Sample("AutoSuggestBox")]
public sealed partial class AutoSuggestBox_Reason : Page
{

public List<string> SampleList = new List<string>
{
"Africa",
"America",
"Europe",
};

public AutoSuggestBox_Reason()
{
this.InitializeComponent();

ReasonAutoSuggestBox.ItemsSource = SampleList;
ReasonAutoSuggestBox.TextChanged += (s, e) =>
{
txtConsole.Text = e.Reason.ToString();
};
}
public void PopulateClick(object sender, RoutedEventArgs e)
{
ReasonAutoSuggestBox.Text = "A";
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class AutoSuggestBox : ItemsControl, IValueChangedListener
private Grid _layoutRoot;
private ListView _suggestionsList;
private Button _queryButton;
private AutoSuggestionBoxTextChangeReason _textChangeReason;
private AutoSuggestionBoxTextChangeReason _textChangeReason = AutoSuggestionBoxTextChangeReason.ProgrammaticChange;
private string userInput;
private BindingPath _textBoxBinding;

Expand Down

0 comments on commit 8d8686d

Please sign in to comment.