From 3dca565806ceea12da9bd101aa59f0c000097ab2 Mon Sep 17 00:00:00 2001 From: amaitland <307872+amaitland@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:46:39 +1000 Subject: [PATCH] Tests - Improve RequestContextTests --- .../Framework/RequestContextTests.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/CefSharp.Test/Framework/RequestContextTests.cs b/CefSharp.Test/Framework/RequestContextTests.cs index f4f83610c..714e8fe5b 100644 --- a/CefSharp.Test/Framework/RequestContextTests.cs +++ b/CefSharp.Test/Framework/RequestContextTests.cs @@ -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(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(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(() =>