Skip to content

Commit

Permalink
Add BindingTestSingle.html
Browse files Browse the repository at this point in the history
Simple test page that can be used to test cases in isolation (useful for debugging purposes)
  • Loading branch information
amaitland committed Mar 5, 2018
1 parent c1255e8 commit 33c0620
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 4 deletions.
1 change: 1 addition & 0 deletions CefSharp.Example/CefExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static class CefExample
public const string BaseUrl = "custom://cefsharp";
public const string DefaultUrl = BaseUrl + "/home.html";
public const string BindingTestUrl = BaseUrl + "/BindingTest.html";
public const string BindingTestSingleUrl = BaseUrl + "/BindingTestSingle.html";
public const string LegacyBindingTestUrl = BaseUrl + "/LegacyBindingTest.html";
public const string PluginsTestUrl = BaseUrl + "/plugins.html";
public const string PopupTestUrl = BaseUrl + "/PopupTest.html";
Expand Down
1 change: 1 addition & 0 deletions CefSharp.Example/CefSharp.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
<Content Include="Resources\assets\js\shBrushCSharp.js" />
<None Include="Resources\assets\js\shBrushJScript.js" />
<Content Include="Resources\assets\js\shCore.js" />
<Content Include="Resources\BindingTestSingle.html" />
<Content Include="Resources\LegacyBindingTest.html" />
<Content Include="Resources\CdmSupportTest.html" />
<Content Include="Resources\CssAnimation.html" />
Expand Down
1 change: 1 addition & 0 deletions CefSharp.Example/CefSharpSchemeHandlerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static CefSharpSchemeHandlerFactory()
{ "/bootstrap/bootstrap.min.js", Resources.bootstrap_min_js },

{ "/BindingTest.html", Resources.BindingTest },
{ "/BindingTestSingle.html", Resources.BindingTestSingle },
{ "/LegacyBindingTest.html", Resources.LegacyBindingTest },
{ "/ExceptionTest.html", Resources.ExceptionTest },
{ "/PopupTest.html", Resources.PopupTest },
Expand Down
26 changes: 25 additions & 1 deletion CefSharp.Example/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions CefSharp.Example/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,7 @@
<data name="LegacyBindingTest" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\LegacyBindingTest.html;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="BindingTestSingle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\BindingTestSingle.html;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
21 changes: 18 additions & 3 deletions CefSharp.Example/Resources/BindingTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,28 @@
});
});

QUnit.test("Async call (Object):", function( assert )
QUnit.test("Async call (Struct):", function( assert )
{
var asyncCallback = assert.async();

boundAsync.returnObject('CefSharp').then(function (res)
boundAsync.returnObject('CefSharp Struct Test').then(function (res)
{
assert.equal(res.Value, "CefSharp", "JSON Object with a single field");
assert.equal(res.Value, "CefSharp Struct Test", "Struct with a single field");

asyncCallback();
});
});

QUnit.test("Async call (Class):", function (assert)
{
var asyncCallback = assert.async();

//Returns a class
boundAsync.returnClass('CefSharp Class Test').then(function (res)
{
const expectedResult = 'CefSharp Class Test';

assert.equal(expectedResult, res.Value, "Class with a single field " + expectedResult);

asyncCallback();
});
Expand Down
52 changes: 52 additions & 0 deletions CefSharp.Example/Resources/BindingTestSingle.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Binding Test</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.4.1.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://code.jquery.com/qunit/qunit-2.4.1.js"></script>

<script type="text/javascript">
(async () =>
{
await CefSharp.BindObjectAsync("boundAsync", "bound");

QUnit.test( "Struct Test:", function( assert )
{
var asyncCallback = assert.async();

//Returns a Struct
boundAsync.returnObject('CefSharp Struct Test').then(function (actualResult)
{
const expectedResult = 'CefSharp Struct Test';

assert.equal(expectedResult, actualResult.Value, "Return class " + expectedResult);

asyncCallback();
});
});

QUnit.test( "Class Test:", function( assert )
{
var asyncCallback = assert.async();

//Returns a class
boundAsync.returnClass('CefSharp Class Test').then(function (actualResult)
{
const expectedResult = 'CefSharp Class Test';

assert.equal(expectedResult, actualResult.Value, "Return class " + expectedResult);

asyncCallback();
});
});


})();
</script>

</body>
</html>

0 comments on commit 33c0620

Please sign in to comment.