-
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.
- Loading branch information
Showing
14 changed files
with
194 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using FlaUI.Core.AutomationElements; | ||
using UITest.InformationManager.Controls; | ||
using UITest.InformationManager.Views; | ||
using UITest.SystemViews; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
|
@@ -23,7 +23,7 @@ public void SearchEmailsAndAssertLists() => Run(() => | |
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("Scelerisque est odio", emailView.Document.As<Document>().GetText(20)); | ||
Assert.Equal("Scelerisque est odio", emailView.Document.GetText(20)); | ||
|
||
Assert.Equal("Search", emailListView.SearchBox.SearchHintLabel.Text); | ||
emailListView.SearchBox.SearchTextBox.Text = "!"; | ||
|
@@ -104,7 +104,89 @@ public void RemoveEmailsTest() => Run(() => | |
Assert.Empty(emailListView.EmailItems); | ||
}); | ||
|
||
private static void AssertEmail(bool received, EmailListItem? emailItem, EmailView? emailView, string from, string to, string sentDate, string sentTime, string title) | ||
[Fact] | ||
public void NewEmailTest() => Run(() => | ||
{ | ||
Launch(); | ||
var window = GetShellWindow(); | ||
window.RootTreeItem.SentNode.Select(); | ||
var emailListView = window.EmailLayoutView.EmailListView; | ||
var emailView = window.EmailLayoutView.EmailView; | ||
Assert.Equal(5, emailListView.EmailItems.Count); | ||
|
||
window.NewEmailCommand.Click(); | ||
var newEmailWindow = window.NewEmailWindows[0]; | ||
newEmailWindow.SendButton.Click(); | ||
|
||
// ItemStatus contains the validation error message or string.Empty if no error exists | ||
Assert.Equal("", newEmailWindow.ToTextBox.Text); | ||
Assert.Equal("This email doesn't define a recipient.", newEmailWindow.ToTextBox.ItemStatus); | ||
Assert.Equal("", newEmailWindow.CCTextBox.Text); | ||
Assert.Empty(newEmailWindow.CCTextBox.ItemStatus); | ||
|
||
newEmailWindow.SendButton.Click(); | ||
var errorBox = newEmailWindow.FirstModalWindow().As<MessageBox>(); | ||
Assert.Contains("One or more fields are not valid.", errorBox.Message); | ||
errorBox.Buttons[0].Click(); | ||
|
||
newEmailWindow.ToTextBox.Text = "[email protected]"; | ||
newEmailWindow.CCTextBox.Click(); | ||
Assert.Empty(newEmailWindow.ToTextBox.ItemStatus); | ||
|
||
newEmailWindow.CCSelectContactButton.Click(); | ||
var contactWindow = newEmailWindow.FirstModalWindow().As<SelectContactWindow>(); | ||
Assert.Equal(5, contactWindow.ContactListView.ContactItems.Count); | ||
Assert.True(contactWindow.ContactListView.ContactItems[0].IsSelected); | ||
contactWindow.ContactListView.SearchBox.SearchTextBox.Text = "Mi"; | ||
Assert.Equal(2, contactWindow.ContactListView.ContactItems.Count); | ||
Assert.False(contactWindow.ContactListView.ContactItems[0].IsSelected); | ||
contactWindow.ContactListView.ContactList.Items[0].Select(); | ||
contactWindow.OkButton.Click(); | ||
Assert.Equal("[email protected]", newEmailWindow.CCTextBox.Text); | ||
|
||
newEmailWindow.BccSelectContactButton.Click(); | ||
contactWindow = newEmailWindow.FirstModalWindow().As<SelectContactWindow>(); | ||
contactWindow.CancelButton.Click(); | ||
Assert.Empty(newEmailWindow.BccTextBox.Text); | ||
newEmailWindow.BccSelectContactButton.Click(); | ||
contactWindow = newEmailWindow.FirstModalWindow().As<SelectContactWindow>(); | ||
contactWindow.OkButton.Click(); | ||
Assert.Equal("[email protected]", newEmailWindow.BccTextBox.Text); | ||
|
||
newEmailWindow.TitleTextBox.Text = "ATitle"; | ||
newEmailWindow.MessageTextBox.Text = "AMessage"; | ||
newEmailWindow.SendButton.Click(); | ||
|
||
Assert.Equal(6, emailListView.EmailItems.Count); | ||
emailListView.EmailItems[0].Select(); | ||
AssertEmail(false, emailListView.EmailItems[0], emailView, "[email protected]", "[email protected]", DateTime.Now.ToShortDateString(), null, "ATitle"); | ||
Assert.Equal("AMessage", emailView.Document.GetText(20)); | ||
|
||
|
||
// Create email but do not send it -> Close | ||
window.NewEmailCommand.Click(); | ||
newEmailWindow = window.NewEmailWindows[0]; | ||
newEmailWindow.ToTextBox.Text = "[email protected]"; | ||
newEmailWindow.TitleTextBox.Text = "Don't send"; | ||
newEmailWindow.CloseButton.Click(); | ||
Assert.Equal(6, emailListView.EmailItems.Count); | ||
}); | ||
|
||
[Fact] | ||
public void EmailAccountsTest() => Run(() => | ||
{ | ||
Launch(); | ||
var window = GetShellWindow(); | ||
window.EmailAccountsCommand.Click(); | ||
var emailAccountsWindow = window.FirstModalWindow().As<EmailAccountsWindow>(); | ||
var row0 = emailAccountsWindow.EmailAccountsDataGrid.Rows[0].As<EmailAccountGridRow>(); | ||
|
||
// TODO: Add test EmailAccountsTest() | ||
// 2. Select email account (just one in ComboBox) | ||
|
||
}); | ||
|
||
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) | ||
{ | ||
|
@@ -113,6 +195,13 @@ private static void AssertEmail(bool received, EmailListItem? emailItem, EmailVi | |
} | ||
if (emailView is not null) | ||
{ | ||
Assert.Equal((from, to, sentDate + " " + sentTime, title), (emailView.FromLabel.Text, emailView.ToLabel.Text, emailView.SentLabel.Text, emailView.TitleLabel.Text)); } | ||
var expectedDate = sentTime is null ? "" : sentDate + " " + sentTime; | ||
var actualDate = sentTime is null ? "" : emailView.SentLabel.Text; | ||
Assert.Equal((from, to, expectedDate, title), (emailView.FromLabel.Text, emailView.ToLabel.Text, actualDate, emailView.TitleLabel.Text)); | ||
if (sentTime is null) | ||
{ | ||
Assert.Contains(expectedDate, actualDate); | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Samples.UITest/InformationManager.Test/Views/EmailAccountsWindow.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,25 @@ | ||
using FlaUI.Core; | ||
using FlaUI.Core.AutomationElements; | ||
using UITest.Controls; | ||
|
||
namespace UITest.InformationManager.Views; | ||
|
||
public class EmailAccountsWindow(FrameworkAutomationElementBase element) : Window(element) | ||
{ | ||
public Button NewButton => this.Find("NewButton").AsButton(); | ||
|
||
public Button RemoveButton => this.Find("RemoveButton").AsButton(); | ||
|
||
public Button EditButton => this.Find("EditButton").AsButton(); | ||
|
||
public Button CloseButton => this.Find("CloseButton").AsButton(); | ||
|
||
public Grid EmailAccountsDataGrid => this.Find("EmailAccountsDataGrid").AsGrid(); | ||
} | ||
|
||
public class EmailAccountGridRow(FrameworkAutomationElementBase element) : GridRow(element) | ||
{ | ||
public TextGridCell NameCell => Cells[0].As<TextGridCell>(); | ||
|
||
public TextGridCell EmailCell => Cells[1].As<TextGridCell>(); | ||
} |
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
29 changes: 29 additions & 0 deletions
29
src/Samples.UITest/InformationManager.Test/Views/NewEmailWindow.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; | ||
|
||
namespace UITest.InformationManager.Views; | ||
|
||
public class NewEmailWindow(FrameworkAutomationElementBase element) : Window(element) | ||
{ | ||
public Button SendButton => this.Find("SendButton").AsButton(); | ||
|
||
public Button CloseButton => this.Find("CloseButton").AsButton(); | ||
|
||
public ComboBox EmailAccountsComboBox => this.Find("EmailAccountsComboBox").AsComboBox(); | ||
|
||
public TextBox ToTextBox => this.Find("ToTextBox").AsTextBox(); | ||
|
||
public Button ToSelectContactButton => this.Find("ToSelectContactButton").AsButton(); | ||
|
||
public TextBox CCTextBox => this.Find("CCTextBox").AsTextBox(); | ||
|
||
public Button CCSelectContactButton => this.Find("CCSelectContactButton").AsButton(); | ||
|
||
public TextBox BccTextBox => this.Find("BccTextBox").AsTextBox(); | ||
|
||
public Button BccSelectContactButton => this.Find("BccSelectContactButton").AsButton(); | ||
|
||
public TextBox TitleTextBox => this.Find("TitleTextBox").AsTextBox(); | ||
|
||
public TextBox MessageTextBox => this.Find("MessageTextBox").AsTextBox(); | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Samples.UITest/InformationManager.Test/Views/SelectContactWindow.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,13 @@ | ||
using FlaUI.Core; | ||
using FlaUI.Core.AutomationElements; | ||
|
||
namespace UITest.InformationManager.Views; | ||
|
||
public class SelectContactWindow(FrameworkAutomationElementBase element) : Window(element) | ||
{ | ||
public ContactListView ContactListView => this.Find("ContactListView").As<ContactListView>(); | ||
|
||
public Button OkButton => this.Find("OkButton").AsButton(); | ||
|
||
public Button CancelButton => this.Find("CancelButton").AsButton(); | ||
} |
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
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