mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
9407ba1828
Readd CefSharp.Test.csproj to solution Add some very basic unit tests using xunit, DisableTestParallelization, Set xunit.appDomain to denied in app.config to disable using appdomains (https://xunit.github.io/docs/configuring-with-xml.html) Add xunit vs test running packages, using 2.2.0 version as 2.3.0 was throwing an exception similar to https://github.com/xunit/xunit/issues/1514 TODO: Take a look at https://github.com/NuGet/NuGetGallery/tree/master/tests/NuGetGallery.Facts for some ideas on structuring xunit tests (look at implementing Theory) NOTE: I am not providing this as a definitive set of tests, it's simply here to get someone else started in creating tests as it appears people have trouble dealing with AppDomain problem Only includes Tests for the OffScreen version at this stage.
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
// Copyright © 2010-2017 The CefSharp Authors. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using CefSharp.Internals;
|
|
|
|
namespace CefSharp.Test
|
|
{
|
|
public static class WebBrowserTestExtensions
|
|
{
|
|
public static Task LoadPageAsync(this IWebBrowser browser, string address = null)
|
|
{
|
|
//If using .Net 4.6 then use TaskCreationOptions.RunContinuationsAsynchronously
|
|
//and switch to tcs.TrySetResult below - no need for the custom extension method
|
|
var tcs = new TaskCompletionSource<bool>();
|
|
|
|
EventHandler<LoadingStateChangedEventArgs> handler = null;
|
|
handler = (sender, args) =>
|
|
{
|
|
//Wait for while page to finish loading not just the first frame
|
|
if (!args.IsLoading)
|
|
{
|
|
browser.LoadingStateChanged -= handler;
|
|
//This is required when using a standard TaskCompletionSource
|
|
//Extension method found in the CefSharp.Internals namespace
|
|
tcs.TrySetResultAsync(true);
|
|
}
|
|
};
|
|
|
|
browser.LoadingStateChanged += handler;
|
|
|
|
if (!string.IsNullOrEmpty(address))
|
|
{
|
|
browser.Load(address);
|
|
}
|
|
return tcs.Task;
|
|
}
|
|
}
|
|
}
|