Skip to content

Commit 3dca565

Browse files
committed
Tests - Improve RequestContextTests
1 parent 0d1b91a commit 3dca565

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

CefSharp.Test/Framework/RequestContextTests.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void IsSharingWith()
4040
public void CanGetContentSetting()
4141
{
4242
var ctx = RequestContext.Configure()
43-
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache1"))
43+
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache2"))
4444
.Create();
4545

4646
var actual = ctx.GetContentSetting(CefExample.DefaultUrl, null, ContentSettingTypes.Autoplay);
@@ -51,10 +51,18 @@ public void CanGetContentSetting()
5151
[Fact]
5252
public async Task CanSetContentSetting()
5353
{
54+
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
55+
5456
var ctx = RequestContext.Configure()
55-
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache1"))
57+
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache3"))
58+
.OnInitialize((ctx) =>
59+
{
60+
tcs.SetResult(true);
61+
})
5662
.Create();
5763

64+
await tcs.Task;
65+
5866
var actual = ContentSettingValues.Default;
5967

6068
await CefThread.ExecuteOnUiThread(() =>
@@ -70,10 +78,18 @@ await CefThread.ExecuteOnUiThread(() =>
7078
[Fact]
7179
public async Task CanSetWebsiteSetting()
7280
{
81+
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
82+
7383
var ctx = RequestContext.Configure()
74-
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache1"))
84+
.WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache4"))
85+
.OnInitialize((ctx) =>
86+
{
87+
tcs.SetResult(true);
88+
})
7589
.Create();
7690

91+
await tcs.Task;
92+
7793
object actual = ContentSettingValues.Default;
7894

7995
await CefThread.ExecuteOnUiThread(() =>

0 commit comments

Comments
 (0)