mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 22:34:27 -07:00
Removed external test dependency (#131)
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:
parent
1870cfe5f9
commit
74cf71eeaa
1 changed files with 14 additions and 1 deletions
|
@ -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>
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue