Tests - Improve RequestContextTests

This commit is contained in:
amaitland
2024-11-23 12:46:39 +10:00
parent 0d1b91a541
commit 3dca565806
+19 -3
View File
@@ -40,7 +40,7 @@ namespace CefSharp.Test.Framework
public void CanGetContentSetting()
{
var ctx = RequestContext.Configure()
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache1"))
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache2"))
.Create();
var actual = ctx.GetContentSetting(CefExample.DefaultUrl, null, ContentSettingTypes.Autoplay);
@@ -51,10 +51,18 @@ namespace CefSharp.Test.Framework
[Fact]
public async Task CanSetContentSetting()
{
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var ctx = RequestContext.Configure()
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache1"))
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache3"))
.OnInitialize((ctx) =>
{
tcs.SetResult(true);
})
.Create();
await tcs.Task;
var actual = ContentSettingValues.Default;
await CefThread.ExecuteOnUiThread(() =>
@@ -70,10 +78,18 @@ namespace CefSharp.Test.Framework
[Fact]
public async Task CanSetWebsiteSetting()
{
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var ctx = RequestContext.Configure()
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache1"))
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache4"))
.OnInitialize((ctx) =>
{
tcs.SetResult(true);
})
.Create();
await tcs.Task;
object actual = ContentSettingValues.Default;
await CefThread.ExecuteOnUiThread(() =>