Skip to content

Commit f3477ec

Browse files
HarishKumarSF4517PureWeen
authored andcommitted
[Testing] Feature matrix UITest Cases for BoxView Control (#29808)
* harish_feature_matrix_boxview * Added the Snapshots * Updated the Snapshots * Renamed the file * Added property and Updated Snaps * Resaved Snapshots from latest build
1 parent b90041c commit f3477ec

30 files changed

+568
-0
lines changed
74 KB
Loading
79.7 KB
Loading
80.9 KB
Loading
90.6 KB
Loading
81.6 KB
Loading
88 KB
Loading
78.1 KB
Loading

src/Controls/tests/TestCases.HostApp/CoreViews/CorePageView.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public override string ToString()
8686
new GalleryPageFactory(() => new CollectionViewFeaturePage(), "CollectionView Feature Matrix"),
8787
new GalleryPageFactory(() => new LabelControlPage(), "Label Feature Matrix"),
8888
new GalleryPageFactory(() => new CarouselViewFeaturePage(), "CarouselView Feature Matrix"),
89+
new GalleryPageFactory(() => new BoxViewControlPage(), "BoxView Feature Matrix"),
8990
};
9091

9192
public CorePageView(Page rootPage)
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:Maui.Controls.Sample"
5+
x:Class="Maui.Controls.Sample.BoxViewControlMainPage"
6+
x:DataType="local:BoxViewViewModel"
7+
Title="BoxViewControlPage">
8+
9+
<Grid>
10+
<Grid.RowDefinitions>
11+
<RowDefinition Height="*"/>
12+
<RowDefinition Height="Auto"/>
13+
</Grid.RowDefinitions>
14+
15+
<!-- BoxView at top center -->
16+
<BoxView Grid.Row="0"
17+
Color="{Binding Color}"
18+
WidthRequest="{Binding Width}"
19+
Opacity="{Binding Opacity}"
20+
HeightRequest="{Binding Height}"
21+
CornerRadius="{Binding CornerRadius}"
22+
IsVisible="{Binding IsVisible}"
23+
Shadow="{Binding BoxShadow}"
24+
VerticalOptions="Center"
25+
FlowDirection="{Binding FlowDirection}"
26+
HorizontalOptions="Center"/>
27+
28+
<!-- Controls at bottom -->
29+
<Grid Grid.Row="1"
30+
ColumnSpacing="20"
31+
VerticalOptions="End"
32+
HorizontalOptions="Center">
33+
34+
<Grid.ColumnDefinitions>
35+
<ColumnDefinition Width="Auto"/>
36+
<ColumnDefinition Width="Auto"/>
37+
</Grid.ColumnDefinitions>
38+
39+
<!-- Left Column - Entry Controls -->
40+
<StackLayout Grid.Column="0"
41+
Grid.Row="0"
42+
Padding="20"
43+
Spacing="10">
44+
<Label FontAttributes="Bold"
45+
AutomationId="CornerRadiusLabel"
46+
Text="Corner Radius"/>
47+
<local:UITestEntry x:Name="CornerRadiusEntry"
48+
AutomationId="CornerRadiusEntry"
49+
Placeholder="e.g. 10,20,30,40"
50+
IsCursorVisible="False"
51+
Text="{Binding CornerRadiusEntryText, Mode=TwoWay}"
52+
TextChanged="OnCornerRadiusEntryChanged"/>
53+
<Label FontAttributes="Bold"
54+
AutomationId="OpacityLabel"
55+
Text="Opacity"/>
56+
<local:UITestEntry x:Name="OpacityEntry"
57+
Placeholder="Enter opacity (0.0 - 1.0)"
58+
AutomationId="OpacityEntry"
59+
IsCursorVisible="False"
60+
Text="{Binding OpacityEntryText, Mode=TwoWay}"
61+
TextChanged="OnOpacityChanged"/>
62+
63+
<Button Text="Reset Changes"
64+
WidthRequest="150"
65+
AutomationId="ResetButton"
66+
Clicked="OnResetChangesClicked"/>
67+
</StackLayout>
68+
69+
<!-- Right Column - Controls -->
70+
<StackLayout Grid.Column="1"
71+
Grid.Row="0"
72+
Padding="20"
73+
Spacing="1">
74+
<Label FontAttributes="Bold"
75+
Text="Box Color"/>
76+
<VerticalStackLayout>
77+
<RadioButton Content="Red"
78+
Value="Red"
79+
GroupName="Colors"
80+
AutomationId="RedRadioButton"
81+
IsChecked="{Binding IsRedChecked, Mode=TwoWay}"/>
82+
83+
<RadioButton Content="Blue"
84+
Value="Blue"
85+
GroupName="Colors"
86+
AutomationId="BlueRadioButton"
87+
IsChecked="{Binding IsBlueChecked, Mode=TwoWay}"/>
88+
</VerticalStackLayout>
89+
90+
<VerticalStackLayout Spacing="5">
91+
<HorizontalStackLayout
92+
Spacing="10">
93+
<CheckBox IsChecked="{Binding IsVisible}"
94+
AutomationId="VisibilityCheckBox"/>
95+
<Label Text="Is Visible"
96+
VerticalOptions="Center"/>
97+
</HorizontalStackLayout>
98+
<HorizontalStackLayout Spacing="10">
99+
<CheckBox
100+
IsChecked="{Binding HasShadow}"
101+
AutomationId="ShadowCheckBox"/>
102+
<Label Text="Has Shadow"
103+
VerticalOptions="Center"/>
104+
</HorizontalStackLayout>
105+
106+
<Label Text="Flow Direction:"
107+
FontAttributes="Bold"
108+
FontSize="15"/>
109+
<StackLayout Orientation="Horizontal"
110+
Spacing="10">
111+
112+
<CheckBox x:Name="FlowDirectionRTLCheckBox"
113+
AutomationId="FlowDirectionRTLCheckBox"
114+
IsChecked="False"
115+
CheckedChanged="OnFlowDirectionCheckBoxChanged"/>
116+
<Label Text="RTL"
117+
VerticalOptions="Center"/>
118+
</StackLayout>
119+
120+
</VerticalStackLayout>
121+
</StackLayout>
122+
</Grid>
123+
</Grid>
124+
</ContentPage>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using System;
2+
using Microsoft.Maui.Controls;
3+
4+
namespace Maui.Controls.Sample
5+
{
6+
public class BoxViewControlPage : NavigationPage
7+
{
8+
private BoxViewViewModel _viewModel;
9+
10+
public BoxViewControlPage()
11+
{
12+
_viewModel = new BoxViewViewModel();
13+
PushAsync(new BoxViewControlMainPage(_viewModel));
14+
}
15+
}
16+
17+
public partial class BoxViewControlMainPage : ContentPage
18+
{
19+
private BoxViewViewModel _viewModel;
20+
21+
public BoxViewControlMainPage(BoxViewViewModel viewModel)
22+
{
23+
InitializeComponent();
24+
_viewModel = viewModel;
25+
BindingContext = _viewModel;
26+
}
27+
28+
private void OnFlowDirectionCheckBoxChanged(object sender, CheckedChangedEventArgs e)
29+
{
30+
if (e.Value)
31+
{
32+
_viewModel.FlowDirection = FlowDirection.RightToLeft;
33+
}
34+
else
35+
{
36+
_viewModel.FlowDirection = FlowDirection.LeftToRight;
37+
}
38+
}
39+
40+
private void OnColorRadioButtonChanged(object sender, EventArgs e)
41+
{
42+
if (sender is RadioButton radioButton && radioButton.IsChecked)
43+
{
44+
switch (radioButton.Value.ToString())
45+
{
46+
case "Red":
47+
_viewModel.Color = Colors.Red;
48+
break;
49+
case "Blue":
50+
_viewModel.Color = Colors.Blue;
51+
break;
52+
default:
53+
_viewModel.Color = Colors.Transparent;
54+
break;
55+
}
56+
}
57+
}
58+
59+
private void OnCornerRadiusEntryChanged(object sender, TextChangedEventArgs e)
60+
{
61+
if (string.IsNullOrWhiteSpace(e.NewTextValue))
62+
return;
63+
64+
var parts = e.NewTextValue.Split(',');
65+
66+
if (parts.Length != 4)
67+
return;
68+
69+
if (float.TryParse(parts[0].Trim(), out float topLeft) &&
70+
float.TryParse(parts[1].Trim(), out float topRight) &&
71+
float.TryParse(parts[2].Trim(), out float bottomLeft) &&
72+
float.TryParse(parts[3].Trim(), out float bottomRight))
73+
{
74+
_viewModel.CornerRadius = new CornerRadius(topLeft, topRight, bottomLeft, bottomRight);
75+
}
76+
}
77+
78+
private void OnResetChangesClicked(object sender, EventArgs e)
79+
{
80+
BindingContext = _viewModel = new BoxViewViewModel();
81+
}
82+
83+
private void OnOpacityChanged(object sender, TextChangedEventArgs e)
84+
{
85+
if (double.TryParse(e.NewTextValue, out double value))
86+
{
87+
if (value >= 0 && value <= 1)
88+
_viewModel.Opacity = value;
89+
}
90+
}
91+
}
92+
}

0 commit comments

Comments
 (0)