Skip to content

Commit de74b28

Browse files
committed
Code changes for testcase review
1 parent 76cb44c commit de74b28

2 files changed

Lines changed: 18 additions & 23 deletions

File tree

src/Controls/tests/TestCases.HostApp/Issues/Issue12008.cs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.ObjectModel;
2+
using Microsoft.Maui.Controls.Shapes;
23

34
namespace Maui.Controls.Sample.Issues;
45

@@ -38,7 +39,7 @@ public Issue12008()
3839
ItemsSource = Groups,
3940
IsGrouped = true,
4041
CanReorderItems = true,
41-
CanMixGroups = true,
42+
CanMixGroups = true,
4243
SelectionMode = SelectionMode.None
4344
};
4445

@@ -59,7 +60,7 @@ public Issue12008()
5960
TextColor = Colors.Gray,
6061
HorizontalTextAlignment = TextAlignment.End
6162
};
62-
countLabel.SetBinding(Label.TextProperty, new Binding("Items.Count", stringFormat: "({0} items)"));
63+
countLabel.SetBinding(Label.TextProperty, new Binding("Count", stringFormat: "({0} items)"));
6364

6465
var headerGrid = new Grid
6566
{
@@ -73,7 +74,7 @@ public Issue12008()
7374
}
7475
};
7576
headerGrid.SetColumn(countLabel, 1);
76-
77+
7778
// Set AutomationId based on group name
7879
headerGrid.SetBinding(AutomationProperties.NameProperty, new Binding("Name"));
7980

@@ -90,16 +91,16 @@ public Issue12008()
9091
};
9192
itemLabel.SetBinding(Label.TextProperty, "Name");
9293

93-
var itemContainer = new Frame
94+
var itemContainer = new Border
9495
{
9596
Padding = 0,
9697
Margin = new Thickness(12, 4, 12, 4),
9798
Content = itemLabel,
9899
BackgroundColor = Colors.White,
99-
CornerRadius = 5,
100-
HasShadow = true
100+
StrokeShape = new RoundRectangle { CornerRadius = 5 },
101+
Shadow = new Shadow { Opacity = 0.3f, Radius = 2 }
101102
};
102-
103+
103104
// Set AutomationId based on item name for testability
104105
itemContainer.SetBinding(AutomationProperties.NameProperty, new Binding("Name"));
105106

@@ -134,31 +135,22 @@ public Issue12008()
134135

135136
void OnReorderCompleted(object sender, EventArgs e)
136137
{
137-
// Update status label when reorder completes
138+
// Update status label with per-group counts so tests can verify actual data model changes
138139
if (Content is VerticalStackLayout layout && layout.Children[0] is Label statusLabel)
139140
{
140-
statusLabel.Text = "Reorder completed!";
141+
var groupCounts = string.Join(", ", Groups.Select(g => $"{g.Name}:{g.Count}"));
142+
statusLabel.Text = $"Reorder completed! {groupCounts}";
141143
statusLabel.BackgroundColor = Color.FromArgb("#C8E6C9");
142-
143-
// Reset status after 2 seconds
144-
MainThread.BeginInvokeOnMainThread(async () =>
145-
{
146-
await Task.Delay(2000);
147-
statusLabel.Text = "Ready to reorder items";
148-
statusLabel.BackgroundColor = Color.FromArgb("#E8F5E9");
149-
});
150144
}
151145
}
152146

153147
public class Issue12008Group : ObservableCollection<Item>
154148
{
155149
public string Name { get; set; }
156-
public new ObservableCollection<Item> Items { get; }
157150

158151
public Issue12008Group(string name, ObservableCollection<Item> items)
159152
{
160153
Name = name;
161-
Items = items;
162154

163155
foreach (var item in items)
164156
Add(item);

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue12008.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_ANDROID
1+
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_ANDROID
22
using NUnit.Framework;
33
using UITest.Appium;
44
using UITest.Core;
@@ -25,10 +25,13 @@ public void CanDragItemIntoEmptyGroup()
2525
// Drag an item from Group A into the Empty Group
2626
App.DragAndDrop("Item A1", "Empty Group");
2727

28-
// Verify the reorder completed successfully by checking status label
28+
// Verify the data model actually changed:
29+
// - Group A should have lost one item (3 -> 2)
30+
// - Empty Group should have gained one item (0 -> 1)
2931
var statusLabel = App.WaitForElement("StatusLabel");
3032
var statusText = statusLabel.GetText();
31-
Assert.That(statusText, Does.Contain("Reorder completed"), "Status should show reorder completed after dragging into empty group");
33+
Assert.That(statusText, Does.Contain("Empty Group:1"), "Empty Group should contain 1 item after drag-and-drop");
34+
Assert.That(statusText, Does.Contain("Group A:2"), "Group A should contain 2 items after losing one to Empty Group");
3235
}
3336
}
34-
#endif
37+
#endif

0 commit comments

Comments
 (0)