-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathBrowserTests.cs
More file actions
47 lines (37 loc) · 1.46 KB
/
BrowserTests.cs
File metadata and controls
47 lines (37 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright © 2021 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.Threading.Tasks;
using CefSharp.Example;
using CefSharp.OffScreen;
using Xunit;
namespace CefSharp.Test
{
public abstract class BrowserTests : IAsyncLifetime
{
public ChromiumWebBrowser Browser { get; private set; }
public bool RequestContextIsolated { get; protected set; }
protected void AssertInitialLoadComplete()
{
var t = Browser.WaitForInitialLoadAsync();
Assert.True(t.IsCompleted, "WaitForInitialLoadAsync Task.IsComplete");
Assert.True(t.Result.Success, "WaitForInitialLoadAsync Result.Success");
}
Task IAsyncLifetime.DisposeAsync()
{
Browser?.Dispose();
return Task.CompletedTask;
}
Task IAsyncLifetime.InitializeAsync()
{
IRequestContext requestContext = null;
if (RequestContextIsolated)
{
requestContext = new RequestContext();
requestContext.RegisterSchemeHandlerFactory("https", CefExample.ExampleDomain, new CefSharpSchemeHandlerFactory());
}
Browser = new ChromiumWebBrowser(CefExample.HelloWorldUrl, requestContext: requestContext, useLegacyRenderHandler: false);
return Browser.WaitForInitialLoadAsync();
}
}
}