-
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 AddressBookTest; add EmailTest
- Loading branch information
Showing
10 changed files
with
195 additions
and
34 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -85,15 +85,34 @@ public void AddAndRemoveEntriesTest() => Run(() => | |
|
||
window.ExitCommand.Click(); | ||
|
||
|
||
// Restart application and assert that new contact was saved | ||
Launch(resetSettings: false, resetContainer: false); | ||
window = GetShellWindow(); | ||
Assert.Equal(WindowVisualState.Maximized, window.WindowState); | ||
window.RootTreeItem.ContactsNode.Click(); | ||
contactListView = window.ContactLayoutView.ContactListView; | ||
contactView = window.ContactLayoutView.ContactView; | ||
Assert.Equal(5, contactListView.ContactItems.Count); | ||
Assert.Equal("AFirstname", contactListView.ContactItems[^1].FirstnameLabel.Text); | ||
newItem = contactListView.ContactItems[^1]; | ||
Assert.Equal("AFirstname", newItem.FirstnameLabel.Text); | ||
contactListView.ContactList.Select(contactListView.ContactItems.Count - 1); | ||
AssertContactItem(newItem, contactView, "AFirstname", "ALastname", "[email protected]", "1234"); | ||
|
||
// Invalid Firstname > Save > Restart > Validation error should be here again | ||
contactView.FirstnameBox.Text = ""; | ||
window.ExitCommand.Click(); | ||
|
||
Launch(resetSettings: false, resetContainer: false); | ||
window = GetShellWindow(); | ||
Assert.Equal(WindowVisualState.Maximized, window.WindowState); | ||
window.RootTreeItem.ContactsNode.Click(); | ||
contactListView = window.ContactLayoutView.ContactListView; | ||
contactView = window.ContactLayoutView.ContactView; | ||
newItem = contactListView.ContactItems[^1]; | ||
contactListView.ContactList.Select(contactListView.ContactItems.Count - 1); | ||
Assert.Equal("The Firstname field is required.", contactView.FirstnameBox.ItemStatus); | ||
|
||
// Remove all contact items | ||
var count = contactListView.ContactItems.Count; | ||
for (int i = 0; i < count; i++) window.DeleteCommand.Click(); | ||
Assert.False(window.DeleteCommand.IsEnabled); | ||
|
78 changes: 78 additions & 0 deletions
78
src/Samples.UITest/InformationManager.Test/Tests/EmailTest.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,78 @@ | ||
using FlaUI.Core.AutomationElements; | ||
using UITest.InformationManager.Views; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace UITest.InformationManager.Tests; | ||
public class EmailTest(ITestOutputHelper log) : UITest(log) | ||
{ | ||
[Fact] | ||
public void SearchEmailsAndAssertLists() => Run(() => | ||
{ | ||
Launch(); | ||
var window = GetShellWindow(); | ||
Assert.True(window.RootTreeItem.InboxNode.IsSelected); | ||
|
||
var emailListView = window.EmailLayoutView.EmailListView; | ||
var emailView = window.EmailLayoutView.EmailView; | ||
var count = emailListView.EmailItems.Count; | ||
Assert.Equal(10, count); | ||
Log.WriteLine($"List of Contacts ({count})"); | ||
for (int i = 0; i < count; i++) Log.WriteLine($"{i:00}: {emailListView.EmailItems[i].ToReceivedTuple()}"); | ||
|
||
AssertEmail(true, emailListView.EmailItems[0], emailView, "[email protected]", "[email protected]", "8/9/2012", "5:58:21 AM", "Nunc sed dis suscipit"); | ||
|
||
Assert.Equal("Search", emailListView.SearchBox.SearchHintLabel.Text); | ||
emailListView.SearchBox.SearchTextBox.Text = "!"; | ||
Assert.Empty(emailListView.EmailItems); | ||
|
||
emailListView.SearchBox.SearchTextBox.Text = "someone"; | ||
Assert.Equal(3, emailListView.EmailItems.Count); | ||
Assert.Null(emailListView.EmailList.SelectedItem); | ||
emailListView.EmailList.Select(1); | ||
var item = emailListView.EmailList.SelectedItem.As<EmailListItem>(); | ||
AssertEmail(true, item, emailView, "[email protected]", "[email protected]", "9/5/2005", "4:34:45 PM", "Taciti enim"); | ||
|
||
|
||
window.RootTreeItem.OutboxNode.Select(); | ||
emailListView = window.EmailLayoutView.EmailListView; | ||
emailView = window.EmailLayoutView.EmailView; | ||
Assert.Empty(emailListView.EmailItems); | ||
Assert.Empty(emailView.TitleLabel.Text); | ||
|
||
|
||
window.RootTreeItem.SentNode.Select(); | ||
emailListView = window.EmailLayoutView.EmailListView; | ||
emailView = window.EmailLayoutView.EmailView; | ||
Assert.Equal(5, emailListView.EmailItems.Count); | ||
AssertEmail(false, emailListView.EmailList.SelectedItem.As<EmailListItem>(), emailView, "[email protected]", "[email protected]", "4/7/2012", "10:07:05 AM", "Massa sed"); | ||
|
||
|
||
window.RootTreeItem.DraftsNode.Select(); | ||
emailListView = window.EmailLayoutView.EmailListView; | ||
emailView = window.EmailLayoutView.EmailView; | ||
Assert.Single(emailListView.EmailItems); | ||
AssertEmail(false, emailListView.EmailList.SelectedItem.As<EmailListItem>(), emailView, "[email protected]", "", "7/1/2006", "3:40:49 AM", "Sociis nunc vivamus sagittis"); | ||
|
||
|
||
window.RootTreeItem.DeletedNode.Select(); | ||
emailListView = window.EmailLayoutView.EmailListView; | ||
emailView = window.EmailLayoutView.EmailView; | ||
Assert.Empty(emailListView.EmailItems); | ||
Assert.Empty(emailView.TitleLabel.Text); | ||
|
||
window.ExitCommand.Click(); | ||
}); | ||
|
||
private static void AssertEmail(bool received, EmailListItem? emailItem, EmailView? emailView, string from, string to, string sentDate, string sentTime, string title) | ||
{ | ||
if (emailItem is not null) | ||
{ | ||
if (received) Assert.Equal((from, sentDate, title), emailItem.ToReceivedTuple()); | ||
else Assert.Equal((to, sentDate, title), emailItem.ToSendTuple()); | ||
} | ||
if (emailView is not null) | ||
{ | ||
Assert.Equal((from, to, sentDate + " " + sentTime, title), (emailView.FromLabel.Text, emailView.ToLabel.Text, emailView.SentLabel.Text, emailView.TitleLabel.Text)); } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Samples.UITest/InformationManager.Test/Views/EmailLayoutView.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.Views; | ||
|
||
public class EmailLayoutView(FrameworkAutomationElementBase element) : AutomationElement(element) | ||
{ | ||
public EmailListView EmailListView => this.Find("EmailListView").As<EmailListView>(); | ||
|
||
public EmailView EmailView => this.Find("EmailView").As<EmailView>(); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Samples.UITest/InformationManager.Test/Views/EmailListView.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,29 @@ | ||
using FlaUI.Core; | ||
using FlaUI.Core.AutomationElements; | ||
using UITest.InformationManager.Controls; | ||
|
||
namespace UITest.InformationManager.Views; | ||
|
||
public class EmailListView(FrameworkAutomationElementBase element) : AutomationElement(element) | ||
{ | ||
public SearchBox SearchBox => this.Find("SearchBox").As<SearchBox>(); | ||
|
||
public ListBox EmailList => this.Find("EmailList").AsListBox(); | ||
|
||
public IReadOnlyList<EmailListItem> EmailItems => EmailList.Items.Select(x => x.As<EmailListItem>()).ToArray(); | ||
} | ||
|
||
public class EmailListItem(FrameworkAutomationElementBase element) : ListBoxItem(element) | ||
{ | ||
public Label ToLabel => this.Find("ToLabel").AsLabel(); | ||
|
||
public Label FromLabel => this.Find("FromLabel").AsLabel(); | ||
|
||
public Label SentLabel => this.Find("SentLabel").AsLabel(); | ||
|
||
public Label TitleLabel => this.Find("TitleLabel").AsLabel(); | ||
|
||
public (string to, string sent, string title) ToReceivedTuple() => (FromLabel.Text, SentLabel.Text, TitleLabel.Text); | ||
|
||
public (string to, string sent, string title) ToSendTuple() => (ToLabel.Text, SentLabel.Text, TitleLabel.Text); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Samples.UITest/InformationManager.Test/Views/EmailView.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,19 @@ | ||
using FlaUI.Core.AutomationElements; | ||
using FlaUI.Core; | ||
|
||
namespace UITest.InformationManager.Views; | ||
|
||
public class EmailView(FrameworkAutomationElementBase element) : AutomationElement(element) | ||
{ | ||
public Label TitleLabel => this.Find("TitleLabel").AsLabel(); | ||
|
||
public Label FromLabel => this.Find("FromLabel").AsLabel(); | ||
|
||
public Label ToLabel => this.Find("ToLabel").AsLabel(); | ||
|
||
public Label CCLabel => this.Find("CCLabel").AsLabel(); | ||
|
||
public Label BccLabel => this.Find("BccLabel").AsLabel(); | ||
|
||
public Label SentLabel => this.Find("SentLabel").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