diff options
author | Manish Sinha <manish.sinha@xamarin.com> | 2015-10-22 01:31:20 +0300 |
---|---|---|
committer | Manish Sinha <manish.sinha@xamarin.com> | 2015-10-22 05:13:11 +0300 |
commit | 781e1f758bb83bac0f8ad013dbd3a6888fd7e50a (patch) | |
tree | 6f4c8b58bd662a921aa3b9844e901026fb2d4ab0 /main/tests | |
parent | 587cfa1d04432f67d54873be38ab24d103c65377 (diff) |
[UITest] Add Git Reproduction Steps in VCSBase
Diffstat (limited to 'main/tests')
-rw-r--r-- | main/tests/UserInterfaceTests/CreateBuildTemplatesTestBase.cs | 21 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/VersionControlTests/VCSBase.cs | 106 |
2 files changed, 95 insertions, 32 deletions
diff --git a/main/tests/UserInterfaceTests/CreateBuildTemplatesTestBase.cs b/main/tests/UserInterfaceTests/CreateBuildTemplatesTestBase.cs index f48f2e6125..d7bb1618de 100644 --- a/main/tests/UserInterfaceTests/CreateBuildTemplatesTestBase.cs +++ b/main/tests/UserInterfaceTests/CreateBuildTemplatesTestBase.cs @@ -30,6 +30,7 @@ using System.Diagnostics; using System.IO; using System.Text.RegularExpressions; using System.Threading; +using MonoDevelop.Components.AutoTest; using NUnit.Framework; namespace UserInterfaceTests @@ -214,6 +215,26 @@ namespace UserInterfaceTests // newProject.IsSelected (templateOptions); } + protected void WaitForElement (Func<AppQuery, AppQuery> query, string expected, string actual, int timeoutInSecs = 5) + { + try { + Session.WaitForElement (query, timeoutInSecs * 1000); + } catch (TimeoutException) { + ReproStep (string.Format ("Expected: {0}\nActual:{1}", expected, actual)); + throw; + } + } + + protected void WaitForElement (Action action, string expected, string actual) + { + try { + action (); + } catch (TimeoutException) { + ReproStep (string.Format ("Expected: {0}\nActual:{1}", expected, actual)); + throw; + } + } + void PrintToTestRunner (TemplateSelectionOptions templateOptions, ProjectDetails projectDetails, GitOptions gitOptions, object miscOptions) { diff --git a/main/tests/UserInterfaceTests/VersionControlTests/VCSBase.cs b/main/tests/UserInterfaceTests/VersionControlTests/VCSBase.cs index 904dfa8e3d..e439d46580 100644 --- a/main/tests/UserInterfaceTests/VersionControlTests/VCSBase.cs +++ b/main/tests/UserInterfaceTests/VersionControlTests/VCSBase.cs @@ -26,7 +26,6 @@ using System; using NUnit.Framework; -using MonoDevelop.Components.AutoTest; using MonoDevelop.Ide.Commands; namespace UserInterfaceTests @@ -42,18 +41,34 @@ namespace UserInterfaceTests protected string CheckoutOrClone (string repoUrl, string cloneToLocation = null, VersionControlType cvsType = VersionControlType.Git, int cloneTimeoutSecs = 180) { cloneToLocation = cloneToLocation ?? Util.CreateTmpDir ("clone"); + ReproStep ("Click on Version Control > Checkout from Menu Bar"); Session.ExecuteCommand (MonoDevelop.VersionControl.Commands.Checkout); - Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Dialogs.SelectRepositoryDialog")); + + WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Dialogs.SelectRepositoryDialog"), + "Select Repository window should open", + "Select Reprository window did not open"); TakeScreenShot ("Checkout-Window-Ready"); + + ReproStep (string.Format ("Select Type to '{0}'", cvsType)); Assert.IsTrue (Session.SelectElement (c => c.Marked ("repCombo").Model ().Text (cvsType.ToString ()))); + + ReproStep (string.Format ("Enter URL as '{0}'", repoUrl)); Assert.IsTrue (Session.EnterText (c => c.Textfield ().Marked ("repositoryUrlEntry"), repoUrl)); + Assert.IsTrue (Session.EnterText (c => c.Textfield ().Marked ("entryFolder"), cloneToLocation)); Session.WaitForElement (c => c.Textfield ().Marked ("entryFolder").Text (cloneToLocation)); + TakeScreenShot ("Before-Clicking-OK"); + ReproStep ("Click OK"); Assert.IsTrue (Session.ClickElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Dialogs.SelectRepositoryDialog").Children ().Button ().Marked ("buttonOk"))); + Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.Ide.Gui.Dialogs.ProgressDialog"), 15000); TakeScreenShot ("CheckoutClone-In-Progress"); - Session.WaitForNoElement (c => c.Window ().Marked ("MonoDevelop.Ide.Gui.Dialogs.ProgressDialog"), cloneTimeoutSecs * 1000); + ReproStep ("Wait for Clone to Finish"); + WaitForElement (c => c.Window ().Marked ("MonoDevelop.Ide.Gui.Dialogs.ProgressDialog"), + string.Format ("Clone should finish within {0} seconds", cloneTimeoutSecs), + string.Format ("Clone failed to finish within {0} seconds", cloneTimeoutSecs), + cloneTimeoutSecs * 1000); return cloneToLocation; } @@ -66,56 +81,59 @@ namespace UserInterfaceTests protected void TestGitStash (string stashMsg, int timeoutStashSecs = 10) { + ReproStep ("Click on Version Control > Stash"); Session.ExecuteCommand (MonoDevelop.VersionControl.Git.Commands.Stash); - Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.NewStashDialog")); + + WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.NewStashDialog"), "Stash Dialog should open", "Stash Dialog did not open"); TakeScreenShot ("Stash-Dialog-Opened"); + + ReproStep ("Enter a stash message"); Session.EnterText (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.NewStashDialog").Children ().Textfield ().Marked ("entryComment"), stashMsg); Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.NewStashDialog").Children ().Textfield ().Marked ("entryComment").Text (stashMsg)); TakeScreenShot ("Stash-Message-Entered"); + + ReproStep ("Click on OK"); Session.ClickElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.NewStashDialog").Children ().Button ().Marked ("buttonOk")); Ide.WaitForStatusMessage (new [] { "Changes successfully stashed" }, timeoutStashSecs); } protected void TestGitUnstash () { + ReproStep ("Click on Version Control > Pop Stash"); Session.ExecuteCommand (MonoDevelop.VersionControl.Git.Commands.StashPop); - Ide.WaitForStatusMessage (new[] {"Stash successfully applied"}, 10); + + WaitForElement (() => Ide.WaitForStatusMessage (new[] {"Stash successfully applied"}, 10), "Stash should apply successfully", "Stash failed to apply"); } protected void TestCommit (string commitMsg) { + ReproStep ("Click on Version Control > Review Solution and Commit from Menu Bar"); Session.ExecuteCommand (MonoDevelop.VersionControl.Commands.SolutionStatus); - Session.WaitForElement (c => c.Button ().Marked ("buttonCommit").Sensitivity (true)); + + ReproStep ("Wait for diff to be available"); + WaitForElement (c => c.Button ().Marked ("buttonCommit").Sensitivity (true), "Commit button should become enabled", "Commit button was not enabled"); + + ReproStep ("Click on Commit Button"); Session.ClickElement (c => c.Button ().Marked ("buttonCommit"), false); - Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Dialogs.CommitDialog")); + + WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Dialogs.CommitDialog"), "Commit Dialog should open", "Commit Dialog did not open"); TakeScreenShot ("Commit-Dialog-Opened"); + + ReproStep ("Enter commit message and click on Commit"); Session.EnterText (c => c.Window ().Marked ("MonoDevelop.VersionControl.Dialogs.CommitDialog").Children ().TextView ().Marked ("textview"), commitMsg); TakeScreenShot ("Commit-Msg-Entered"); Session.ClickElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Dialogs.CommitDialog").Children ().Button ().Marked ("buttonCommit"), false); CheckIfNameEmailNeeded (); CheckIfUserConflict (); - Ide.WaitForStatusMessage (new[] {"Commit operation completed."}); - TakeScreenShot ("Commit-Completed"); - } - protected void EnterGitUserConfig (string gitUser, string gitEmail) - { - Session.ToggleElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().CheckButton ().Marked ("repoConfigRadio"), true); - - Session.EnterText (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().Textfield ().Marked ("usernameEntry"), gitUser); - Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().Textfield ().Marked ("usernameEntry").Text (gitUser)); - - Session.EnterText (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().Textfield ().Marked ("emailEntry"), gitEmail); - Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().Textfield ().Marked ("emailEntry").Text (gitEmail)); + WaitForElement (() => Ide.WaitForStatusMessage (new [] { "Commit operation completed." }), + "Status bar should show 'Commit operation completed.'", + "Status bar did not show 'Commit operation completed.'"); + TakeScreenShot ("Commit-Completed"); - TakeScreenShot ("Git-User-Email-Filled"); - Session.ClickElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().Button ().Marked ("buttonOk")); - if (Session.Query (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserInfoConflictDialog")).Length > 0) { - TakeScreenShot ("Provided-User-Details-Mismatch"); - Session.ToggleElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserInfoConflictDialog").Children ().CheckButton ().Marked ("radiobutton2"), true); - TakeScreenShot ("Selected-Use-Git-Config"); - Session.ClickElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserInfoConflictDialog").Children ().Button ().Marked ("buttonOk")); - } + ReproStep ("Close currently commit tab"); + Session.ExecuteCommand (FileCommands.CloseFile); + Session.WaitForElement (IdeQuery.TextArea); } protected void GitCreateAndCommit (TemplateSelectionOptions templateOptions, string commitMessage) @@ -126,23 +144,27 @@ namespace UserInterfaceTests Session.WaitForElement (IdeQuery.TextArea); TestCommit (commitMessage); - - Session.ExecuteCommand (FileCommands.CloseFile); - Session.WaitForElement (IdeQuery.TextArea); } protected string MakeSomeChangesAndSaveAll (string waitForFile = null) { - if (waitForFile != null) - Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.Ide.Gui.DefaultWorkbench").Property ("TabControl.CurrentTab.Text", waitForFile)); + if (waitForFile != null) { + WaitForElement (c => c.Window ().Marked ("MonoDevelop.Ide.Gui.DefaultWorkbench").Property ("TabControl.CurrentTab.Text", waitForFile), + string.Format ("File '{0}' should open", waitForFile), + string.Format ("File {0} did not open", waitForFile)); + } + Session.WaitForElement (IdeQuery.TextArea); TakeScreenShot ("Ready-To-Make-Changes"); Session.SelectElement (IdeQuery.TextArea); + ReproStep ("Make some random changes to the file"); for (int i = 0; i < 10; i++) { Session.ExecuteCommand (TextEditorCommands.InsertNewLine); Session.ExecuteCommand (TextEditorCommands.InsertTab); } TakeScreenShot ("Made-Changes-To-Doc"); + + ReproStep ("Click on File > Save All from Menu Bar"); Session.ExecuteCommand (FileCommands.SaveAll); TakeScreenShot ("Inserted-Newline-SaveAll-Called"); @@ -158,6 +180,26 @@ namespace UserInterfaceTests } catch (TimeoutException e) { } } + protected void EnterGitUserConfig (string gitUser, string gitEmail) + { + Session.ToggleElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().CheckButton ().Marked ("repoConfigRadio"), true); + + Session.EnterText (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().Textfield ().Marked ("usernameEntry"), gitUser); + Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().Textfield ().Marked ("usernameEntry").Text (gitUser)); + + Session.EnterText (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().Textfield ().Marked ("emailEntry"), gitEmail); + Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().Textfield ().Marked ("emailEntry").Text (gitEmail)); + + TakeScreenShot ("Git-User-Email-Filled"); + Session.ClickElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog").Children ().Button ().Marked ("buttonOk")); + if (Session.Query (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserInfoConflictDialog")).Length > 0) { + TakeScreenShot ("Provided-User-Details-Mismatch"); + Session.ToggleElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserInfoConflictDialog").Children ().CheckButton ().Marked ("radiobutton2"), true); + TakeScreenShot ("Selected-Use-Git-Config"); + Session.ClickElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserInfoConflictDialog").Children ().Button ().Marked ("buttonOk")); + } + } + protected void CheckIfUserConflict () { try { |