Removed external test dependency

Removed capture test being dependent on some Notepad window. Test was only successfull if this window existed.

Code from [here](450fae4b4a/src/Dapplo.Windows.Tests/WindowsEnumeratorTests.cs (L85))
This commit is contained in:
Matthäus Falkowski 2019-06-04 15:23:28 +02:00
commit ae6e0985b3

View file

@ -20,6 +20,7 @@
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
@ -117,7 +118,19 @@ namespace Greenshot.Tests
{ {
ICoreConfiguration config = new CoreConfigurationImpl(); ICoreConfiguration config = new CoreConfigurationImpl();
var windowToCapture = InteropWindowQuery.GetTopLevelWindows().First(window => window.GetCaption().Contains("Notepad")); var textValue = System.Guid.NewGuid().ToString();
var form = new Form
{
Text = textValue,
TopLevel = true
};
form.Show();
// Important, otherwise Windows doesn't have time to display the window!
Application.DoEvents();
await Task.Delay(400);
var windowToCapture = await WindowsEnumerator.EnumerateWindowsAsync().Where(info => info.GetCaption().Contains(textValue)).FirstOrDefaultAsync();
var bounds = windowToCapture.GetInfo().Bounds; var bounds = windowToCapture.GetInfo().Bounds;
var captureFlow = new CaptureFlow<BitmapSource> var captureFlow = new CaptureFlow<BitmapSource>
{ {