Moved GuiAutomation into agg.
This commit is contained in:
parent
75a4bf3c2e
commit
fc62137d3e
9 changed files with 43 additions and 587 deletions
|
|
@ -431,6 +431,10 @@
|
|||
<Project>{04667764-dc7b-4b95-aef6-b4e6c87a54e9}</Project>
|
||||
<Name>DataConverters3D</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="SubModules\agg-sharp\GuiAutomation\GuiAutomation.csproj">
|
||||
<Project>{e9102310-0029-4d8f-b1e9-88fba6147d45}</Project>
|
||||
<Name>GuiAutomation</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="Submodules\agg-sharp\Gui\Gui.csproj">
|
||||
<Project>{74F6BB6C-9D02-4512-A59A-21940E35C532}</Project>
|
||||
<Name>Gui</Name>
|
||||
|
|
@ -519,9 +523,5 @@
|
|||
<Project>{990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9}</Project>
|
||||
<Name>InfInstaller</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="TestRunner\TestRunner.csproj">
|
||||
<Project>{9d193b5c-bef4-44b2-ad6d-597b7a2c52c5}</Project>
|
||||
<Name>TestRunner</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -120,7 +120,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X3GDriver", "..\X3GDriver\X
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Nat", "..\CloudServicesPlugin\Mono.Nat\Mono.Nat.csproj", "{F5D74163-145F-47BF-83DC-D0E07249C6CA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestRunner", "TestRunner\TestRunner.csproj", "{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GuiAutomation", "SubModules\agg-sharp\GuiAutomation\GuiAutomation.csproj", "{E9102310-0029-4D8F-B1E9-88FBA6147D45}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -1075,38 +1075,38 @@ Global
|
|||
{F5D74163-145F-47BF-83DC-D0E07249C6CA}.Release64|x64.ActiveCfg = Release|x64
|
||||
{F5D74163-145F-47BF-83DC-D0E07249C6CA}.Release64|x64.Build.0 = Release|x64
|
||||
{F5D74163-145F-47BF-83DC-D0E07249C6CA}.Release64|x86.ActiveCfg = Release|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug|x64.Build.0 = Debug|x64
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug64|Any CPU.ActiveCfg = Debug64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug64|Any CPU.Build.0 = Debug64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug64|Mixed Platforms.ActiveCfg = Debug64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug64|Mixed Platforms.Build.0 = Debug64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug64|x64.ActiveCfg = Debug64|x64
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug64|x64.Build.0 = Debug64|x64
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug64|x86.ActiveCfg = Debug64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Debug64|x86.Build.0 = Debug64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release|x64.ActiveCfg = Release|x64
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release|x64.Build.0 = Release|x64
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release|x86.Build.0 = Release|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release64|Any CPU.ActiveCfg = Release64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release64|Any CPU.Build.0 = Release64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release64|Mixed Platforms.ActiveCfg = Release64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release64|Mixed Platforms.Build.0 = Release64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release64|x64.ActiveCfg = Release64|x64
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release64|x64.Build.0 = Release64|x64
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release64|x86.ActiveCfg = Release64|Any CPU
|
||||
{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}.Release64|x86.Build.0 = Release64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug|x64.Build.0 = Debug|x64
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug64|Any CPU.ActiveCfg = Debug64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug64|Any CPU.Build.0 = Debug64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug64|Mixed Platforms.ActiveCfg = Debug64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug64|Mixed Platforms.Build.0 = Debug64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug64|x64.ActiveCfg = Debug64|x64
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug64|x64.Build.0 = Debug64|x64
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug64|x86.ActiveCfg = Debug64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Debug64|x86.Build.0 = Debug64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release|x64.ActiveCfg = Release|x64
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release|x64.Build.0 = Release|x64
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release|x86.Build.0 = Release|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release64|Any CPU.ActiveCfg = Release64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release64|Any CPU.Build.0 = Release64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release64|Mixed Platforms.ActiveCfg = Release64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release64|Mixed Platforms.Build.0 = Release64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release64|x64.ActiveCfg = Release64|x64
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release64|x64.Build.0 = Release64|x64
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release64|x86.ActiveCfg = Release64|Any CPU
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45}.Release64|x86.Build.0 = Release64|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -1142,6 +1142,7 @@ Global
|
|||
{8CD15B23-D30F-470E-99BA-9276FB7CABD4} = {FBE6DF29-85A9-4A8B-B739-35BE4CA0A9B7}
|
||||
{26164CC3-29AD-4384-861C-181440934B00} = {4E79BE4E-275E-4901-9173-E9096B7318F0}
|
||||
{F5D74163-145F-47BF-83DC-D0E07249C6CA} = {4E79BE4E-275E-4901-9173-E9096B7318F0}
|
||||
{E9102310-0029-4D8F-B1E9-88FBA6147D45} = {2AB9B589-5C98-4C05-BBEA-F97DAE168EAB}
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = MatterControl.csproj
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ using MatterHackers.MatterControl.SettingsManagement;
|
|||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.PolygonMesh.Processors;
|
||||
using MatterHackers.RenderOpenGl.OpenGl;
|
||||
using MatterHackers.TestRunner;
|
||||
using MatterHackers.GuiAutomation;
|
||||
using MatterHackers.VectorMath;
|
||||
using Mindscape.Raygun4Net;
|
||||
using System;
|
||||
|
|
@ -533,7 +533,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
if (firstDraw)
|
||||
{
|
||||
//Task.Run((Action)ButtonClickTest);
|
||||
//Task.Run((Action)AutomationTest);
|
||||
UiThread.RunOnIdle(DoAutoConnectIfRequired);
|
||||
|
||||
firstDraw = false;
|
||||
|
|
@ -556,9 +556,9 @@ namespace MatterHackers.MatterControl
|
|||
//msGraph.Draw(MatterHackers.Agg.Transform.Affine.NewIdentity(), graphics2D);
|
||||
}
|
||||
|
||||
private void ButtonClickTest()
|
||||
private void AutomationTest()
|
||||
{
|
||||
TestFramework test = new TestFramework("C:/TestImages");
|
||||
AutomationRunner test = new AutomationRunner("C:/TestImages");
|
||||
test.Wait(2);
|
||||
test.ClickByName("SettingsAndControls");
|
||||
test.Wait(2);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit fd3e1f9259b528ab1f0d220c6007f53deb81c417
|
||||
Subproject commit 7f766b566fb0d98124b53e5a37bc84741c767567
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
/*
|
||||
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.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MatterHackers.TestRunner
|
||||
{
|
||||
public static class NativeMethods
|
||||
{
|
||||
// P/Invoke declarations
|
||||
[DllImport("gdi32.dll")]
|
||||
static extern bool BitBlt(IntPtr hdcDest, int xDest, int yDest, int wDest, int hDest, IntPtr hdcSource, int xSrc, int ySrc, CopyPixelOperation rop);
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDc);
|
||||
[DllImport("gdi32.dll")]
|
||||
static extern IntPtr DeleteDC(IntPtr hDc);
|
||||
[DllImport("gdi32.dll")]
|
||||
static extern IntPtr DeleteObject(IntPtr hDc);
|
||||
[DllImport("gdi32.dll")]
|
||||
static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);
|
||||
[DllImport("gdi32.dll")]
|
||||
static extern IntPtr CreateCompatibleDC(IntPtr hdc);
|
||||
[DllImport("gdi32.dll")]
|
||||
static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp);
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetDesktopWindow();
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetWindowDC(IntPtr ptr);
|
||||
|
||||
[DllImport("User32.Dll")]
|
||||
public static extern long SetCursorPos(int x, int y);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
|
||||
|
||||
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
|
||||
public const int MOUSEEVENTF_LEFTUP = 0x04;
|
||||
|
||||
public static int GetCurrentScreenHeight()
|
||||
{
|
||||
Size sz = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size;
|
||||
return sz.Height;
|
||||
}
|
||||
|
||||
public static ImageBuffer GetCurrentScreen()
|
||||
{
|
||||
ImageBuffer screenCapture = new ImageBuffer();
|
||||
|
||||
Size sz = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size;
|
||||
IntPtr hDesk = GetDesktopWindow();
|
||||
IntPtr hSrce = GetWindowDC(hDesk);
|
||||
IntPtr hDest = CreateCompatibleDC(hSrce);
|
||||
IntPtr hBmp = CreateCompatibleBitmap(hSrce, sz.Width, sz.Height);
|
||||
IntPtr hOldBmp = SelectObject(hDest, hBmp);
|
||||
bool b = BitBlt(hDest, 0, 0, sz.Width, sz.Height, hSrce, 0, 0, CopyPixelOperation.SourceCopy | CopyPixelOperation.CaptureBlt);
|
||||
Bitmap bmpScreenCapture = Bitmap.FromHbitmap(hBmp);
|
||||
SelectObject(hDest, hOldBmp);
|
||||
DeleteObject(hBmp);
|
||||
DeleteDC(hDest);
|
||||
ReleaseDC(hDesk, hSrce);
|
||||
|
||||
//bmpScreenCapture.Save("bitmapsave.png");
|
||||
|
||||
screenCapture = new ImageBuffer(bmpScreenCapture.Width, bmpScreenCapture.Height, 32, new BlenderBGRA());
|
||||
BitmapData bitmapData = bmpScreenCapture.LockBits(new Rectangle(0, 0, bmpScreenCapture.Width, bmpScreenCapture.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, bmpScreenCapture.PixelFormat);
|
||||
|
||||
int offset;
|
||||
byte[] buffer = screenCapture.GetBuffer(out offset);
|
||||
int bitmapDataStride = bitmapData.Stride;
|
||||
int backBufferStrideInBytes = screenCapture.StrideInBytes();
|
||||
int backBufferHeight = screenCapture.Height;
|
||||
int backBufferHeightMinusOne = backBufferHeight - 1;
|
||||
|
||||
unsafe
|
||||
{
|
||||
byte* bitmapDataScan0 = (byte*)bitmapData.Scan0;
|
||||
fixed (byte* pSourceFixed = &buffer[offset])
|
||||
{
|
||||
byte* pSource = bitmapDataScan0 + bitmapDataStride * backBufferHeightMinusOne;
|
||||
byte* pDestBuffer = pSourceFixed;
|
||||
for (int y = 0; y < screenCapture.Height; y++)
|
||||
{
|
||||
int* pSourceInt = (int*)pSource;
|
||||
pSourceInt -= (bitmapDataStride * y / 4);
|
||||
|
||||
int* pDestBufferInt = (int*)pDestBuffer;
|
||||
pDestBufferInt += (backBufferStrideInBytes * y / 4);
|
||||
|
||||
for (int x = 0; x < screenCapture.Width; x++)
|
||||
{
|
||||
pDestBufferInt[x] = pSourceInt[x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bmpScreenCapture.UnlockBits(bitmapData);
|
||||
|
||||
bmpScreenCapture.Dispose();
|
||||
|
||||
return screenCapture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,212 +0,0 @@
|
|||
/*
|
||||
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.VectorMath;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace MatterHackers.TestRunner
|
||||
{
|
||||
public class TestFramework
|
||||
{
|
||||
private string imageDirectory;
|
||||
|
||||
public TestFramework(string imageDirectory)
|
||||
{
|
||||
this.imageDirectory = imageDirectory;
|
||||
}
|
||||
|
||||
public enum ClickOrigin { LowerLeft, Center };
|
||||
|
||||
public bool ClickByName(string widgetName, int xOffset = 0, int yOffset = 0, double upDelaySeconds = .2, ClickOrigin origin = ClickOrigin.Center)
|
||||
{
|
||||
foreach (SystemWindow window in SystemWindow.OpenWindows)
|
||||
{
|
||||
GuiWidget widgetToClick = window.FindNamedChildRecursive(widgetName);
|
||||
if (widgetToClick != null)
|
||||
{
|
||||
RectangleDouble childBounds = widgetToClick.TransformToParentSpace(window, widgetToClick.LocalBounds);
|
||||
|
||||
if (origin == ClickOrigin.Center)
|
||||
{
|
||||
xOffset += (int)childBounds.Width / 2;
|
||||
yOffset += (int)childBounds.Height / 2;
|
||||
}
|
||||
|
||||
Point2D screenPosition = new Point2D((int)childBounds.Left + xOffset, (int)window.Height - (int)(childBounds.Bottom + yOffset));
|
||||
|
||||
screenPosition.x += WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.Location.X;
|
||||
screenPosition.y += WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.Location.Y + WidgetForWindowsFormsAbstract.MainWindowsFormsWindow.TitleBarHeight;
|
||||
|
||||
SetCursorPos(screenPosition.x, screenPosition.y);
|
||||
NativeMethods.mouse_event(NativeMethods.MOUSEEVENTF_LEFTDOWN, screenPosition.x, screenPosition.y, 0, 0);
|
||||
|
||||
Wait(upDelaySeconds);
|
||||
|
||||
NativeMethods.mouse_event(NativeMethods.MOUSEEVENTF_LEFTUP, screenPosition.x, screenPosition.y, 0, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Point2D CurrentMousPosition()
|
||||
{
|
||||
Point2D mousePos = new Point2D(System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y);
|
||||
return mousePos;
|
||||
}
|
||||
|
||||
public enum InterpolationType { LINEAR, EASE_IN, EASE_OUT, EASE_IN_OUT };
|
||||
|
||||
public double GetInterpolatedValue(double compleatedRatio0To1, InterpolationType interpolationType)
|
||||
{
|
||||
switch (interpolationType)
|
||||
{
|
||||
case InterpolationType.LINEAR:
|
||||
return compleatedRatio0To1;
|
||||
|
||||
case InterpolationType.EASE_IN:
|
||||
return Math.Pow(compleatedRatio0To1, 3);
|
||||
|
||||
case InterpolationType.EASE_OUT:
|
||||
return (Math.Pow(compleatedRatio0To1 - 1, 3) + 1);
|
||||
|
||||
case InterpolationType.EASE_IN_OUT:
|
||||
if (compleatedRatio0To1 < .5)
|
||||
{
|
||||
return Math.Pow(compleatedRatio0To1 * 2, 3) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Math.Pow(compleatedRatio0To1 * 2 - 2, 3) + 2) / 2;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCursorPos(int x, int y)
|
||||
{
|
||||
Vector2 start = new Vector2(CurrentMousPosition().x, CurrentMousPosition().y);
|
||||
Vector2 end = new Vector2(x, y);
|
||||
Vector2 delta = end - start;
|
||||
int steps = 50;
|
||||
for (int i = 0; i < steps; i++)
|
||||
{
|
||||
double ratio = i / (double)steps;
|
||||
ratio = GetInterpolatedValue(ratio, InterpolationType.EASE_IN_OUT);
|
||||
Vector2 current = start + delta * ratio;
|
||||
NativeMethods.SetCursorPos((int)current.x, (int)current.y);
|
||||
Thread.Sleep(20);
|
||||
}
|
||||
|
||||
NativeMethods.SetCursorPos((int)end.x, (int)end.y);
|
||||
}
|
||||
|
||||
public bool ClickImage(string imageName, int xOffset = 0, int yOffset = 0, double upDelaySeconds = .2, ClickOrigin origin = ClickOrigin.Center)
|
||||
{
|
||||
string pathToImage = Path.Combine(imageDirectory, imageName);
|
||||
|
||||
if (File.Exists(pathToImage))
|
||||
{
|
||||
ImageBuffer imageToLookFor = new ImageBuffer();
|
||||
|
||||
if (ImageIO.LoadImageData(pathToImage, imageToLookFor))
|
||||
{
|
||||
if (origin == ClickOrigin.Center)
|
||||
{
|
||||
xOffset += imageToLookFor.Width / 2;
|
||||
yOffset += imageToLookFor.Height / 2;
|
||||
}
|
||||
|
||||
ImageBuffer currentScreen = NativeMethods.GetCurrentScreen();
|
||||
|
||||
Vector2 matchPosition;
|
||||
double bestMatch;
|
||||
if (currentScreen.FindLeastSquaresMatch(imageToLookFor, out matchPosition, out bestMatch, 50))
|
||||
{
|
||||
// TODO: figure out which window the position is in
|
||||
Point2D screenPosition = new Point2D((int)matchPosition.x + xOffset, currentScreen.Height - (int)(matchPosition.y + yOffset));
|
||||
SetCursorPos(screenPosition.x, screenPosition.y);
|
||||
NativeMethods.mouse_event(NativeMethods.MOUSEEVENTF_LEFTDOWN, screenPosition.x, screenPosition.y, 0, 0);
|
||||
Wait(upDelaySeconds);
|
||||
NativeMethods.mouse_event(NativeMethods.MOUSEEVENTF_LEFTUP, screenPosition.x, screenPosition.y, 0, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public ImageBuffer GetCurrentScreen()
|
||||
{
|
||||
return NativeMethods.GetCurrentScreen();
|
||||
}
|
||||
|
||||
public bool ImageExists(ImageBuffer image)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ImageExists(string imageFileName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool NameExists(string widgetName)
|
||||
{
|
||||
foreach (SystemWindow window in SystemWindow.OpenWindows)
|
||||
{
|
||||
GuiWidget widgetToClick = window.FindNamedChildRecursive(widgetName);
|
||||
if (widgetToClick != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Wait(double timeInSeconds)
|
||||
{
|
||||
Thread.Sleep((int)(timeInSeconds * 1000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{9D193B5C-BEF4-44B2-AD6D-597B7A2C52C5}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MatterHackers.TestRunner</RootNamespace>
|
||||
<AssemblyName>TestRunner</AssemblyName>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>False</Optimize>
|
||||
<OutputPath>..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release64|AnyCPU'">
|
||||
<OutputPath>bin\Release64\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug64|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug64\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release64|x64'">
|
||||
<OutputPath>bin\x64\Release64\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug64|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug64\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="TestFramework.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Submodules\agg-sharp\agg\Agg.csproj">
|
||||
<Project>{657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}</Project>
|
||||
<Name>Agg</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Submodules\agg-sharp\Gui\Gui.csproj">
|
||||
<Project>{74F6BB6C-9D02-4512-A59A-21940E35C532}</Project>
|
||||
<Name>Gui</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Submodules\agg-sharp\ImageProcessing\ImageProcessing.csproj">
|
||||
<Project>{036BCCBA-52D8-457C-84AE-8821F209FE4A}</Project>
|
||||
<Name>ImageProcessing</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Submodules\agg-sharp\PlatformAbstract\PlatformAbstract.csproj">
|
||||
<Project>{3e4aaba8-d85f-4922-88c6-5c1b2d2308fb}</Project>
|
||||
<Name>PlatformAbstract</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Submodules\agg-sharp\PlatformWin32\PlatformWin32.csproj">
|
||||
<Project>{670bddff-927b-425d-9dd1-22acb14356eb}</Project>
|
||||
<Name>PlatformWin32</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Submodules\agg-sharp\VectorMath\VectorMath.csproj">
|
||||
<Project>{D3E41B4E-BFBB-44CA-94C8-95C00F754FDD}</Project>
|
||||
<Name>VectorMath</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="OpenTK" publicKeyToken="bad199fe84eb3df4" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="InputSimulator" version="1.0.4.0" targetFramework="net45" />
|
||||
</packages>
|
||||
Loading…
Add table
Add a link
Reference in a new issue