diff options
author | Matt Ward <matt.ward@xamarin.com> | 2015-11-19 12:43:19 +0300 |
---|---|---|
committer | Matt Ward <matt.ward@xamarin.com> | 2015-11-19 12:43:19 +0300 |
commit | 3464fad275c48d7c4ffb3602dfcc66afa467b76a (patch) | |
tree | 10db040d0a2cf55165ac8d43dd24b60ca297a887 /main/tests/UserInterfaceTests/VersionControlTests | |
parent | d94562154c646871e5af85aeb9eca1ece86776f9 (diff) | |
parent | 203ed0aabb6a60c7bb18f3b7b490588ab09cf38e (diff) |
Merge branch 'master' into aspnet-project-wizard
Conflicts:
main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj
main/tests/UnitTests/UnitTests.csproj
Diffstat (limited to 'main/tests/UserInterfaceTests/VersionControlTests')
-rw-r--r-- | main/tests/UserInterfaceTests/VersionControlTests/Git/GitBase.cs | 478 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/VersionControlTests/Git/GitRepositoryConfigurationTests.cs | 356 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/VersionControlTests/Git/GitStashManagerTests.cs | 119 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/VersionControlTests/Git/GitTests.cs (renamed from main/tests/UserInterfaceTests/VersionControlTests/GitTests.cs) | 45 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/VersionControlTests/GitRepositoryConfigurationTests.cs | 310 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/VersionControlTests/VCSBase.cs | 106 |
6 files changed, 1067 insertions, 347 deletions
diff --git a/main/tests/UserInterfaceTests/VersionControlTests/Git/GitBase.cs b/main/tests/UserInterfaceTests/VersionControlTests/Git/GitBase.cs new file mode 100644 index 0000000000..293015c5f9 --- /dev/null +++ b/main/tests/UserInterfaceTests/VersionControlTests/Git/GitBase.cs @@ -0,0 +1,478 @@ +// +// GitBase.cs +// +// Author: +// Manish Sinha <manish.sinha@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using MonoDevelop.Components.AutoTest; +using NUnit.Framework; + +namespace UserInterfaceTests +{ + public abstract class GitBase : VCSBase + { + static string notString = "not"; + + #region Git Repository Configuration + + #region Remotes + + Func<AppQuery, AppQuery> remoteTreeName = c => c.TreeView ().Marked ("treeRemotes").Model ("storeRemotes__Name"); + Func<AppQuery, AppQuery> remoteTreeUrl = c => c.TreeView ().Marked ("treeRemotes").Model ("storeRemotes__Url"); + Func<AppQuery, AppQuery> remoteTreeFullName = c => c.TreeView ().Marked ("treeRemotes").Model ("storeRemotes__FullName"); + + protected void AssertRemotesButtonSensitivity (bool editSensitivity, bool removeSensitivity, bool trackSensitivity, bool fetchSensitivity) + { + AssertButtonSensitivity ("Add", true); + AssertButtonSensitivity ("Edit", editSensitivity); + AssertButtonSensitivity ("Remove", removeSensitivity); + AssertButtonSensitivity ("Track in Local Branch", trackSensitivity); + AssertButtonSensitivity ("Fetch", fetchSensitivity); + } + + protected void SelectRemote (string remoteName, string remoteUrl = null) + { + ReproStep (string.Format ("Select a remote named '{0}' {1}", remoteName, + remoteUrl != null ? string.Format (" and Remote URL '{0}'", remoteUrl) : string.Empty)); + Session.WaitForElement (c => remoteTreeName (c).Contains (remoteName)); + + try { + Assert.IsTrue (Session.SelectElement (c => remoteTreeName (c).Contains (remoteName))); + } catch (AssertionException) { + ReproFailedStep (string.Format ("Remote Name '{0}' exists", remoteName), string.Format ("Remote Name '{0}' does not exists", remoteName)); + throw; + } + if (remoteUrl != null) { + try { + Assert.IsTrue (Session.SelectElement (c => remoteTreeUrl (c).Contains (remoteUrl))); + } catch (AssertionException) { + ReproFailedStep (string.Format ("Remote URL '{0}' with Name '{1}' exists", remoteUrl, remoteName), + string.Format ("Remote URL '{0}' with Name '{1}' does not exist", remoteUrl, remoteName)); + throw; + } + } + TakeScreenShot (string.Format ("{0}-Remote-Selected", remoteName)); + } + + protected void EditRemote (string newRemoteName, string remoteUrl, string remotePushUrl = null) + { + ReproStep ("Click on Edit"); + AddEditRemote ("buttonEditRemote", newRemoteName, remoteUrl, remotePushUrl); + } + + protected void AddRemote (string newRemoteName, string remoteUrl, string remotePushUrl = null) + { + ReproStep ("Click on Add"); + AddEditRemote ("buttonAddRemote", newRemoteName, remoteUrl, remotePushUrl); + } + + protected void FetchRemoteBranch (string remoteName) + { + SelectRemote (remoteName); + + Assert.IsEmpty (Session.Query (c => remoteTreeFullName (c).Contains (remoteName+"/"))); + Assert.IsTrue (Session.ClickElement (c => IdeQuery.GitConfigurationDialog (c).Children ().Button ().Text ("Fetch"))); + TakeScreenShot ("Fetch-Remote"); + + SelectRemoteBranch (remoteName); + } + + protected void SelectRemoteBranch (string remoteName, string remoteBranchName = null) + { + Session.ClickElement (c => remoteTreeName (c).Contains (remoteName)); + Assert.IsNotEmpty (Session.Query (c => remoteTreeFullName (c).Contains (remoteName+"/"+remoteBranchName))); + + var expected = string.Format ("Select the Remote with Name '{0}' and Remote Branch Name '{1}'", remoteName, remoteBranchName); + try { + ReproStep (expected); + Assert.IsTrue (Session.SelectElement (c => remoteTreeFullName (c).Contains (remoteName + "/" + remoteBranchName).Index (0))); + } catch (AssertionException) { + ReproFailedStep (expected, "Could not "+expected); + throw; + } + TakeScreenShot (string.Format ("{0}-Remote-Branch-Selected", remoteBranchName ?? "First")); + } + + void AddEditRemote (string buttonName, string newRemoteName, string remoteUrl, string remotePushUrl) + { + Assert.IsNotEmpty (Session.Query (c => IdeQuery.GitConfigurationDialog (c).Children ().Button ().Marked (buttonName))); + Session.ClickElement (c => IdeQuery.GitConfigurationDialog (c).Children ().Button ().Marked (buttonName), false); + Session.WaitForElement (IdeQuery.EditRemoteDialog); + + ReproStep (string.Format ("Enter Remote name as '{0}'", newRemoteName)); + Func<AppQuery, AppQuery> EditRemoteDialogChildren = c => IdeQuery.EditRemoteDialog (c).Children (); + Assert.IsTrue (Session.EnterText (c => EditRemoteDialogChildren (c).Textfield ().Marked ("entryName"), newRemoteName)); + Session.WaitForElement (c => EditRemoteDialogChildren (c).Textfield ().Marked ("entryName").Text (newRemoteName)); + + ReproStep (string.Format ("Enter Remote URL as '{0}'", remoteUrl)); + Assert.IsTrue (Session.EnterText (c => EditRemoteDialogChildren (c).Textfield ().Marked ("entryUrl"), remoteUrl)); + Session.WaitForElement (c => EditRemoteDialogChildren (c).Marked ("entryUrl").Text (remoteUrl)); + + ReproStep (string.Format ("Enter Remote Push URL as '{0}'", remotePushUrl ?? remoteUrl)); + Assert.IsTrue (Session.EnterText (c => EditRemoteDialogChildren (c).Textfield ().Marked ("entryPushUrl"), remotePushUrl ?? remoteUrl)); + Session.WaitForElement (c => EditRemoteDialogChildren (c).Textfield ().Marked ("entryPushUrl").Text (remotePushUrl ?? remoteUrl)); + TakeScreenShot ("Remote-Details-Filled"); + + ReproStep ("Click on OK"); + Assert.IsTrue (Session.ClickElement (c => EditRemoteDialogChildren (c).Button ().Marked ("buttonOk"))); + Session.WaitForNoElement (IdeQuery.EditRemoteDialog); + Session.WaitForElement (IdeQuery.GitConfigurationDialog); + TakeScreenShot ("Remote-Edit-Dialog-Closed"); + } + + protected void DeleteRemote (string remoteName) + { + Session.WaitForElement (c => remoteTreeName (c).Contains (remoteName)); + ReproStep ("Click on Remove"); + Session.ClickElement (c => IdeQuery.GitConfigurationDialog(c).Children ().Button ().Text ("Remove"), false); + TakeScreenShot (string.Format ("Remove-Remote-{0}", remoteName)); + + ReproStep ("When prompted to confirm, click Delete"); + Ide.ClickButtonAlertDialog ("Delete"); + Session.WaitForElement (IdeQuery.GitConfigurationDialog); + } + + #endregion + + #region Tags + + Func<AppQuery, AppQuery> tagTreeName = c => c.TreeView ().Marked ("listTags").Model ("storeTags__Name"); + + protected void AssertTagsButtonSensitivity (bool pushSensitivity, bool deleteSensitivity) + { + AssertButtonSensitivity ("New", true); + AssertButtonSensitivity ("Push", pushSensitivity); + AssertButtonSensitivity ("Delete", deleteSensitivity); + } + + protected void SelectTag (string tagName) + { + WaitForElement (c => tagTreeName (c).Text (tagName), + string.Format ("Tag '{0}' should be available", tagName), + string.Format ("Tag '{0}' it not available", tagName)); + try { + Assert.IsTrue (Session.SelectElement (c => tagTreeName (c).Text (tagName)), "Failed to select tag: " + tagName); + } catch (AssertionException) { + ReproFailedStep (string.Format ("Tag '{0}' should be selected", tagName), + string.Format ("Tag '{0}' cannot be selected", tagName)); + throw; + } + TakeScreenShot (string.Format ("{0}-Tag-Selected", tagName)); + } + + protected void DeleteTag (string tagName) + { + SelectTag (tagName); + ReproStep ("Click Delete"); + try { + Assert.IsTrue ((Session.ClickElement (c => IdeQuery.GitConfigurationDialog (c).Children ().Button ().Marked ("buttonRemoveTag")))); + } catch (AssertionException) { + ReproFailedStep (string.Format ("Tag '{0}' should be removed", tagName), string.Format ("Tag '{0}' could not be removed", tagName)); + throw; + } + Session.WaitForNoElement (c => tagTreeName (c).Text (tagName)); + } + + protected void AddNewTag (string tagName, string tagMessage = null, string commitMsg = null) + { + ReproStep ("Click on New"); + Session.ClickElement (c => IdeQuery.GitConfigurationDialog (c).Children ().Button ().Marked ("buttonAddTag"), false); + + ReproStep ("Wait for 'Select a Revision' dialog to open"); + try { + Session.WaitForElement (c => c.Window ().Marked ("Select a revision")); + } catch (AssertionException) { + ReproFailedStep ("'Select a Revision' dialog should open", "'Select a Revision' dialog did not open"); + throw; + } + + ReproStep ("Enter the Tag Name"); + Session.EnterText (c => c.Window ().Marked ("Select a revision").Children ().Textfield ().Index (0), tagName); + Session.WaitForElement (c => c.Window ().Marked ("Select a revision").Children ().Textfield ().Index (0).Text (tagName)); + TakeScreenShot ("Tag-Name-Entered"); + + if (!string.IsNullOrEmpty (tagMessage)) { + ReproStep ("Enter a Tag Message"); + Session.EnterText (c => c.Window ().Marked ("Select a revision").Children ().Textfield ().Index (1), tagMessage); + Session.WaitForElement (c => c.Window ().Marked ("Select a revision").Children ().Textfield ().Index (1).Text (tagMessage)); + TakeScreenShot ("Tag-Message-Entered"); + } + + Func<AppQuery, AppQuery> revisionsTreeView = c => c.Window ().Marked ("Select a revision").Children ().TreeView ().Index (0).Model ().Children (); + if (!string.IsNullOrEmpty (commitMsg)) { + ReproStep (string.Format ("Select the commit with message '{0}'", commitMsg)); + Session.SelectElement (c => revisionsTreeView (c).Text (commitMsg)); + } else { + ReproStep ("Select the first commit"); + Session.SelectElement (c => revisionsTreeView (c).Index (0)); + } + TakeScreenShot ("Commit-Message-Selected"); + + ReproStep ("Click OK"); + Session.ClickElement (c => c.Window ().Marked ("Select a revision").Children ().Button ().Text ("Ok")); + try { + Session.WaitForElement (IdeQuery.GitConfigurationDialog); + TakeScreenShot ("Git-User-Not-Configured"); + EnterGitUserConfig ("John Doe", "john.doe@example.com"); + } catch (TimeoutException e) { } + Session.WaitForElement (c => IdeQuery.GitConfigurationDialog (c)); + TakeScreenShot ("Ok-Clicked"); + } + + #endregion + + #region Branches + + Func<AppQuery, AppQuery> branchDisplayName = c => c.TreeView ().Marked ("listBranches").Model ("storeBranches__DisplayName"); + + protected void AssertBranchesButtonSensitivity (bool editSensitivity, bool deleteSensitivity, bool switchSensitivity) + { + AssertButtonSensitivity ("New", true); + AssertButtonSensitivity ("Edit", editSensitivity); + AssertButtonSensitivity ("Delete", deleteSensitivity); + AssertButtonSensitivity ("Switch to Branch", switchSensitivity); + } + + protected void CreateNewBranch (string newBranchName) + { + ReproStep ("Click New"); + CreateEditBranch ("buttonAddBranch", newBranchName); + } + + protected void EditBranch (string oldBranchName, string newBranchName) + { + SelectBranch (oldBranchName); + ReproStep ("Click Edit"); + CreateEditBranch ("buttonEditBranch", newBranchName); + } + + protected void CreateEditBranch (string buttonName, string newBranchName) + { + Session.ClickElement (c => IdeQuery.GitConfigurationDialog(c).Children ().Button ().Marked (buttonName), false); + + ReproStep ("Wait for Branch Properties dialog"); + WaitForElement (IdeQuery.EditBranchDialog, "Branch Properties dialog opens", "Branch Properties dialog does not open"); + TakeScreenShot ("Edit-Branch-Dialog-Opened"); + + EnterBranchName (newBranchName); + Session.WaitForElement (IdeQuery.GitConfigurationDialog); + TakeScreenShot ("Edit-Branch-Dialog-Opened-Closed"); + } + + protected void EnterBranchName (string newBranchName) + { + ReproStep ("Enter branch name"); + Session.EnterText (c => IdeQuery.EditBranchDialog (c).Children ().Textfield ().Marked ("entryName"), newBranchName); + Session.WaitForElement (c => IdeQuery.EditBranchDialog (c).Children ().Textfield ().Marked ("entryName").Text (newBranchName)); + TakeScreenShot ("Branch-Name-Entered"); + + ReproStep ("Click OK"); + Assert.IsTrue (Session.ClickElement (c => IdeQuery.EditBranchDialog (c).Children ().Button ().Marked ("buttonOk"))); + } + + protected void SwitchToBranch (string branchName) + { + SelectBranch (branchName); + TakeScreenShot (string.Format ("{0}-Branch-Selected", branchName)); + + ReproStep ("Click on 'Switch to Branch'"); + Session.ClickElement (c => IdeQuery.GitConfigurationDialog(c).Children ().Button ().Text ("Switch to Branch"), false); + CheckIfNameEmailNeeded (); + CheckIfUserConflict (); + ReproStep ("Check if the selected branch is bold"); + try { + Assert.IsTrue (IsBranchSwitched (branchName)); + } catch (AssertionException) { + ReproFailedStep ("The selected branch should be bold", "The selected branch is not bold"); + throw; + } + TakeScreenShot (string.Format ("Switched-To-{0}", branchName)); + } + + protected void SwitchTab (string tabName) + { + ReproStep (string.Format ("Select the '{0}' tab", tabName)); + try { + Assert.IsTrue (Session.SelectElement (c => IdeQuery.GitConfigurationDialog (c).Children ().Notebook ().Marked ("notebook1").Text (tabName))); + } catch (AssertionException) { + ReproFailedStep (string.Format ("Tab '{0}' is selected", tabName), string.Format ("Tab '{0}' is not selected", tabName)); + throw; + } + TakeScreenShot (string.Format ("Tab-Changed-{0}", GenerateProjectName (tabName))); + } + + protected void SelectBranch (string branchName) + { + ReproStep (string.Format ("Select the '{0}' branch", branchName)); + try { + Assert.IsTrue (Session.SelectElement (c => branchDisplayName (c).Contains (branchName))); + } catch (AssertionException) { + ReproFailedStep (string.Format ("Branch '{0}' is selected", branchName), string.Format ("Branch '{0}' is not selected", branchName)); + throw; + } + TakeScreenShot (string.Format ("Selected-Branch-{0}", branchName.ToPathSafeString ())); + } + + protected void DeleteBranch (string branchName) + { + SelectBranch (branchName); + ReproStep ("Press Delete"); + Session.ClickElement (c => IdeQuery.GitConfigurationDialog (c).Children ().Button ().Text ("Delete"), false); + TakeScreenShot (string.Format ("Delete-Branch-{0}", branchName)); + ReproStep ("If prompted for confirmation, press Delete"); + Ide.ClickButtonAlertDialog ("Delete"); + Session.WaitForElement (IdeQuery.GitConfigurationDialog); + } + + protected bool IsBranchSwitched (string branchName) + { + try { + WaitForElement (c => branchDisplayName (c).Text ("<b>" + branchName + "</b>"), + string.Format ("Branch '{0}' is checked out", branchName), + string.Format ("Branch '{0}' is not checked out", branchName)); + return true; + } catch (TimeoutException) { + return false; + } + } + + #endregion + + protected void OpenRepositoryConfiguration (string selectTab = null) + { + ReproStep ("Click Version Control > Manage Branches and Remotes"); + Session.ExecuteCommand (MonoDevelop.VersionControl.Git.Commands.ManageBranches); + + WaitForElement (IdeQuery.GitConfigurationDialog, + "Git Repository Configuration Dialog should open", + "Git Repository Configuration Dialog did not open"); + TakeScreenShot ("Repository-Configuration-Opened"); + + if (selectTab != null) + SwitchTab (selectTab); + } + + protected void CloseRepositoryConfiguration () + { + ReproStep ("Click on Close button of Git Repository Configuration Dialog"); + Session.ClickElement (c => IdeQuery.GitConfigurationDialog(c).Children ().Button ().Marked ("buttonOk")); + TakeScreenShot ("Git-Repository-Configuration-Closed"); + Session.WaitForNoElement (IdeQuery.GitConfigurationDialog); + } + + protected void AssertButtonSensitivity (string buttonLabel, bool sensitivity) + { + var expected = string.Format ("{0} button is {1} enabled", buttonLabel, !sensitivity ? notString : string.Empty); + var actual = string.Format ("{0} button is {1} enabled", buttonLabel, sensitivity ? notString : string.Empty); + try { + Assert.IsNotEmpty (Session.Query (c => c.Button ().Text (buttonLabel).Sensitivity (sensitivity)), actual); + } catch (AssertionException) { + ReproFailedStep (expected, actual); + throw; + } + } + + #endregion + + #region Stash Manager + + protected Func<AppQuery, AppQuery> StashEntries = c => c.Window ().Marked ( + "Stash Manager").Children ().TreeView ().Marked ("list").Model ().Children (); + + protected void OpenStashManager () + { + ReproStep ("Click on Version Control > Manage Stashes"); + Session.ExecuteCommand ("MonoDevelop.VersionControl.Git.Commands.ManageStashes"); + WaitForElement (c => c.Window ().Marked ("Stash Manager"), "Stash Manager dialog should open", "Stash Manager dialog did not open"); + TakeScreenShot ("StashManager-Opened"); + } + + protected void CloseStashManager () + { + ReproStep ("On Stash Manager, click Close button"); + Session.ClickElement (c => c.Window ().Marked ("Stash Manager").Children ().Text ("Close")); + Session.WaitForElement (IdeQuery.TextArea); + TakeScreenShot ("StashManager-Closed"); + } + + protected void SelectStashEntry (int index = 0) + { + ReproStep ("Select the stash entry #{0}", index+1); + WaitForElement (c => StashEntries (c).Index (index), "Select stash entry: "+index+1, "Could not select that stash entry"); + Session.SelectElement (c => StashEntries (c).Index (index)); + } + + protected void RemoveStash (int index) + { + SelectStashEntry (index); + TakeScreenShot ("About-To-Click-Remove"); + try { + ReproStep ("Click on Remove"); + Assert.IsTrue (Session.ClickElement (c => c.Window ().Marked ("Stash Manager").Children ().Button ().Text ("Remove"))); + } catch (AssertionException) { + ReproFailedStep ("Stash should be removed", "Stash failed to remove"); + throw; + } + Session.WaitForElement (c => c.Window ().Marked ("Stash Manager")); + } + + protected void ApplyAndRemoveStash (int index) + { + SelectStashEntry (index); + TakeScreenShot ("About-To-Click-Apply-and-Remove"); + try { + ReproStep ("Click on 'Apply and Remove'"); + Assert.IsTrue (Session.ClickElement (c => c.Window ().Marked ("Stash Manager").Children ().Button ().Text ("Apply and Remove"))); + } catch (AssertionException) { + ReproFailedStep ("Stash should be applied and removed from the list", "Stash failed to applied and removed from the list"); + throw; + } + } + + protected void ApplyStash (int index) + { + SelectStashEntry (index); + TakeScreenShot ("About-To-Click-Apply"); + try { + ReproStep ("Click on Apply"); + Assert.IsTrue (Session.ClickElement (c => c.Window ().Marked ("Stash Manager").Children ().Button ().Text ("Apply"))); + } catch (AssertionException) { + ReproFailedStep ("Stash should be applied", "Stash failed to apply"); + throw; + } + } + + protected void ComvertToBranch (int index, string branchName) + { + SelectStashEntry (index); + TakeScreenShot ("About-To-Click-Convert-To-Branch"); + ReproStep ("Click on 'Convert to Branch'"); + Session.ClickElement (c => c.Window ().Marked ("Stash Manager").Children ().Button ().Text ("Convert to Branch"), false); + EnterBranchName (branchName); + Ide.WaitForStatusMessage (new [] { "Stash successfully applied" }); + } + + #endregion + } +} + diff --git a/main/tests/UserInterfaceTests/VersionControlTests/Git/GitRepositoryConfigurationTests.cs b/main/tests/UserInterfaceTests/VersionControlTests/Git/GitRepositoryConfigurationTests.cs new file mode 100644 index 0000000000..1c5c9eb52a --- /dev/null +++ b/main/tests/UserInterfaceTests/VersionControlTests/Git/GitRepositoryConfigurationTests.cs @@ -0,0 +1,356 @@ +// +// GitRepositoryConfigurationTests.cs +// +// Author: +// Manish Sinha <manish.sinha@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System;
+using NUnit.Framework; + +namespace UserInterfaceTests +{ + [TestFixture, Timeout(90000)] + [Category ("GitConfig")] + public class GitRepositoryConfigurationTests : GitBase + { + const string gtkSharpUrl = "https://github.com/mono/gtk-sharp.git"; + const string monoHotdrawUrl = "https://github.com/mono/monocov.git"; + + #region Branch Tab + + [Test] + [Description ("Check that Edit, Switch, Switch to Branch are enabled only when a branch is selected")] + public void CheckBranchButtonsSensitivity () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration ("Branches"); + + TakeScreenShot ("Asserting-Edit-Delete-Switch-Button-Disabled"); + AssertBranchesButtonSensitivity (false, false, false); + SelectBranch ("<b>master</b>"); + TakeScreenShot ("Asserting-Edit-Switch-Button-Enabled"); + AssertBranchesButtonSensitivity (true, false, false); + CreateNewBranch ("new-branch"); + SelectBranch ("new-branch"); + TakeScreenShot ("Asserting-Edit-Delete-Switch-Button-Enabled"); + AssertBranchesButtonSensitivity (true, true, true); + + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Create a New Branch")] + public void CreateNewBranchTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration (); + CreateNewBranch ("new-branch"); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Create a New Branch and switch to it")] + public void GitSwitchBranchTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration (); + CreateNewBranch ("new-branch"); + SwitchToBranch ("new-branch"); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Create a New Branch, select it and edit the name and switch to it")] + public void GitEditBranchTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration (); + CreateNewBranch ("new-branch"); + SelectBranch ("new-branch"); + EditBranch ("new-branch", "new-new-branch"); + SwitchToBranch ("new-new-branch"); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Create a new branch, select it and delete it")] + public void GitDeleteBranchTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration (); + CreateNewBranch ("new-branch"); + SelectBranch ("new-branch"); + DeleteBranch ("new-branch"); + + CloseRepositoryConfiguration (); + } + + #endregion + + #region Tag + + [Test] + [Description ("Check that Push and Delete button are enabled only when a tag is selected")] + public void CheckTagButtonsSensitivity () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration ("Tags"); + + TakeScreenShot ("Asserting-Push-Delete-Button-Disabled"); + AssertTagsButtonSensitivity (false, false); + SelectTag ("1.0.10"); + TakeScreenShot ("Asserting-Push-Delete-Button-Enabled"); + AssertTagsButtonSensitivity (true, true); + + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Create a new tag with tag name, tag message and by selecting a specific commit message")] + public void AddTag () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration ("Tags"); + + AddNewTag ("bumped", "bumped tag", "build: Bump mono dependency to 3.2.8"); + SelectTag ("bumped"); + TakeScreenShot ("New-Tag-Selected"); + + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Clone a repo, open Tag tab, select a tag by name and delete it")] + public void DeleteTag () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration ("Tags"); + DeleteTag ("1.0.10"); + CloseRepositoryConfiguration (); + } + + #endregion + + #region Remotes Tab + + [Test] + [Description ("Check that Edit, Remove, Fetch button are enabled only when a remote is selected and 'Track in Local' only when a remote branch is selected")] + public void CheckRemoteButtonsSensitivity () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration ("Remote Sources"); + + TakeScreenShot ("Asserting-Edit-Remove-Track--Fetch-Button-Disabled"); + AssertRemotesButtonSensitivity (false, false, false, false); + SelectRemote ("origin"); + TakeScreenShot ("Asserting-Edit-Switch-Button-Enabled"); + AssertRemotesButtonSensitivity (true, true, false, true); + SelectRemoteBranch ("origin", "master"); + TakeScreenShot ("Asserting-Edit-Switch-Button-Track-Enabled"); + AssertRemotesButtonSensitivity (true, true, true, true); + + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Clone a repo and select a remote")] + public void SelectRemoteTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration ("Remote Sources"); + SelectRemote ("origin"); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Clone a repo, add a new remote and select that added remote")] + public void AddGitRemoteTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + const string newRemoteName = "second"; + const string newRemoteUrl = monoHotdrawUrl; + OpenRepositoryConfiguration ("Remote Sources"); + AddRemote (newRemoteName, newRemoteUrl); + SelectRemote (newRemoteName, newRemoteUrl); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Clone a repo, add a new remote, select it and delete it")] + public void DeleteGitRemoteTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + const string newRemoteName = "second"; + const string newRemoteUrl = monoHotdrawUrl; + OpenRepositoryConfiguration ("Remote Sources"); + AddRemote (newRemoteName, newRemoteUrl); + SelectRemote (newRemoteName, newRemoteUrl); + DeleteRemote (newRemoteName); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Edit only Remote Name, don't edit URL or Push URL")] + public void EditGitRemoteNameTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration ("Remote Sources"); + + const string newRemoteName = "second"; + const string newRemoteUrl = monoHotdrawUrl; + AddRemote (newRemoteName, newRemoteUrl); + SelectRemote (newRemoteName, newRemoteUrl); + + const string updatedRemoteName = "second-origin"; + const string updatedRemoteUrl = monoHotdrawUrl; + EditRemote (updatedRemoteName, updatedRemoteUrl, updatedRemoteUrl); + SelectRemote (updatedRemoteName, updatedRemoteUrl); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Edit only Remote Name and URL, don't edit Push URL")] + public void EditGitRemoteNameAndUrlTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration ("Remote Sources"); + + const string newRemoteName = "second"; + const string newRemoteUrl = monoHotdrawUrl; + AddRemote (newRemoteName, newRemoteUrl); + SelectRemote (newRemoteName, newRemoteUrl); + + const string updatedRemoteName = "second-origin"; + const string updatedRemoteUrl = monoHotdrawUrl; + EditRemote (updatedRemoteName, updatedRemoteUrl, newRemoteUrl); + SelectRemote (updatedRemoteName, updatedRemoteUrl); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Edit only Remote Name and Push URL, don't edit URL")] + public void EditGitRemoteNameAndPushUrlTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration ("Remote Sources"); + + const string newRemoteName = "second"; + const string newRemoteUrl = monoHotdrawUrl; + AddRemote (newRemoteName, newRemoteUrl); + SelectRemote (newRemoteName, newRemoteUrl); + + const string updatedRemoteName = "second-origin"; + const string updatedRemoteUrl = monoHotdrawUrl; + EditRemote (updatedRemoteName, updatedRemoteUrl, monoHotdrawUrl); + SelectRemote (updatedRemoteName, updatedRemoteUrl); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Edit only Remote URL and Push URL, don't edit Name")] + public void EditGitRemoteUrlTest () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + OpenRepositoryConfiguration ("Remote Sources"); + + const string newRemoteName = "second"; + const string newRemoteUrl = monoHotdrawUrl; + AddRemote (newRemoteName, newRemoteUrl); + SelectRemote (newRemoteName, newRemoteUrl); + + const string updatedRemoteUrl = monoHotdrawUrl; + EditRemote (newRemoteName, updatedRemoteUrl, updatedRemoteUrl); + SelectRemote (newRemoteName, updatedRemoteUrl); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Clone a repo, add a new remote and fetch the remote branches for that remote")] + public void FetchRemoteBranches () + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + const string newRemoteName = "second"; + const string newRemoteUrl = monoHotdrawUrl; + OpenRepositoryConfiguration ("Remote Sources"); + AddRemote (newRemoteName, newRemoteUrl); + FetchRemoteBranch (newRemoteName); + CloseRepositoryConfiguration (); + } + + [Test] + [Description ("Clone a repo, add a new remote, fetch the remote branch, chose a branch and track it in local. Select that branch in Branches tab")] + public void TrackRemoteBranchInLocalTest() + { + TestClone (gtkSharpUrl); + Ide.WaitForSolutionCheckedOut (); + + const string newRemoteName = "second"; + const string newRemoteUrl = monoHotdrawUrl; + OpenRepositoryConfiguration ("Remote Sources"); + AddRemote (newRemoteName, newRemoteUrl); + FetchRemoteBranch (newRemoteName); + const string localBranch = "local-branch-random-uitest"; + CreateEditBranch ("buttonTrackRemote", localBranch); + SwitchTab ("Branches"); + SelectBranch (localBranch); + CloseRepositoryConfiguration (); + } + + #endregion + } +} + diff --git a/main/tests/UserInterfaceTests/VersionControlTests/Git/GitStashManagerTests.cs b/main/tests/UserInterfaceTests/VersionControlTests/Git/GitStashManagerTests.cs new file mode 100644 index 0000000000..71736ae25e --- /dev/null +++ b/main/tests/UserInterfaceTests/VersionControlTests/Git/GitStashManagerTests.cs @@ -0,0 +1,119 @@ +// +// GitStashManagerTests.cs +// +// Author: +// Manish Sinha <manish.sinha@xamarin.com> +// +// Copyright (c) 2015 Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using NUnit.Framework; +using System; +using MonoDevelop.Ide.Commands; +using MonoDevelop.Components.AutoTest; + +namespace UserInterfaceTests +{ + [TestFixture, Timeout(60000)] + [Category ("Git")] + [Category ("StashManager")] + public class GitStashManagerTests : GitBase + { + [Test] + [Description ("Create a project with git, commit changes. Make changes and stash. Remove stash from Stash Manager")] + public void GitRemoveStashTest () + { + CreateProjectAndCommitAndStash (); + + OpenStashManager (); + RemoveStash (0); + Assert.IsEmpty (Session.Query (StashEntries)); + CloseStashManager (); + } + + [Test] + [Description ("Create a project with git, commit changes. Make changes and stash. Apply and Remove stash from Stash Manager")] + public void GitApplyAndRemoveStashTest () + { + CreateProjectAndCommitAndStash (); + + OpenStashManager (); + ApplyAndRemoveStash (0); + + Session.WaitForElement (IdeQuery.TextArea); + TakeScreenShot ("Stash-Applied"); + OpenStashManager (); + + TakeScreenShot ("Asserting-if-Not-Stash-Present"); + Session.WaitForNoElement (StashEntries); + CloseStashManager (); + } + + [Test] + [Description ("Create a project with git, commit changes. Make changes and stash. Apply stash from Stash Manager")] + public void GitApplyStashTest () + { + CreateProjectAndCommitAndStash (); + + OpenStashManager (); + ApplyStash (0); + OpenStashManager (); + + TakeScreenShot ("Asserting-if-Stash-Still-Present"); + Assert.IsNotEmpty (Session.Query (StashEntries)); + CloseStashManager (); + } + + [Test] + [Description ("Create a project with git, commit changes. Make changes and stash. Convert stash to branch from Stash Manager")] + public void GitStashConvertToBranchTest () + { + CreateProjectAndCommitAndStash (); + + var branchName = "sample-branch"; + OpenStashManager (); + ComvertToBranch (0, branchName); + OpenStashManager (); + TakeScreenShot ("Asserting-if-Stash-Still-Present"); + Assert.IsEmpty (Session.Query (StashEntries)); + CloseStashManager (); + + OpenRepositoryConfiguration ("Branches"); + IsBranchSwitched (branchName); + CloseRepositoryConfiguration (); + } + + void CreateProjectAndCommitAndStash () + { + var templateOptions = new TemplateSelectionOptions { + CategoryRoot = OtherCategoryRoot, + Category = ".NET", + TemplateKindRoot = GeneralKindRoot, + TemplateKind = "Console Project" + }; + GitCreateAndCommit (templateOptions, "First commit"); + var changeDescription = MakeSomeChangesAndSaveAll ("Program.cs"); + TestGitStash (changeDescription); + Session.WaitForElement (IdeQuery.TextArea, 20000); + TakeScreenShot ("After-Stash"); + } + } +} + diff --git a/main/tests/UserInterfaceTests/VersionControlTests/GitTests.cs b/main/tests/UserInterfaceTests/VersionControlTests/Git/GitTests.cs index 471b8a94ff..2bf26bcb52 100644 --- a/main/tests/UserInterfaceTests/VersionControlTests/GitTests.cs +++ b/main/tests/UserInterfaceTests/VersionControlTests/Git/GitTests.cs @@ -30,20 +30,22 @@ using NUnit.Framework; namespace UserInterfaceTests { - [TestFixture] + [TestFixture, Timeout(60000)] [Category ("Git")] + [Category ("GitBase")] public class GitTests : VCSBase { - [Test] - [TestCase ("git@github.com:mono/jurassic.git", TestName = "TestGitSSHClone")] - [TestCase ("https://github.com/mono/jurassic.git", TestName = "TestGitHTTPSClone")] + [Test, Timeout(120000), Category("Smoke")] + [TestCase ("git@github.com:mono/gtk-sharp.git", TestName = "TestGitSSHClone", Description = "Clone Git repo over SSH")] + [TestCase ("https://github.com/mono/gtk-sharp.git", TestName = "TestGitHTTPSClone", Description = "Clone Git repo over HTTPS")] public void TestGitClone (string url) { TestClone (url); - Ide.WaitForSolutionCheckedOut (); + Ide.WaitForIdeIdle (); } - [Test] + [Test, Category("Smoke")] + [Description ("Create a new project with Git and commit the changes")] public void TestCommit () { var templateOptions = new TemplateSelectionOptions { @@ -52,15 +54,11 @@ namespace UserInterfaceTests TemplateKindRoot = GeneralKindRoot, TemplateKind = "Console Project" }; - CreateProject (templateOptions, - new ProjectDetails (templateOptions), - new GitOptions { UseGit = true, UseGitIgnore = true}); - - Session.WaitForElement (IdeQuery.TextArea); - TestCommit ("First commit"); + GitCreateAndCommit (templateOptions, "First commit"); } [Test] + [Description ("Create a new project and try to stash without any changes, it should not be allowed")] public void TestNoChangesStashOperation () { var templateOptions = new TemplateSelectionOptions { @@ -81,6 +79,7 @@ namespace UserInterfaceTests } [Test] + [Description ("Create a new project and try to stash without HEAD commit, it should not be allowed")] public void TestStashWithoutHeadCommit () { var templateOptions = new TemplateSelectionOptions { @@ -98,7 +97,8 @@ namespace UserInterfaceTests TakeScreenShot ("Stash-Window-Doesnt-Show"); } - [Test] + [Test, Category("Smoke")] + [Description ("Create a new project, make a commit, make changes. Stash and Unstash successfully")] public void TestStashAndUnstashSuccessful () { var templateOptions = new TemplateSelectionOptions { @@ -107,23 +107,10 @@ namespace UserInterfaceTests TemplateKindRoot = GeneralKindRoot, TemplateKind = "Console Project" }; - CreateProject (templateOptions, - new ProjectDetails (templateOptions), - new GitOptions { UseGit = true, UseGitIgnore = true }); - - Session.WaitForElement (IdeQuery.TextArea); - TestCommit ("First commit"); - - Session.ExecuteCommand (FileCommands.CloseFile); - Session.WaitForElement (IdeQuery.TextArea); - - Session.ExecuteCommand (TextEditorCommands.InsertNewLine); - TakeScreenShot ("Inserted-Newline-Marked-Dirty"); - Session.ExecuteCommand (FileCommands.SaveAll); - TakeScreenShot ("Inserted-Newline-SaveAll-Called"); - - TestGitStash ("Entered new blank line"); + GitCreateAndCommit (templateOptions, "First commit"); + var changeDescription = MakeSomeChangesAndSaveAll ("Program.cs"); + TestGitStash (changeDescription); Session.WaitForElement (IdeQuery.TextArea); TakeScreenShot ("After-Stash"); diff --git a/main/tests/UserInterfaceTests/VersionControlTests/GitRepositoryConfigurationTests.cs b/main/tests/UserInterfaceTests/VersionControlTests/GitRepositoryConfigurationTests.cs deleted file mode 100644 index 166f0ac4ec..0000000000 --- a/main/tests/UserInterfaceTests/VersionControlTests/GitRepositoryConfigurationTests.cs +++ /dev/null @@ -1,310 +0,0 @@ -// -// GitRepositoryConfigurationTests.cs -// -// Author: -// Manish Sinha <manish.sinha@xamarin.com> -// -// Copyright (c) 2015 Xamarin Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using NUnit.Framework; -using System; -using MonoDevelop.Ide.Commands; -using MonoDevelop.Components.AutoTest; - -namespace UserInterfaceTests -{ - [TestFixture] - [Category ("GitConfig")] - public class GitRepositoryConfigurationTests : GitRepositoryConfigurationBase - { - #region Branch Tab - - [Test] - public void CreateNewBranchTest () - { - TestClone ("git@github.com:mono/jurassic.git"); - Ide.WaitForSolutionCheckedOut (); - - OpenRepositoryConfiguration (); - CreateNewBranch ("new-branch"); - CloseRepositoryConfiguration (); - } - - [Test] - public void GitSwitchBranchTest () - { - TestClone ("git@github.com:mono/jurassic.git"); - Ide.WaitForSolutionCheckedOut (); - - OpenRepositoryConfiguration (); - CreateNewBranch ("new-branch"); - SwitchToBranch ("new-branch"); - CloseRepositoryConfiguration (); - } - - [Test] - public void GitEditBranchTest () - { - TestClone ("git@github.com:mono/jurassic.git"); - Ide.WaitForSolutionCheckedOut (); - - OpenRepositoryConfiguration (); - CreateNewBranch ("new-branch"); - SelectBranch ("new-branch"); - EditBranch ("new-branch", "new-new-branch"); - SwitchToBranch ("new-new-branch"); - CloseRepositoryConfiguration (); - } - - #endregion - - #region Remotes Tab - - [Test] - public void SelectRemoteTest () - { - TestClone ("git@github.com:mono/jurassic.git"); - Ide.WaitForSolutionCheckedOut (); - - OpenRepositoryConfiguration ("Remote Sources"); - SelectRemote ("origin"); - CloseRepositoryConfiguration (); - } - - [Test] - public void AddGitRemoteTest () - { - TestClone ("git@github.com:mono/jurassic.git"); - Ide.WaitForSolutionCheckedOut (); - - const string newRemoteName = "second"; - const string newRemoteUrl = "git@github.com:mono/monohotdraw.git"; - OpenRepositoryConfiguration ("Remote Sources"); - AddRemote (newRemoteName, newRemoteUrl); - SelectRemote (newRemoteName, newRemoteUrl); - CloseRepositoryConfiguration (); - } - - [Test] - [Ignore ("When OK is clicked on EditRemoteDialog, it doesn't update the list")] - public void EditGitRemoteTest () - { - TestClone ("git@github.com:mono/jurassic.git"); - Ide.WaitForSolutionCheckedOut (); - - OpenRepositoryConfiguration ("Remote Sources"); - - const string newRemoteName = "second"; - const string newRemoteUrl = "git@github.com:mono/monohotdraw.git"; - AddRemote (newRemoteName, newRemoteUrl); - SelectRemote (newRemoteName, newRemoteUrl); - - const string updatedRemoteName = "second-origin"; - const string updatedRemoteUrl = "git@github.com:mono/monohotdraw.git"; - EditRemote (updatedRemoteName, updatedRemoteUrl, "git@github.com:mono/monohotdraw-push.git"); - SelectRemote (updatedRemoteName, updatedRemoteUrl); - CloseRepositoryConfiguration (); - } - - [Test] - public void FetchRemoteBranches () - { - TestClone ("git@github.com:mono/jurassic.git"); - Ide.WaitForSolutionCheckedOut (); - - const string newRemoteName = "second"; - const string newRemoteUrl = "git@github.com:mono/monohotdraw.git"; - OpenRepositoryConfiguration ("Remote Sources"); - AddRemote (newRemoteName, newRemoteUrl); - FetchRemoteBranch (newRemoteName); - CloseRepositoryConfiguration (); - } - - [Test] - public void TrackRemoteBranchInLocalTest() - { - TestClone ("git@github.com:mono/jurassic.git"); - Ide.WaitForSolutionCheckedOut (); - - const string newRemoteName = "second"; - const string newRemoteUrl = "git@github.com:mono/monohotdraw.git"; - OpenRepositoryConfiguration ("Remote Sources"); - AddRemote (newRemoteName, newRemoteUrl); - FetchRemoteBranch (newRemoteName); - const string localBranch = "local-branch-random-uitest"; - CreateEditBranch ("buttonTrackRemote", localBranch); - SwitchTab ("Branches"); - SelectBranch (localBranch); - CloseRepositoryConfiguration (); - } - - #endregion - } - - public abstract class GitRepositoryConfigurationBase : VCSBase - { - #region Remotes - - Func<AppQuery, AppQuery> remoteTreeName = c => c.TreeView ().Marked ("treeRemotes").Model ("storeRemotes__Name"); - Func<AppQuery, AppQuery> remoteTreeUrl = c => c.TreeView ().Marked ("treeRemotes").Model ("storeRemotes__Url"); - Func<AppQuery, AppQuery> remoteTreeFullName = c => c.TreeView ().Marked ("treeRemotes").Model ("storeRemotes__FullName"); - - protected void SelectRemote (string remoteName, string remoteUrl = null) - { - Session.WaitForElement (c => remoteTreeName (c).Contains (remoteName)); - Assert.IsTrue (Session.SelectElement (c => remoteTreeName (c).Contains (remoteName))); - if (remoteUrl != null) { - Assert.IsTrue (Session.SelectElement (c => remoteTreeUrl (c).Contains (remoteUrl))); - } - TakeScreenShot (string.Format ("{0}-Remote-Selected", remoteName)); - } - - protected void EditRemote (string newRemoteName, string remoteUrl, string remotePushUrl = null) - { - AddEditRemote ("buttonEditRemote", newRemoteName, remoteUrl, remotePushUrl); - } - - protected void AddRemote (string newRemoteName, string remoteUrl, string remotePushUrl = null) - { - AddEditRemote ("buttonAddRemote", newRemoteName, remoteUrl, remotePushUrl); - } - - protected void FetchRemoteBranch (string remoteName) - { - SelectRemote (remoteName); - - Assert.IsEmpty (Session.Query (c => remoteTreeFullName (c).Contains (remoteName+"/"))); - Assert.IsTrue (Session.ClickElement (c => IdeQuery.GitConfigurationDialog (c).Children ().Button ().Marked ("buttonFetch"))); - TakeScreenShot ("Fetch-Remote"); - - Session.ClickElement (c => remoteTreeName (c).Contains (remoteName)); - Assert.IsNotEmpty (Session.Query (c => remoteTreeFullName (c).Contains (remoteName+"/"))); - Assert.IsTrue (Session.SelectElement (c => remoteTreeFullName (c).Contains (remoteName+"/").Index (0))); - TakeScreenShot ("First-Remote-Branch-Selected"); - } - - void AddEditRemote (string buttonName, string newRemoteName, string remoteUrl, string remotePushUrl) - { - Assert.IsNotEmpty (Session.Query (c => IdeQuery.GitConfigurationDialog (c).Children ().Button ().Marked (buttonName))); - Session.ClickElement (c => IdeQuery.GitConfigurationDialog (c).Children ().Button ().Marked (buttonName), false); - Session.WaitForElement (IdeQuery.EditRemoteDialog); - - Func<AppQuery, AppQuery> EditRemoteDialogChildren = c => IdeQuery.EditRemoteDialog (c).Children (); - Assert.IsTrue (Session.EnterText (c => EditRemoteDialogChildren (c).Textfield ().Marked ("entryName"), newRemoteName)); - Session.WaitForElement (c => EditRemoteDialogChildren (c).Textfield ().Marked ("entryName").Text (newRemoteName)); - - Assert.IsTrue (Session.EnterText (c => EditRemoteDialogChildren (c).Textfield ().Marked ("entryUrl"), remoteUrl)); - Session.WaitForElement (c => EditRemoteDialogChildren (c).Marked ("entryUrl").Text (remoteUrl)); - - Assert.IsTrue (Session.EnterText (c => EditRemoteDialogChildren (c).Textfield ().Marked ("entryPushUrl"), remotePushUrl ?? remoteUrl)); - Session.WaitForElement (c => EditRemoteDialogChildren (c).Textfield ().Marked ("entryPushUrl").Text (remotePushUrl ?? remoteUrl)); - TakeScreenShot ("Remote-Details-Filled"); - - Assert.IsTrue (Session.ClickElement (c => EditRemoteDialogChildren (c).Button ().Marked ("buttonOk"))); - Session.WaitForNoElement (IdeQuery.EditRemoteDialog); - Session.WaitForElement (IdeQuery.GitConfigurationDialog); - TakeScreenShot ("Remote-Edit-Dialog-Closed"); - } - - #endregion - - #region Branches - - Func<AppQuery, AppQuery> branchDisplayName = c => c.TreeView ().Marked ("listBranches").Model ("storeBranches__DisplayName"); - - protected void CreateNewBranch (string newBranchName) - { - CreateEditBranch ("buttonAddBranch", newBranchName); - } - - protected void EditBranch (string oldBranchName, string newBranchName) - { - SelectBranch (oldBranchName); - CreateEditBranch ("buttonEditBranch", newBranchName); - } - - protected void CreateEditBranch (string buttonName, string newBranchName) - { - Session.ClickElement (c => IdeQuery.GitConfigurationDialog(c).Children ().Button ().Marked (buttonName), false); - Session.WaitForElement (IdeQuery.EditBranchDialog); - TakeScreenShot ("Edit-Branch-Dialog-Opened"); - - Session.EnterText (c => IdeQuery.EditBranchDialog (c).Children ().Textfield ().Marked ("entryName"), newBranchName); - Session.WaitForElement (c => IdeQuery.EditBranchDialog (c).Children ().Textfield ().Marked ("entryName").Text (newBranchName)); - TakeScreenShot ("Branch-Name-Entered"); - - Assert.IsTrue (Session.ClickElement (c => IdeQuery.EditBranchDialog (c).Children ().Button ().Marked ("buttonOk"))); - Session.WaitForElement (IdeQuery.GitConfigurationDialog); - TakeScreenShot ("Edit-Branch-Dialog-Opened-Closed"); - } - - protected void SwitchToBranch (string branchName) - { - SelectBranch (branchName); - TakeScreenShot (string.Format ("{0}-Branch-Selected", branchName)); - Session.ClickElement (c => IdeQuery.GitConfigurationDialog(c).Children ().Button ().Marked ("buttonSetDefaultBranch"), false); - - try { - Session.WaitForElement (IdeQuery.GitConfigurationDialog); - TakeScreenShot ("Git-User-Not-Configured"); - EnterGitUserConfig ("John Doe", "john.doe@example.com"); - } catch (TimeoutException e) { } - - Assert.IsTrue (IsBranchSwitched (branchName)); - TakeScreenShot (string.Format ("Switched-To-{0}", branchName)); - } - - protected void SwitchTab (string tabName) - { - Assert.IsTrue (Session.SelectElement (c => IdeQuery.GitConfigurationDialog(c).Children ().Notebook ().Marked ("notebook1").Text (tabName))); - TakeScreenShot (string.Format ("Tab-Changed-{0}", GenerateProjectName (tabName))); - } - - protected void SelectBranch (string branchName) - { - Assert.IsTrue (Session.SelectElement (c => branchDisplayName (c).Contains (branchName))); - TakeScreenShot (string.Format ("Selected-Branch-{0}", branchName)); - } - - protected bool IsBranchSwitched (string branchName) - { - return Session.SelectElement (c => branchDisplayName (c).Text ("<b>" + branchName + "</b>")); - } - - #endregion - - protected void OpenRepositoryConfiguration (string selectTab = null) - { - Session.ExecuteCommand (MonoDevelop.VersionControl.Git.Commands.ManageBranches); - Session.WaitForElement (IdeQuery.GitConfigurationDialog); - TakeScreenShot ("Repository-Configuration-Opened"); - if (selectTab != null) - SwitchTab (selectTab); - } - - protected void CloseRepositoryConfiguration () - { - Session.ClickElement (c => IdeQuery.GitConfigurationDialog(c).Children ().Button ().Marked ("buttonOk")); - Session.WaitForNoElement (IdeQuery.GitConfigurationDialog); - } - } -} - diff --git a/main/tests/UserInterfaceTests/VersionControlTests/VCSBase.cs b/main/tests/UserInterfaceTests/VersionControlTests/VCSBase.cs index cf599626fd..e439d46580 100644 --- a/main/tests/UserInterfaceTests/VersionControlTests/VCSBase.cs +++ b/main/tests/UserInterfaceTests/VersionControlTests/VCSBase.cs @@ -26,7 +26,7 @@ using System; using NUnit.Framework; -using MonoDevelop.Components.AutoTest; +using MonoDevelop.Ide.Commands; namespace UserInterfaceTests { @@ -41,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; } @@ -65,38 +81,103 @@ 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); + + 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 (); + + 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"); + + ReproStep ("Close currently commit tab"); + Session.ExecuteCommand (FileCommands.CloseFile); + Session.WaitForElement (IdeQuery.TextArea); + } + + protected void GitCreateAndCommit (TemplateSelectionOptions templateOptions, string commitMessage) + { + CreateProject (templateOptions, + new ProjectDetails (templateOptions), + new GitOptions { UseGit = true, UseGitIgnore = true }); + + Session.WaitForElement (IdeQuery.TextArea); + TestCommit (commitMessage); + } + + protected string MakeSomeChangesAndSaveAll (string waitForFile = null) + { + 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"); + + return "Entered new blank line"; + } + + protected void CheckIfNameEmailNeeded () + { try { Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.VersionControl.Git.UserGitConfigDialog")); TakeScreenShot ("Git-User-Not-Configured"); EnterGitUserConfig ("John Doe", "john.doe@example.com"); } catch (TimeoutException e) { } - Ide.WaitForStatusMessage (new[] {"Commit operation completed."}); - TakeScreenShot ("Commit-Completed"); } protected void EnterGitUserConfig (string gitUser, string gitEmail) @@ -119,6 +200,15 @@ namespace UserInterfaceTests } } + protected void CheckIfUserConflict () + { + try { + Session.WaitForElement (c => c.Window ().Marked ("User Information Conflict")); + Session.ClickElement (c => c.Window ().Marked ("User Information Conflict").Children ().Button ().Text ("OK")); + } catch (TimeoutException) { + } + } + protected override void OnBuildTemplate (int buildTimeoutInSecs = 180) { } |