Skip to content

Commit

Permalink
Example - Add JSB Qunit Tests for Binder UInt conversion
Browse files Browse the repository at this point in the history
Issue #2906
  • Loading branch information
amaitland committed Sep 26, 2019
1 parent 58c9585 commit 6ead2b3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions CefSharp.Example/CefSharp.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<Compile Include="JavascriptBinding\JavascriptCallbackBoundObject.cs" />
<Compile Include="JavascriptBinding\JsSerializableClass.cs" />
<Compile Include="JavascriptBinding\JsSerializableStruct.cs" />
<Compile Include="JavascriptBinding\UIntAddModel.cs" />
<Compile Include="ModelBinding\MethodInterceptorLogger.cs" />
<Compile Include="PostMessage\PostMessageExample.cs" />
<Compile Include="PostMessage\PostMessageExampleData.cs" />
Expand Down
5 changes: 5 additions & 0 deletions CefSharp.Example/JavascriptBinding/AsyncBoundObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,10 @@ public async Task<string> AsyncThrowException()

throw new Exception("Expected Exception");
}

public uint UIntAdd(UIntAddModel model)
{
return model.ParamA + model.ParamB;
}
}
}
13 changes: 13 additions & 0 deletions CefSharp.Example/JavascriptBinding/UIntAddModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright © 2019 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.


namespace CefSharp.Example.JavascriptBinding
{
public class UIntAddModel
{
public uint ParamA { get; set; }
public uint ParamB { get; set; }
}
}
14 changes: 14 additions & 0 deletions CefSharp.Example/Resources/BindingTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,20 @@
});
});

QUnit.test("Async call (UIntAdd 3 + 2):", function (assert)
{
var asyncCallback = assert.async();

boundAsync.uIntAdd({ ParamA: 3, ParamB: 2 }).then(function (actualResult)
{
const expectedResult = 5

assert.equal(expectedResult, actualResult, "Add 3 + 2 resulted in " + expectedResult);

asyncCallback();
});
});

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

0 comments on commit 6ead2b3

Please sign in to comment.