-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UITest/InfoMan: extend ShowContactsTest
- Loading branch information
Showing
8 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/Samples.UITest/InformationManager.Test/Controls/SearchBox.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using FlaUI.Core.AutomationElements; | ||
using FlaUI.Core; | ||
|
||
namespace UITest.InformationManager.Controls; | ||
|
||
public class SearchBox(FrameworkAutomationElementBase element) : AutomationElement(element) | ||
{ | ||
public Label SearchHintLabel => this.Find("SearchHintLabel").AsLabel(); | ||
|
||
public TextBox SearchTextBox => this.Find("SearchTextBox").AsTextBox(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
using Xunit.Abstractions; | ||
using FlaUI.Core.AutomationElements; | ||
using Xunit.Abstractions; | ||
using Xunit; | ||
using UITest.InformationManager.Views; | ||
|
||
namespace UITest.InformationManager.Tests; | ||
|
||
|
@@ -13,8 +15,38 @@ public void ShowContactsTest() => Run(() => | |
window.RootTreeItem.ContactsNode.Click(); | ||
|
||
var contactListView = window.ContactLayoutView.ContactListView; | ||
Assert.Equal(5, contactListView.ContactList.Items.Length); | ||
var contactView = window.ContactLayoutView.ContactView; | ||
Assert.Equal(5, contactListView.ContactItems.Count); | ||
Assert.Equal(contactListView.ContactList.SelectedItem.As<ContactListItem>().FirstnameLabel.Text, contactListView.ContactItems[0].FirstnameLabel.Text); | ||
AssertContactItem(contactListView.ContactItems[0], contactView, "Jesper", "Aaberg", "[email protected]", "(111) 555-0100"); | ||
AssertContactItem(contactListView.ContactItems[^1], null, "Miles", "Reid", "[email protected]", "(444) 555-0123"); | ||
|
||
Assert.Equal("Search", contactListView.SearchBox.SearchHintLabel.Text); | ||
contactListView.SearchBox.SearchTextBox.Text = "!"; | ||
Assert.Empty(contactListView.ContactItems); | ||
|
||
contactListView.SearchBox.SearchTextBox.Text = "Mi"; | ||
Assert.Equal(2, contactListView.ContactItems.Count); | ||
Assert.Null(contactListView.ContactList.SelectedItem); | ||
contactListView.ContactList.Select(0); | ||
AssertContactItem(contactListView.ContactList.SelectedItem.As<ContactListItem>(), contactView, "Michael", "Pfeiffer", "[email protected]", "(222) 555-0105"); | ||
|
||
window.ExitCommand.Click(); | ||
}); | ||
|
||
private static void AssertContactItem(ContactListItem contactItem, ContactView? contactView, string firstName, string lastName, string email, string phone) | ||
{ | ||
Assert.Equal(firstName, contactItem.FirstnameLabel.Text); | ||
Assert.Equal(lastName, contactItem.LastnameLabel.Text); | ||
Assert.Equal(email, contactItem.EmailLabel.Text); | ||
Assert.Equal(phone, contactItem.PhoneLabel.Text); | ||
|
||
if (contactView is not null) | ||
{ | ||
Assert.Equal(firstName, contactView.FirstnameBox.Text); | ||
Assert.Equal(lastName, contactView.LastnameBox.Text); | ||
Assert.Equal(email, contactView.EmailBox.Text); | ||
Assert.Equal(phone, contactView.PhoneBox.Text); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Samples.UITest/InformationManager.Test/Views/ContactListView.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
using FlaUI.Core.AutomationElements; | ||
using FlaUI.Core; | ||
using UITest.InformationManager.Controls; | ||
|
||
namespace UITest.InformationManager.Views; | ||
|
||
public class ContactListView(FrameworkAutomationElementBase element) : AutomationElement(element) | ||
{ | ||
public SearchBox SearchBox => this.Find("SearchBox").As<SearchBox>(); | ||
|
||
public ListBox ContactList => this.Find("ContactList").AsListBox(); | ||
|
||
public IReadOnlyList<ContactListItem> ContactItems => ContactList.Items.Select(x => x.As<ContactListItem>()).ToArray(); | ||
} | ||
|
||
public class ContactListItem(FrameworkAutomationElementBase element) : ListBoxItem(element) | ||
{ | ||
public Label FirstnameLabel => this.Find("FirstnameLabel").AsLabel(); | ||
|
||
public Label LastnameLabel => this.Find("LastnameLabel").AsLabel(); | ||
|
||
public Label EmailLabel => this.Find("EmailLabel").AsLabel(); | ||
|
||
public Label PhoneLabel => this.Find("PhoneLabel").AsLabel(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters