mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-03 23:12:42 +00:00
fc8bf6d1a0
* Make BrowserRefCount test more reliable * use embedded url * wait for browsers to close before running test --------- Co-authored-by: amaitland <307872+amaitland@users.noreply.github.com>
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
// Copyright © 2022 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.Internals;
|
|
using CefSharp.OffScreen;
|
|
using CefSharp.Web;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace CefSharp.Test.OffScreen
|
|
{
|
|
//NOTE: All Test classes must be part of this collection as it manages the Cef Initialize/Shutdown lifecycle
|
|
[Collection(CefSharpFixtureCollection.Key)]
|
|
public class BrowserRefCountTests
|
|
{
|
|
private readonly ITestOutputHelper output;
|
|
private readonly CefSharpFixture fixture;
|
|
|
|
public BrowserRefCountTests(ITestOutputHelper output, CefSharpFixture fixture)
|
|
{
|
|
this.fixture = fixture;
|
|
this.output = output;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task ShouldWork()
|
|
{
|
|
Cef.WaitForBrowsersToClose(1000);
|
|
|
|
var startCount = BrowserRefCounter.Instance.Count;
|
|
|
|
using (var browser = new ChromiumWebBrowser(CefExample.HelloWorldUrl, useLegacyRenderHandler: false))
|
|
{
|
|
var response = await browser.WaitForInitialLoadAsync();
|
|
|
|
Assert.True(response.Success);
|
|
Assert.Equal(startCount + 1, BrowserRefCounter.Instance.Count);
|
|
}
|
|
|
|
Cef.WaitForBrowsersToClose(10000);
|
|
|
|
output.WriteLine("BrowserRefCounter Log");
|
|
output.WriteLine(BrowserRefCounter.Instance.GetLog());
|
|
|
|
Assert.Equal(startCount, BrowserRefCounter.Instance.Count);
|
|
}
|
|
}
|
|
}
|