Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ward <matt.ward@xamarin.com>2015-11-19 12:43:19 +0300
committerMatt Ward <matt.ward@xamarin.com>2015-11-19 12:43:19 +0300
commit3464fad275c48d7c4ffb3602dfcc66afa467b76a (patch)
tree10db040d0a2cf55165ac8d43dd24b60ca297a887 /main/tests/UserInterfaceTests/Controllers
parentd94562154c646871e5af85aeb9eca1ece86776f9 (diff)
parent203ed0aabb6a60c7bb18f3b7b490588ab09cf38e (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/Controllers')
-rw-r--r--main/tests/UserInterfaceTests/Controllers/NewFileController.cs27
-rw-r--r--main/tests/UserInterfaceTests/Controllers/NewProjectController.cs73
-rw-r--r--main/tests/UserInterfaceTests/Controllers/NuGetController.cs87
-rw-r--r--main/tests/UserInterfaceTests/Controllers/NuGetOptions.cs179
-rw-r--r--main/tests/UserInterfaceTests/Controllers/OptionsController.cs148
-rw-r--r--main/tests/UserInterfaceTests/Controllers/SolutionExplorerController.cs62
6 files changed, 533 insertions, 43 deletions
diff --git a/main/tests/UserInterfaceTests/Controllers/NewFileController.cs b/main/tests/UserInterfaceTests/Controllers/NewFileController.cs
index b87fbdb0ca..b4e8879936 100644
--- a/main/tests/UserInterfaceTests/Controllers/NewFileController.cs
+++ b/main/tests/UserInterfaceTests/Controllers/NewFileController.cs
@@ -37,14 +37,25 @@ namespace UserInterfaceTests
Action<string> takeScreenshot;
+ Func<AppQuery, AppQuery> categoryViewQuery = c => c.TreeView ().Marked ("catView").Model ();
+ Func<AppQuery, AppQuery> fileTypeQuery = c => c.TreeView ().Marked ("newFileTemplateTreeView").Model ("templateStore__Name");
+
public NewFileController (Action<string> takeScreenshot = null)
{
- this.takeScreenshot = takeScreenshot ?? delegate { };
+ this.takeScreenshot = Util.GetNonNullAction (takeScreenshot);
}
- public static void Create (NewFileOptions options, Action<string> takeScreenshot = null)
+ public static void Create (NewFileOptions options, UITestBase testContext = null)
{
- var ctrl = new NewFileController (takeScreenshot);
+ options.PrintData ();
+ Action<string> screenshotAction = (s) => {};
+ if (testContext != null) {
+ testContext.ReproStep (string.Format ("Add a new file of type '{0}' named '{1}'",
+ options.FileType, options.FileName), options);
+ screenshotAction = testContext.TakeScreenShot;
+ }
+
+ var ctrl = new NewFileController (screenshotAction);
ctrl.Open ();
ctrl.ConfigureAddToProject (!string.IsNullOrEmpty (options.AddToProjectName), options.AddToProjectName);
ctrl.SelectFileTypeCategory (options.FileTypeCategory, options.FileTypeCategoryRoot);
@@ -63,16 +74,18 @@ namespace UserInterfaceTests
public bool SelectFileTypeCategory (string fileTypeCategory, string fileTypeCategoryRoot = "C#")
{
- var openChild = Session.ClickElement (c => c.TreeView ().Marked ("catView").Model ().Text (fileTypeCategoryRoot));
- var resultParent = Session.SelectElement (c => c.TreeView ().Marked ("catView").Model ().Text (fileTypeCategoryRoot).Children ().Text (fileTypeCategory));
- var result = Session.SelectElement (c => c.TreeView ().Marked ("catView").Model ().Text (fileTypeCategory));
+ var openChild = Session.ClickElement (c => categoryViewQuery (c).Text (fileTypeCategoryRoot));
+ var resultParent = Session.SelectElement (c => categoryViewQuery (c).Text (fileTypeCategoryRoot).Children ().Text (fileTypeCategory));
+ var result = Session.SelectElement (c => categoryViewQuery (c).Text (fileTypeCategory)) &&
+ Session.WaitForElement (c => categoryViewQuery (c).Text (fileTypeCategory).Selected ()).Length > 0;
takeScreenshot ("FileTypeCategory-Selected");
return resultParent || result;
}
public bool SelectFileType (string fileType)
{
- var result = Session.SelectElement (c => c.TreeView ().Marked ("newFileTemplateTreeView").Model ("templateStore__Name").Contains (fileType));
+ var result = Session.SelectElement (c => fileTypeQuery (c).Contains (fileType)) &&
+ Session.WaitForElement (c => fileTypeQuery (c).Contains (fileType).Selected ()).Length > 0;
takeScreenshot ("FileType-Selected");
return result;
}
diff --git a/main/tests/UserInterfaceTests/Controllers/NewProjectController.cs b/main/tests/UserInterfaceTests/Controllers/NewProjectController.cs
index 1b9c517323..05719054c0 100644
--- a/main/tests/UserInterfaceTests/Controllers/NewProjectController.cs
+++ b/main/tests/UserInterfaceTests/Controllers/NewProjectController.cs
@@ -28,6 +28,7 @@ using MonoDevelop.Components.AutoTest;
using MonoDevelop.Ide.Commands;
using NUnit.Framework;
using System.Threading;
+using System.Linq;
namespace UserInterfaceTests
{
@@ -37,27 +38,74 @@ namespace UserInterfaceTests
get { return TestService.Session; }
}
- Func<AppQuery, AppQuery> previewTree = (c) => c.TreeView ().Marked ("folderTreeView").Model ("folderTreeStore__NodeName");
+ Func<AppQuery, AppQuery> templateCategoriesTreeViewQuery = c => c.TreeView ().Marked ("templateCategoriesTreeView");
+ Func<AppQuery, AppQuery> templatesTreeViewQuery = c => c.TreeView ().Marked ("templatesTreeView");
+
+ Func<AppQuery, AppQuery> previewTree = c => c.TreeView ().Marked ("folderTreeView").Model ("folderTreeStore__NodeName");
+ Func<AppQuery, AppQuery> templateCategoriesQuery = c => c.TreeView ().Marked ("templateCategoriesTreeView").Model ("templateCategoriesListStore__Name");
+ Func<AppQuery, AppQuery> templatesQuery = c => c.TreeView ().Marked ("templatesTreeView").Model ("templateListStore__Name");
public void Open ()
{
Session.ExecuteCommand (FileCommands.NewProject);
+ WaitForOpen ();
+ }
+
+ public void Open (string addToSolutionName)
+ {
+ SolutionExplorerController.SelectSolution (addToSolutionName);
+ Session.ExecuteCommand (ProjectCommands.AddNewProject);
+ WaitForOpen ();
+ }
+
+ public void WaitForOpen ()
+ {
Session.WaitForElement (c => c.Window ().Marked ("MonoDevelop.Ide.Projects.GtkNewProjectDialogBackend"));
}
+ public void Select (TemplateSelectionOptions templateOptions)
+ {
+ SelectTemplateType (templateOptions.CategoryRoot, templateOptions.Category);
+ SelectTemplate (templateOptions.TemplateKindRoot, templateOptions.TemplateKind);
+ }
+
+ public bool IsSelected (TemplateSelectionOptions templateOptions)
+ {
+ return true;
+// return Session.SelectElement (templateCategoriesTreeViewQuery) && IsTemplateTypeSelected (templateOptions.CategoryRoot, templateOptions.Category)
+// && Session.SelectElement (templatesTreeViewQuery) && IsTemplateSelected (templateOptions.TemplateKindRoot, templateOptions.TemplateKind);
+ }
+
public bool SelectTemplateType (string categoryRoot, string category)
{
- return Session.SelectElement (c => c.TreeView ().Marked ("templateCategoriesTreeView").Model ("templateCategoriesListStore__Name").Contains (categoryRoot).NextSiblings ().Text (category));
+ return Session.SelectElement (c => templateCategoriesQuery (c).Contains (categoryRoot).NextSiblings ().Text (category))
+ && IsTemplateTypeSelected (categoryRoot, category);
}
public bool SelectTemplate (string kindRoot, string kind)
{
- return Session.SelectElement (c => c.TreeView ().Marked ("templatesTreeView").Model ("templateListStore__Name").Contains (kindRoot).NextSiblings ().Text (kind));
+ return Session.SelectElement (c => templatesQuery (c).Contains (kindRoot).NextSiblings ().Text (kind))
+ && IsTemplateSelected (kindRoot, kind);
+ }
+
+ public bool IsTemplateTypeSelected (string categoryRoot, string category)
+ {
+ return Session.WaitForElement (c => templateCategoriesQuery (c).Contains (categoryRoot).NextSiblings ().Text (category).Selected ()).Any ();
+ }
+
+ public bool IsTemplateSelected (string kindRoot, string kind)
+ {
+ return Session.WaitForElement (c => templatesQuery (c).Contains (kindRoot).NextSiblings ().Text (kind).Selected ()).Any ();
}
public bool Next ()
{
- return Session.ClickElement (c => c.Button ().Marked ("nextButton"));
+ return Session.ClickElement (c => c.Button ().Text ("Next"));
+ }
+
+ public bool Create ()
+ {
+ return Session.ClickElement (c => c.Button ().Text ("Create"));
}
public bool Previous ()
@@ -70,14 +118,23 @@ namespace UserInterfaceTests
return Session.ClickElement (c => c.Button ().Marked ("cancelButton"));
}
- public bool SetProjectName (string projectName)
+ public bool SetProjectName (string projectName, bool addToExistingSolution)
{
- return Session.EnterText (c => c.Textfield ().Marked ("projectNameTextBox"), projectName);
+ Func<AppQuery, AppQuery> projectNameTextBox = c => c.Textfield ().Marked ("projectNameTextBox");
+ if (addToExistingSolution && Session.Query (c => projectNameTextBox (c).Sensitivity (false)).Length > 0) {
+ return Session.Query (c => projectNameTextBox (c).Text (projectName)).Length > 0;
+ }
+ return Session.EnterText (projectNameTextBox, projectName);
}
- public bool SetSolutionName (string solutionName)
+ public bool SetSolutionName (string solutionName, bool addToExistingSolution)
{
- return Session.EnterText (c => c.Textfield ().Marked ("solutionNameTextBox"), solutionName);
+ Func<AppQuery, AppQuery> solutionNameTextBox = c => c.Textfield ().Marked ("solutionNameTextBox");
+ if (addToExistingSolution) {
+ return Session.Query (c => solutionNameTextBox (c).Sensitivity (false)).Length > 0 &&
+ Session.Query (c => solutionNameTextBox (c).Text (solutionName)).Length > 0;
+ }
+ return Session.EnterText (solutionNameTextBox, solutionName);
}
public bool SetSolutionLocation (string solutionLocation)
diff --git a/main/tests/UserInterfaceTests/Controllers/NuGetController.cs b/main/tests/UserInterfaceTests/Controllers/NuGetController.cs
index 92cf57a4ad..3425a7b31c 100644
--- a/main/tests/UserInterfaceTests/Controllers/NuGetController.cs
+++ b/main/tests/UserInterfaceTests/Controllers/NuGetController.cs
@@ -25,21 +25,11 @@
// THE SOFTWARE.
using System;
using MonoDevelop.Components.AutoTest;
-using UserInterfaceTests;
using MonoDevelop.Components.Commands;
using NUnit.Framework;
namespace UserInterfaceTests
{
- public class NuGetPackageOptions
- {
- public string PackageName { get; set;}
-
- public string Version { get; set;}
-
- public bool IsPreRelease { get; set;}
- }
-
public class NuGetController
{
static AutoTestClientSession Session {
@@ -48,31 +38,76 @@ namespace UserInterfaceTests
Action<string> takeScreenshot;
- readonly Func<AppQuery,AppQuery> nugetWindow;
+ bool isUpdate;
+
+ static readonly Func<AppQuery,AppQuery> nugetWindow = c => c.Window ().Marked ("Add Packages");
readonly Func<AppQuery,AppQuery> addPackageButton;
+ readonly Func<AppQuery,AppQuery> updatePackageButton;
readonly Func<AppQuery,AppQuery> resultList;
readonly Func<AppQuery,AppQuery> includePreRelease;
- public static void AddPackage (NuGetPackageOptions packageOptions, Action<string> takeScreenshot = null)
+ public static void AddPackage (NuGetPackageOptions packageOptions, UITestBase testContext = null)
+ {
+ Action<string> screenshotAction = delegate { };
+ if (testContext != null) {
+ testContext.ReproStep (string.Format ("Add NuGet package '{0}'", packageOptions.PackageName), packageOptions);
+ screenshotAction = testContext.TakeScreenShot;
+ }
+ AddUpdatePackage (packageOptions, screenshotAction, false);
+ }
+
+ public static void UpdatePackage (NuGetPackageOptions packageOptions, UITestBase testContext = null)
{
- var nuget = new NuGetController (takeScreenshot);
+ Action<string> screenshotAction = delegate { };
+ if (testContext != null) {
+ testContext.ReproStep (string.Format ("Update NuGet package '{0}'", packageOptions.PackageName), packageOptions);
+ screenshotAction = testContext.TakeScreenShot;
+ }
+ AddUpdatePackage (packageOptions, screenshotAction, true);
+ }
+
+ public static void UpdateAllNuGetPackages (UITestBase testContext = null)
+ {
+ Session.ExecuteCommand ("MonoDevelop.PackageManagement.Commands.UpdateAllPackagesInSolution");
+ WaitForNuGet.UpdateSuccess (string.Empty);
+ if (testContext != null)
+ testContext.TakeScreenShot ("All-NuGet-Packages-Updated");
+ }
+
+ static void AddUpdatePackage (NuGetPackageOptions packageOptions, Action<string> takeScreenshot, bool isUpdate = false)
+ {
+ packageOptions.PrintData ();
+ var nuget = new NuGetController (takeScreenshot, isUpdate);
nuget.Open ();
nuget.EnterSearchText (packageOptions.PackageName, packageOptions.Version, packageOptions.IsPreRelease);
- nuget.SelectResultByPackageName (packageOptions.PackageName, packageOptions.Version);
+ for (int i = 0; i < packageOptions.RetryCount; i++) {
+ try {
+ nuget.SelectResultByPackageName (packageOptions.PackageName, packageOptions.Version);
+ break;
+ } catch (NuGetException e) {
+ if (i == packageOptions.RetryCount - 1)
+ Assert.Inconclusive ("Unable to find NuGet package, could be network related.", e);
+ }
+ }
nuget.ClickAdd ();
- Ide.WaitForStatusMessage (new [] {
- string.Format ("{0} successfully added.", packageOptions.PackageName)
- });
- if (takeScreenshot != null)
- takeScreenshot ("Package-Added");
+ Session.WaitForNoElement (nugetWindow);
+ takeScreenshot ("NuGet-Update-Is-"+isUpdate);
+ try {
+ WaitForNuGet.Success (packageOptions.PackageName, isUpdate ? NuGetOperations.Update : NuGetOperations.Add);
+ } catch (TimeoutException e) {
+ takeScreenshot ("Wait-For-NuGet-Operation-Failed");
+ throw;
+ }
+ takeScreenshot ("NuGet-Operation-Finished");
}
- public NuGetController (Action<string> takeScreenshot = null)
+ public NuGetController (Action<string> takeScreenshot = null, bool isUpdate = false)
{
this.takeScreenshot = takeScreenshot ?? delegate { };
+ this.isUpdate = isUpdate;
- nugetWindow = c => c.Window ().Marked ("Add Packages");
addPackageButton = c => nugetWindow (c).Children ().Button ().Text ("Add Package");
+ updatePackageButton = c => nugetWindow (c).Children ().Button ().Text ("Update Package");
resultList = c => nugetWindow (c).Children ().TreeView ().Model ();
includePreRelease = c => nugetWindow (c).Children ().CheckButton ().Text ("Show pre-release packages");
}
@@ -112,18 +147,18 @@ namespace UserInterfaceTests
var found = Session.Query (c => nugetWindow (c).Children ().CheckType (typeof(Gtk.Label)).Text (packageName)).Length > 0;
if (version != null) {
found = found && (Session.Query (c => nugetWindow (c).Children ().CheckType (typeof(Gtk.Label)).Text (version)).Length > 0);
- if (found)
- return;
}
+ if (found)
+ return;
}
takeScreenshot ("Package-Failed-To-Be-Found");
- Assert.Fail ("No package '{0}' with version: '{1}' found", packageName, version);
+ throw new NuGetException (string.Format ("No package '{0}' with version: '{1}' found", packageName, version));
}
public void ClickAdd ()
{
WaitForAddButton (true);
- Assert.IsTrue (Session.ClickElement (addPackageButton));
+ Assert.IsTrue (Session.ClickElement (isUpdate ? updatePackageButton : addPackageButton));
Session.WaitForElement (IdeQuery.TextArea);
}
@@ -138,7 +173,7 @@ namespace UserInterfaceTests
if (enabled == null)
Session.WaitForElement (addPackageButton);
else
- Session.WaitForElement (c => addPackageButton (c).Sensitivity (enabled.Value), 10000);
+ Session.WaitForElement (c => (isUpdate? updatePackageButton(c) : addPackageButton (c)).Sensitivity (enabled.Value), 30000);
}
}
}
diff --git a/main/tests/UserInterfaceTests/Controllers/NuGetOptions.cs b/main/tests/UserInterfaceTests/Controllers/NuGetOptions.cs
new file mode 100644
index 0000000000..9fb53d57cb
--- /dev/null
+++ b/main/tests/UserInterfaceTests/Controllers/NuGetOptions.cs
@@ -0,0 +1,179 @@
+//
+// NuGetOptions.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 System.Collections.Generic;
+
+namespace UserInterfaceTests
+{
+ public class NuGetPackageOptions
+ {
+ public NuGetPackageOptions ()
+ {
+ RetryCount = 3;
+ }
+
+ public string PackageName { get; set;}
+
+ public string Version { get; set;}
+
+ public bool IsPreRelease { get; set;}
+
+ public int RetryCount { get; set;}
+
+ public override string ToString ()
+ {
+ return string.Format ("PackageName={0}, Version={1}, IsPreRelease={2}, RetryCount={3}",
+ PackageName, Version, IsPreRelease, RetryCount);
+ }
+ }
+
+ public enum NuGetOperations
+ {
+ Add,
+ Remove,
+ Update
+ }
+
+ public class WaitForNuGet
+ {
+ public WaitForNuGet ()
+ {
+ TimeOutSeconds = 180;
+ PollStepSeconds = 1;
+ }
+
+ public NuGetOperations Operation { get; set;}
+
+ public string PackageName { get; set;}
+
+ public bool WaitForSuccess { get; set;}
+
+ public bool WaitForWarning { get; set;}
+
+ public bool WaitForError { get; set;}
+
+ public int TimeOutSeconds { get; set;}
+
+ public int PollStepSeconds { get; set;}
+
+ public override string ToString ()
+ {
+ return string.Format ("Operation={0}, PackageName={1}, WaitForSuccess={2}, WaitForWarning={3}, WaitForError={4}, TimeOutSeconds={5}, PollStepSeconds={6}",
+ Operation, PackageName, WaitForSuccess, WaitForWarning, WaitForError, TimeOutSeconds, PollStepSeconds);
+ }
+
+ public static void UpdateSuccess (string packageName, bool waitForWarning = true, UITestBase testContext = null)
+ {
+ Success (packageName, NuGetOperations.Update, waitForWarning, testContext);
+ }
+
+ public static void AddSuccess (string packageName, bool waitForWarning = true, UITestBase testContext = null)
+ {
+ Success (packageName, NuGetOperations.Add, waitForWarning, testContext);
+ }
+
+ public static void Success (string packageName, NuGetOperations operation, bool waitForWarning = true, UITestBase testContext = null)
+ {
+ var waitPackage = new WaitForNuGet {
+ Operation = operation,
+ PackageName = packageName,
+ WaitForSuccess = true,
+ WaitForWarning = waitForWarning
+ };
+ if (testContext != null) {
+ testContext.ReproStep (string.Format ("Wait for one of these messages:\n\t{0}",
+ string.Join ("\t\n", waitPackage.ToMessages ())));
+ }
+ waitPackage.Wait ();
+ }
+
+ public void Wait ()
+ {
+ Ide.WaitForStatusMessage (ToMessages (), TimeOutSeconds, PollStepSeconds);
+ }
+
+ public string [] ToMessages ()
+ {
+ if ((WaitForSuccess | WaitForWarning | WaitForError) == false)
+ throw new ArgumentException ("Atleast one of the 'WaitForSuccess', 'WaitForWarning', 'WaitForError' needs to be true");
+
+ List<string> waitForMessages = new List<string> ();
+
+ if (WaitForSuccess) {
+ if (Operation == NuGetOperations.Add) {
+ waitForMessages.Add (string.Format ("{0} successfully added.", PackageName));
+ waitForMessages.Add ("Packages successfully added.");
+ waitForMessages.Add ("packages successfully added.");
+ }
+ if (Operation == NuGetOperations.Update) {
+ waitForMessages.Add (string.Format ("{0} is up to date.", PackageName));
+ waitForMessages.Add (string.Format ("{0} successfully updated.", PackageName));
+ waitForMessages.Add ("Packages successfully updated.");
+ waitForMessages.Add ("packages successfully updated.");
+ waitForMessages.Add ("successfully updated.");
+ waitForMessages.Add ("Packages are up to date.");
+ }
+ if (Operation == NuGetOperations.Remove) {
+ waitForMessages.Add (string.Format ("{0} successfully removed.", PackageName));
+ }
+ }
+
+ if (WaitForWarning) {
+ if (Operation == NuGetOperations.Add) {
+ waitForMessages.Add (string.Format ("{0} added with warnings.", PackageName));
+ waitForMessages.Add ("Packages added with warnings.");
+ waitForMessages.Add ("packages added with warnings.");
+ }
+ if (Operation == NuGetOperations.Update) {
+ waitForMessages.Add (string.Format ("{0} updated with warnings.", PackageName));
+ waitForMessages.Add ("Packages updated with warnings.");
+ waitForMessages.Add ("packages updated with warnings.");
+ waitForMessages.Add ("No update found but warnings were reported.");
+ waitForMessages.Add ("No updates found but warnings were reported.");
+ }
+ if (Operation == NuGetOperations.Remove) {
+ waitForMessages.Add (string.Format ("{0} removed with warnings.", PackageName));
+ }
+ }
+
+ if (WaitForError) {
+ if (Operation == NuGetOperations.Add) {
+ waitForMessages.Add (string.Format ("Could not add {0}.", PackageName));
+ waitForMessages.Add ("Could not add packages.");
+ }
+ if (Operation == NuGetOperations.Update) {
+ waitForMessages.Add (string.Format ("Could not update {0}.", PackageName));
+ waitForMessages.Add ("Could not update packages.");
+ }
+ if (Operation == NuGetOperations.Remove) {
+ waitForMessages.Add (string.Format ("Could not remove {0}.", PackageName));
+ }
+ }
+ return waitForMessages.ToArray ();
+ }
+ }
+}
+
diff --git a/main/tests/UserInterfaceTests/Controllers/OptionsController.cs b/main/tests/UserInterfaceTests/Controllers/OptionsController.cs
new file mode 100644
index 0000000000..7a3c9cc0eb
--- /dev/null
+++ b/main/tests/UserInterfaceTests/Controllers/OptionsController.cs
@@ -0,0 +1,148 @@
+//
+// ProjectOptionsController.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 MonoDevelop.Ide.Commands;
+
+namespace UserInterfaceTests
+{
+ public class ProjectOptionsController : OptionsController
+ {
+ readonly static Func<AppQuery, AppQuery> windowQuery = c => c.Window ().Marked ("MonoDevelop.Ide.Projects.ProjectOptionsDialog");
+
+ readonly string solutionName;
+ readonly string projectName;
+
+ public ProjectOptionsController (string solutionName, string projectName, UITestBase testContext = null) : base (windowQuery,testContext)
+ {
+ this.solutionName = solutionName;
+ this.projectName = projectName;
+ }
+
+ public ProjectOptionsController (UITestBase testContext = null) : base (windowQuery, testContext) { }
+
+ public void OpenProjectOptions ()
+ {
+ ReproStep (string.Format ("In Solution Explorer, right click '{0}' and select 'Options'", projectName));
+ SolutionExplorerController.SelectProject (solutionName, projectName);
+
+ Session.Query (IdeQuery.TextArea);
+ Session.ExecuteCommand (ProjectCommands.ProjectOptions);
+ Session.WaitForElement (windowQuery);
+ TakeScreenshot ("Opened-ProjectOptionsDialog");
+ }
+ }
+
+ public class PreferencesController : OptionsController
+ {
+ readonly static Func<AppQuery, AppQuery> windowQuery = c => c.Window ().Marked ("Preferences");
+
+ public PreferencesController (Action<string> takeScreenshot = null) : base (windowQuery, takeScreenshot) {}
+
+ public void Open ()
+ {
+ Session.ExecuteCommand (EditCommands.MonodevelopPreferences);
+ Session.WaitForElement (windowQuery);
+ TakeScreenshot ("Opened-Preferences-Window");
+ }
+
+ public static void SetAuthorInformation (string name = null, string email = null , string copyright = null,
+ string company = null, string trademark = null, Action<string> takeScreenshot = null)
+ {
+ takeScreenshot = takeScreenshot ?? new Action<string> (delegate {});
+
+ if (name == null && email == null && copyright == null && company == null && trademark == null)
+ throw new ArgumentNullException ("Atleast one of these arguments need to be not null: name, email, copyright, company, trademark");
+
+ var prefs = new PreferencesController ();
+ prefs.Open ();
+ prefs.SelectPane ("Author Information");
+ prefs.SetEntry ("nameEntry", name, "Name", takeScreenshot);
+ prefs.SetEntry ("emailEntry", email, "Email", takeScreenshot);
+ prefs.SetEntry ("copyrightEntry", copyright, "Copyright", takeScreenshot);
+ prefs.SetEntry ("companyEntry", company, "Company", takeScreenshot);
+ prefs.SetEntry ("trademarkEntry", trademark, "Trademark", takeScreenshot);
+ prefs.ClickOK ();
+ }
+ }
+
+ public abstract class OptionsController
+ {
+ protected static AutoTestClientSession Session {
+ get { return TestService.Session; }
+ }
+
+ protected Action<string> TakeScreenshot;
+ readonly UITestBase testContext;
+ readonly Func<AppQuery, AppQuery> windowQuery;
+
+ protected OptionsController (Func<AppQuery, AppQuery> windowQuery, UITestBase testContext) : this (windowQuery, testContext.TakeScreenShot)
+ {
+ this.testContext = testContext;
+ }
+
+ protected OptionsController (Func<AppQuery, AppQuery> windowQuery, Action<string> takeScreenshot = null)
+ {
+ this.windowQuery = windowQuery;
+ TakeScreenshot = Util.GetNonNullAction (takeScreenshot);
+ }
+
+ protected void ReproStep (string stepDescription, params object[] info)
+ {
+ testContext.ReproStep (stepDescription, info);
+ }
+
+ public void SelectPane (string name)
+ {
+ ReproStep (string.Format ("Select pane: '{0}'", name));
+ string.Format ("Selected Pane :{0}", name).PrintData ();
+ Session.SelectElement (c => windowQuery (c).Children ().Marked (
+ "MonoDevelop.Components.HeaderBox").Children ().TreeView ().Model ().Children ().Property ("Label", name));
+ }
+
+ protected void SetEntry (string entryName, string entryValue, string stepName, Action<string> takeScreenshot)
+ {
+ if (entryValue != null) {
+ Session.EnterText (c => c.Marked (entryName), entryValue);
+ Session.WaitForElement (c => c.Marked (entryName).Text (entryValue));
+ takeScreenshot (string.Format("{0}-Entry-Set", stepName));
+ }
+ }
+
+ public void ClickOK ()
+ {
+ ReproStep ("Click OK");
+ Session.ClickElement (c => windowQuery (c).Children ().Button ().Text ("OK"));
+ }
+
+ public void ClickCancel ()
+ {
+ ReproStep ("Click Cancel");
+ Session.ClickElement (c => windowQuery (c).Children ().Button ().Text ("Cancel"));
+ }
+ }
+}
+
diff --git a/main/tests/UserInterfaceTests/Controllers/SolutionExplorerController.cs b/main/tests/UserInterfaceTests/Controllers/SolutionExplorerController.cs
index 0afd044380..abd0a1f69b 100644
--- a/main/tests/UserInterfaceTests/Controllers/SolutionExplorerController.cs
+++ b/main/tests/UserInterfaceTests/Controllers/SolutionExplorerController.cs
@@ -24,7 +24,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
+using System.Linq;
using MonoDevelop.Components.AutoTest;
+using System.Collections.Generic;
namespace UserInterfaceTests
{
@@ -39,12 +41,68 @@ namespace UserInterfaceTests
public static Func<AppQuery, AppQuery> GetSolutionQuery (string solutionLabel)
{
- return c => topLevel (c).Children().Property ("Label", solutionLabel).Index (0);
+ return c => topLevel (c).Children (false).Index (0).Property ("Label", solutionLabel);
}
public static Func<AppQuery, AppQuery> GetProjectQuery (string solutionLabel, string projectLabel)
{
- return c => topLevel (c).Children().Property ("Label", solutionLabel).Children ().Property ("Label", projectLabel).Index (0);
+ return c => topLevel (c).Children (false).Index (0).Property ("Label", solutionLabel).Children (false).Property ("Label", projectLabel).Index (0);
+ }
+
+ public static bool Select (params string[] selectionTree)
+ {
+ string.Join (" > ", selectionTree).PrintData ();
+ Func<AppQuery, AppQuery> query = GetNodeQuery (selectionTree);
+ return Session.SelectElement (GetNodeQuery (selectionTree)) && Session.WaitForElement (c => query (c).Selected ()).Any ();
+ }
+
+ public static Func<AppQuery, AppQuery> GetNodeQuery (params string[] selectionTree)
+ {
+ var funcs = new List<Func<AppQuery, AppQuery>> ();
+ funcs.Add (topLevel);
+ foreach (var nodeName in selectionTree) {
+ var lastFunc = funcs.Last ();
+ funcs.Add (c => lastFunc (c).Children (false).Property ("Label", nodeName).Index (0));
+ }
+ return funcs.Last ();
+ }
+
+ public static bool SelectSolution (string solutionName, UITestBase testContext = null)
+ {
+ LogReproSteps (testContext, string.Format ("Under Solution Explorer, select Solution '{0}'", solutionName.StripBold ()));
+ return Select (solutionName);
+ }
+
+ public static bool SelectProject (string solutionName, string projectName, UITestBase testContext = null)
+ {
+ LogReproSteps (testContext, string.Format ("Under Solution Explorer, select Project '{0}' under '{1}'", projectName.StripBold (), solutionName.StripBold ()));
+ return Select (solutionName, projectName);
+ }
+
+ public static bool SelectReferenceFolder (string solutionName, string projectName, UITestBase testContext = null)
+ {
+ LogReproSteps (testContext, string.Format ("Under Solution Explorer, expand References node under '{0}'> '{1}'", projectName.StripBold (), solutionName.StripBold ()));
+ return Select (solutionName, projectName, "References");
+ }
+
+ public static bool SelectSingleReference (string solutionName, string projectName, string referenceName, bool fromPackage = false, UITestBase testContext = null)
+ {
+ LogReproSteps (testContext, string.Format ("Under Solution Explorer, select NuGet package '{0}' under '{1}' > '{2}' > From Packages",
+ referenceName, projectName.StripBold (), solutionName.StripBold ()));
+ return fromPackage ? Select (solutionName, projectName, "From Packages", referenceName) : Select (solutionName, projectName, referenceName);
+ }
+
+ public static bool SelectPackage (string solutionName, string projectName, string package, UITestBase testContext = null)
+ {
+ LogReproSteps (testContext, string.Format ("Under Solution Explorer, select package '{0}' under '{1}' > '{2}' > 'Packages'", package, projectName.StripBold (), solutionName.StripBold ()));
+ return Select (solutionName, projectName, "Packages", package);
+ }
+
+ static void LogReproSteps (UITestBase testContext, string message, params object[] info)
+ {
+ if (testContext != null) {
+ testContext.ReproStep (message, info);
+ }
}
}
}