Cleaning up MC utilities interface
This commit is contained in:
parent
72fac334ea
commit
277fb9a128
8 changed files with 245 additions and 131 deletions
|
|
@ -57,14 +57,16 @@
|
|||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MatterControl\AutomationTests\CheckBoxInLibraryIsClickable.cs" />
|
||||
<Compile Include="MatterControl\LibraryProviderSqliteTests.cs" />
|
||||
<Compile Include="MatterControl\CheckBoxInLibraryIsClickable.cs" />
|
||||
<Compile Include="MatterControl\MatterControl.UI.cs" />
|
||||
<Compile Include="MatterControl\AutomationTests\CreateLibraryFolder.cs" />
|
||||
<Compile Include="MatterControl\MatterControlUiFeatures.cs" />
|
||||
<Compile Include="MatterControl\MatterControlUtilities.cs" />
|
||||
<Compile Include="MatterControl\HtmlParser.cs" />
|
||||
<Compile Include="MatterControl\LibraryProviderTests.cs" />
|
||||
<Compile Include="MatterControl\OptionsTabTests.cs" />
|
||||
<Compile Include="MatterControl\AutomationTests\OptionsTabTests.cs" />
|
||||
<Compile Include="MatterControl\PrinterConfigurationTests.cs" />
|
||||
<Compile Include="MatterControl\PrintQueueTests.cs" />
|
||||
<Compile Include="MatterControl\AutomationTests\PrintQueueTests.cs" />
|
||||
<Compile Include="MatterControl\ReleaseBuildTests.cs" />
|
||||
<Compile Include="MatterControl\SetupIniTests.cs" />
|
||||
<Compile Include="MatterControl\Slicing\SliceMappingCLassesTets.cs" />
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages);
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
|
||||
// Now do the actions specific to this test. (replace this for new tests)
|
||||
{
|
||||
|
|
@ -78,7 +78,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
testRunner.Wait(.5);
|
||||
resultsHarness.AddTestResult(checkBoxWidget.Checked == false, "currently not checked");
|
||||
|
||||
MatterControlUITests.CloseMatterControl(testRunner);
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.UI;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.GuiAutomation;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using System.IO;
|
||||
using MatterHackers.Agg.UI.Tests;
|
||||
|
||||
namespace MatterHackers.MatterControl.UI
|
||||
{
|
||||
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
|
||||
public class CreateLibraryFolder
|
||||
{
|
||||
[Test, RequiresSTA, RunInApplicationDomain]
|
||||
public void CreateFolderStarsOutWithTextFiledFocusedAndEditable()
|
||||
{
|
||||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
|
||||
// Now do the actions specific to this test. (replace this for new tests)
|
||||
{
|
||||
testRunner.ClickByName("Library Tab");
|
||||
testRunner.ClickByName("Create Folder Button");
|
||||
|
||||
testRunner.Wait(.5);
|
||||
testRunner.Type("Test Text");
|
||||
testRunner.Wait(.5);
|
||||
|
||||
SystemWindow containingWindow;
|
||||
GuiWidget textInputWidget = testRunner.GetWidgetByName("Create Folder - Text Input", out containingWindow);
|
||||
MHTextEditWidget textWidgetMH = textInputWidget as MHTextEditWidget;
|
||||
resultsHarness.AddTestResult(textWidgetMH != null, "Found Text Widget");
|
||||
resultsHarness.AddTestResult(textWidgetMH.Text == "Test Text", "Had the right text");
|
||||
containingWindow.CloseOnIdle();
|
||||
testRunner.Wait(.5);
|
||||
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
#if !__ANDROID__
|
||||
// Set the static data to point to the directory of MatterControl
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
#endif
|
||||
bool showWindow;
|
||||
MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow);
|
||||
AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 10);
|
||||
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages);
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
testRunner.ClickByName("SettingsAndControls", 5);
|
||||
|
|
@ -40,7 +40,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
containingWindow.CloseOnIdle();
|
||||
testRunner.Wait(.5);
|
||||
|
||||
MatterControlUITests.CloseMatterControl(testRunner);
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -50,10 +50,10 @@ namespace MatterHackers.MatterControl.UI
|
|||
#endif
|
||||
bool showWindow;
|
||||
string testDBFolder = "MC_Three_Queue_Items";
|
||||
MatterControlUITests.DataFolderState staticDataState = MatterControlUITests.MakeNewStaticDataForTesting(testDBFolder);
|
||||
MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewStaticDataForTesting(testDBFolder);
|
||||
MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow);
|
||||
AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 45);
|
||||
MatterControlUITests.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
MatterControlUtilities.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages);
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
testRunner.ClickByName("SettingsAndControls", 5);
|
||||
|
|
@ -83,7 +83,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
bool printNotificationsWindowExists2 = testRunner.WaitForName("Notification Options Window", 3);
|
||||
resultsHarness.AddTestResult(printNotificationsWindowExists2 == true, "Print Notifications Window exists after Configure button is clicked");
|
||||
|
||||
MatterControlUITests.CloseMatterControl(testRunner);
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -93,10 +93,10 @@ namespace MatterHackers.MatterControl.UI
|
|||
#endif
|
||||
bool showWindow;
|
||||
string testDBFolder = "MC_Three_Queue_Items";
|
||||
MatterControlUITests.DataFolderState staticDataState = MatterControlUITests.MakeNewStaticDataForTesting(testDBFolder);
|
||||
MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewStaticDataForTesting(testDBFolder);
|
||||
MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow);
|
||||
AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 45);
|
||||
MatterControlUITests.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
MatterControlUtilities.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages);
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
//Make sure image does not exist before we click the buy button
|
||||
|
|
@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
bool imageExists2 = testRunner.ImageExists("MatterHackersStoreImage.png", 10);
|
||||
resultsHarness.AddTestResult(imageExists2 == true, "Web page is open");
|
||||
|
||||
MatterControlUITests.CloseMatterControl(testRunner);
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages);
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
//Make sure that plugin window does not exist
|
||||
|
|
@ -106,7 +106,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
pluginWindowExists.CloseOnIdle();
|
||||
testRunner.Wait(.5);
|
||||
|
||||
MatterControlUITests.CloseMatterControl(testRunner);
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -135,7 +135,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages);
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
//Make sure that the export window does not exist
|
||||
|
|
@ -149,7 +149,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
exportWindow.CloseOnIdle();
|
||||
testRunner.Wait(.5);
|
||||
|
||||
MatterControlUITests.CloseMatterControl(testRunner);
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -159,10 +159,10 @@ namespace MatterHackers.MatterControl.UI
|
|||
#endif
|
||||
bool showWindow;
|
||||
string testDBFolder = "MC_Three_Queue_Items";
|
||||
MatterControlUITests.DataFolderState staticDataState = MatterControlUITests.MakeNewStaticDataForTesting(testDBFolder);
|
||||
MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewStaticDataForTesting(testDBFolder);
|
||||
MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow);
|
||||
AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 60);
|
||||
MatterControlUITests.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
MatterControlUtilities.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages);
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
//bool exportButtonExists = testRunner.NameExists("Export Queue Button");
|
||||
|
|
@ -186,7 +186,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
testRunner.Wait(5);
|
||||
resultsHarness.AddTestResult(exportButtonExists == false, "Export button is disabled");
|
||||
|
||||
MatterControlUITests.CloseMatterControl(testRunner);
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -196,10 +196,10 @@ namespace MatterHackers.MatterControl.UI
|
|||
#endif
|
||||
bool showWindow;
|
||||
string testDBFolder = "MC_Fresh_Installation";
|
||||
MatterControlUITests.DataFolderState staticDataState = MatterControlUITests.MakeNewStaticDataForTesting(testDBFolder);
|
||||
MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewStaticDataForTesting(testDBFolder);
|
||||
MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow);
|
||||
AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 300);
|
||||
MatterControlUITests.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
MatterControlUtilities.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 1); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages);
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
bool partPreviewWindowExists1 = testRunner.WaitForName("Part Preview Window Thumbnail", 0);
|
||||
resultsHarness.AddTestResult(partPreviewWindowExists1 == false, "Part Preview Window Does Not Exist");
|
||||
|
|
@ -227,7 +227,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
partPreviewWindowExists.CloseOnIdle();
|
||||
testRunner.Wait(.5);
|
||||
|
||||
MatterControlUITests.CloseMatterControl(testRunner);
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -237,10 +237,10 @@ namespace MatterHackers.MatterControl.UI
|
|||
#endif
|
||||
bool showWindow;
|
||||
string testDBFolder = "MC_Three_Queue_Items";
|
||||
MatterControlUITests.DataFolderState staticDataState = MatterControlUITests.MakeNewStaticDataForTesting(testDBFolder);
|
||||
MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewStaticDataForTesting(testDBFolder);
|
||||
MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow);
|
||||
AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 300);
|
||||
MatterControlUITests.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
MatterControlUtilities.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ namespace MatterControl.Tests
|
|||
[Test, RunInApplicationDomain]
|
||||
public void LibraryProviderSqlite_NavigationWorking()
|
||||
{
|
||||
MatterControlUITests.DataFolderState staticDataState = MatterControlUITests.MakeNewStaticDataForTesting();
|
||||
MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewStaticDataForTesting();
|
||||
|
||||
LibraryProviderSQLite testProvider = new LibraryProviderSQLite(null, null, null, "Local Library");
|
||||
testProvider.DataReloaded += (sender, e) => { dataReloaded = true; };
|
||||
|
|
@ -113,7 +113,7 @@ namespace MatterControl.Tests
|
|||
Assert.IsTrue(testProvider.CollectionCount == 0);
|
||||
Assert.IsTrue(!NamedCollectionExists(collectionName)); // assert that the record does not exist in the DB
|
||||
|
||||
MatterControlUITests.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
MatterControlUtilities.RestoreStaticDataAfterTesting(staticDataState, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.UI.Tests;
|
||||
using MatterHackers.GuiAutomation;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MatterHackers.MatterControl.UI
|
||||
{
|
||||
[TestFixture, Category("MatterControl.UI")]
|
||||
public class MatterControlUiFeatures
|
||||
{
|
||||
private static bool saveImagesForDebug = true;
|
||||
|
||||
/// <summary>
|
||||
/// Bug #94150618 - Left margin is not applied on GuiWidget
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TopToBottomContainerAppliesExpectedMarginToToggleView()
|
||||
{
|
||||
int marginSize = 40;
|
||||
int dimensions = 300;
|
||||
|
||||
GuiWidget outerContainer = new GuiWidget(dimensions, dimensions);
|
||||
|
||||
FlowLayoutWidget topToBottomContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.ParentLeftRight,
|
||||
VAnchor = VAnchor.ParentBottomTop,
|
||||
};
|
||||
outerContainer.AddChild(topToBottomContainer);
|
||||
|
||||
CheckBox toggleBox = ImageButtonFactory.CreateToggleSwitch(true);
|
||||
toggleBox.HAnchor = HAnchor.ParentLeftRight;
|
||||
toggleBox.VAnchor = VAnchor.ParentBottomTop;
|
||||
toggleBox.Margin = new BorderDouble(marginSize);
|
||||
toggleBox.BackgroundColor = RGBA_Bytes.Red;
|
||||
toggleBox.DebugShowBounds = true;
|
||||
|
||||
topToBottomContainer.AddChild(toggleBox);
|
||||
topToBottomContainer.AnchorAll();
|
||||
topToBottomContainer.PerformLayout();
|
||||
|
||||
outerContainer.DoubleBuffer = true;
|
||||
outerContainer.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
|
||||
outerContainer.OnDraw(outerContainer.NewGraphics2D());
|
||||
|
||||
// For troubleshooting or visual validation
|
||||
OutputImages(outerContainer, outerContainer);
|
||||
|
||||
var bounds = toggleBox.BoundsRelativeToParent;
|
||||
Assert.IsTrue(bounds.Left == marginSize, "Left margin is incorrect");
|
||||
Assert.IsTrue(bounds.Right == dimensions - marginSize, "Right margin is incorrect");
|
||||
Assert.IsTrue(bounds.Top == dimensions - marginSize, "Top margin is incorrect");
|
||||
Assert.IsTrue(bounds.Bottom == marginSize, "Bottom margin is incorrect");
|
||||
}
|
||||
|
||||
private static void OutputImage(ImageBuffer imageToOutput, string fileName)
|
||||
{
|
||||
if (saveImagesForDebug)
|
||||
{
|
||||
ImageTgaIO.Save(imageToOutput, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OutputImage(GuiWidget widgetToOutput, string fileName)
|
||||
{
|
||||
if (saveImagesForDebug)
|
||||
{
|
||||
OutputImage(widgetToOutput.BackBuffer, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OutputImages(GuiWidget control, GuiWidget test)
|
||||
{
|
||||
OutputImage(control, "image-control.tga");
|
||||
OutputImage(test, "image-test.tga");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,28 +27,23 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.UI.Tests;
|
||||
using MatterHackers.GuiAutomation;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MatterHackers.MatterControl.UI
|
||||
{
|
||||
[TestFixture, Category("MatterControl.UI")]
|
||||
public class MatterControlUITests
|
||||
public static class MatterControlUtilities
|
||||
{
|
||||
private static bool saveImagesForDebug = true;
|
||||
|
||||
private void RemoveAllFromQueue(AutomationRunner testRunner)
|
||||
private static void RemoveAllFromQueue(AutomationRunner testRunner)
|
||||
{
|
||||
Assert.IsTrue(testRunner.ClickByName("Queue... Menu", secondsToWait: 2));
|
||||
Assert.IsTrue(testRunner.ClickByName(" Remove All Menu Item", secondsToWait: 2));
|
||||
|
|
@ -74,91 +69,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
}
|
||||
|
||||
[Test, RequiresSTA, RunInApplicationDomain]
|
||||
public void CreateFolderStarsOutWithTextFiledFocusedAndEditable()
|
||||
{
|
||||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages);
|
||||
|
||||
// Now do the actions specific to this test. (replace this for new tests)
|
||||
{
|
||||
testRunner.ClickByName("Library Tab");
|
||||
testRunner.ClickByName("Create Folder Button");
|
||||
|
||||
testRunner.Wait(.5);
|
||||
testRunner.Type("Test Text");
|
||||
testRunner.Wait(.5);
|
||||
|
||||
SystemWindow containingWindow;
|
||||
GuiWidget textInputWidget = testRunner.GetWidgetByName("Create Folder - Text Input", out containingWindow);
|
||||
MHTextEditWidget textWidgetMH = textInputWidget as MHTextEditWidget;
|
||||
resultsHarness.AddTestResult(textWidgetMH != null, "Found Text Widget");
|
||||
resultsHarness.AddTestResult(textWidgetMH.Text == "Test Text", "Had the right text");
|
||||
containingWindow.CloseOnIdle();
|
||||
testRunner.Wait(.5);
|
||||
|
||||
CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
#if !__ANDROID__
|
||||
// Set the static data to point to the directory of MatterControl
|
||||
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));
|
||||
#endif
|
||||
bool showWindow;
|
||||
MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow);
|
||||
AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 10);
|
||||
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bug #94150618 - Left margin is not applied on GuiWidget
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TopToBottomContainerAppliesExpectedMarginToToggleView()
|
||||
{
|
||||
int marginSize = 40;
|
||||
int dimensions = 300;
|
||||
|
||||
GuiWidget outerContainer = new GuiWidget(dimensions, dimensions);
|
||||
|
||||
FlowLayoutWidget topToBottomContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.ParentLeftRight,
|
||||
VAnchor = VAnchor.ParentBottomTop,
|
||||
};
|
||||
outerContainer.AddChild(topToBottomContainer);
|
||||
|
||||
CheckBox toggleBox = ImageButtonFactory.CreateToggleSwitch(true);
|
||||
toggleBox.HAnchor = HAnchor.ParentLeftRight;
|
||||
toggleBox.VAnchor = VAnchor.ParentBottomTop;
|
||||
toggleBox.Margin = new BorderDouble(marginSize);
|
||||
toggleBox.BackgroundColor = RGBA_Bytes.Red;
|
||||
toggleBox.DebugShowBounds = true;
|
||||
|
||||
topToBottomContainer.AddChild(toggleBox);
|
||||
topToBottomContainer.AnchorAll();
|
||||
topToBottomContainer.PerformLayout();
|
||||
|
||||
outerContainer.DoubleBuffer = true;
|
||||
outerContainer.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
|
||||
outerContainer.OnDraw(outerContainer.NewGraphics2D());
|
||||
|
||||
// For troubleshooting or visual validation
|
||||
OutputImages(outerContainer, outerContainer);
|
||||
|
||||
var bounds = toggleBox.BoundsRelativeToParent;
|
||||
Assert.IsTrue(bounds.Left == marginSize, "Left margin is incorrect");
|
||||
Assert.IsTrue(bounds.Right == dimensions - marginSize, "Right margin is incorrect");
|
||||
Assert.IsTrue(bounds.Top == dimensions - marginSize, "Top margin is incorrect");
|
||||
Assert.IsTrue(bounds.Bottom == marginSize, "Bottom margin is incorrect");
|
||||
}
|
||||
|
||||
private void OutputImage(ImageBuffer imageToOutput, string fileName)
|
||||
private static void OutputImage(ImageBuffer imageToOutput, string fileName)
|
||||
{
|
||||
if (saveImagesForDebug)
|
||||
{
|
||||
|
|
@ -166,7 +77,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
}
|
||||
|
||||
private void OutputImage(GuiWidget widgetToOutput, string fileName)
|
||||
private static void OutputImage(GuiWidget widgetToOutput, string fileName)
|
||||
{
|
||||
if (saveImagesForDebug)
|
||||
{
|
||||
|
|
@ -174,7 +85,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
}
|
||||
|
||||
private void OutputImages(GuiWidget control, GuiWidget test)
|
||||
private static void OutputImages(GuiWidget control, GuiWidget test)
|
||||
{
|
||||
OutputImage(control, "image-control.tga");
|
||||
OutputImage(test, "image-test.tga");
|
||||
|
|
@ -245,20 +156,18 @@ namespace MatterHackers.MatterControl.UI
|
|||
public static void CopyTestDataDBFolderToTemporaryMCAppDataDirectory(string testDataDBDirectory)
|
||||
{
|
||||
string matterControlAppDataFolder = MatterHackers.MatterControl.DataStorage.ApplicationDataStorage.ApplicationUserDataPath;
|
||||
|
||||
foreach(string folder in Directory.GetDirectories(testDataDBDirectory, "*", SearchOption.AllDirectories))
|
||||
|
||||
foreach (string folder in Directory.GetDirectories(testDataDBDirectory, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
string directoryToCopyFilesTo = folder.Replace(testDataDBDirectory, matterControlAppDataFolder);
|
||||
Directory.CreateDirectory(directoryToCopyFilesTo);
|
||||
}
|
||||
|
||||
foreach(string fileName in Directory.GetFiles(testDataDBDirectory, "*", SearchOption.AllDirectories))
|
||||
foreach (string fileName in Directory.GetFiles(testDataDBDirectory, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
string newFileFullName = fileName.Replace(testDataDBDirectory, matterControlAppDataFolder);
|
||||
File.Copy(fileName, newFileFullName, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue