diff --git a/CefSharp.Example/BoundObject.cs b/CefSharp.Example/BoundObject.cs index 95b3d1153..ddbdd59b5 100644 --- a/CefSharp.Example/BoundObject.cs +++ b/CefSharp.Example/BoundObject.cs @@ -18,6 +18,151 @@ namespace CefSharp.Example public void EchoVoid() { - } + } + + public Boolean EchoBoolean(Boolean arg0) + { + return arg0; + } + + public Boolean? EchoNullableBoolean(Boolean? arg0) + { + return arg0; + } + + public SByte EchoSByte(SByte arg0) + { + return arg0; + } + + public SByte? EchoNullableSByte(SByte? arg0) + { + return arg0; + } + + public Int16 EchoInt16(Int16 arg0) + { + return arg0; + } + + public Int16? EchoNullableInt16(Int16? arg0) + { + return arg0; + } + + public Int32 EchoInt32(Int32 arg0) + { + return arg0; + } + + public Int32? EchoNullableInt32(Int32? arg0) + { + return arg0; + } + + public Int64 EchoInt64(Int64 arg0) + { + return arg0; + } + + public Int64? EchoNullableInt64(Int64? arg0) + { + return arg0; + } + + public Byte EchoByte(Byte arg0) + { + return arg0; + } + + public Byte? EchoNullableByte(Byte? arg0) + { + return arg0; + } + + public UInt16 EchoUInt16(UInt16 arg0) + { + return arg0; + } + + public UInt16? EchoNullableUInt16(UInt16? arg0) + { + return arg0; + } + + public UInt32 EchoUInt32(UInt32 arg0) + { + return arg0; + } + + public UInt32? EchoNullableUInt32(UInt32? arg0) + { + return arg0; + } + + public UInt64 EchoUInt64(UInt64 arg0) + { + return arg0; + } + + public UInt64? EchoNullableUInt64(UInt64? arg0) + { + return arg0; + } + + public Single EchoSingle(Single arg0) + { + return arg0; + } + + public Single? EchoNullableSingle(Single? arg0) + { + return arg0; + } + + public Double EchoDouble(Double arg0) + { + return arg0; + } + + public Double? EchoNullableDouble(Double? arg0) + { + return arg0; + } + + public Char EchoChar(Char arg0) + { + return arg0; + } + + public Char? EchoNullableChar(Char? arg0) + { + return arg0; + } + + public DateTime EchoDateTime(DateTime arg0) + { + return arg0; + } + + public DateTime? EchoNullableDateTime(DateTime? arg0) + { + return arg0; + } + + public Decimal EchoDecimal(Decimal arg0) + { + return arg0; + } + + public Decimal? EchoNullableDecimal(Decimal? arg0) + { + return arg0; + } + + public String EchoString(String arg0) + { + return arg0; + } } } \ No newline at end of file diff --git a/CefSharp.Tests/BindObjectTests.cs b/CefSharp.Tests/BindObjectTests.cs index 9e154f483..a55d376df 100644 --- a/CefSharp.Tests/BindObjectTests.cs +++ b/CefSharp.Tests/BindObjectTests.cs @@ -107,20 +107,6 @@ Assert.Fail(); } - [Test] - public void Int_Echo_Int_Test() - { - var result = RunScript("return bound.EchoInt(67);"); - Assert.AreEqual("67", result); - } - - [Test] - public void String_Echo_String_Test() - { - var result1 = RunScript("return bound.EchoString('test string');"); - Assert.AreEqual("test string", result1); - } - [Test] public void StringUnicodeTest() { @@ -190,12 +176,12 @@ [TestCase("Boolean_Null", "bound.EchoBoolean(null) === false", false)] [TestCase("Boolean_Boolean_True", "bound.EchoBoolean(true) === true", false)] [TestCase("Boolean_Boolean_False", "bound.EchoBoolean(false) === false", false)] - [TestCase("Boolean_Number_0", "bound.EchoBoolean(0) === false", true)] - [TestCase("Boolean_Number_1", "bound.EchoBoolean(1) === true", true)] - [TestCase("Boolean_String", "bound.EchoBoolean('0') === true", true)] - [TestCase("Boolean_Date", "bound.EchoBoolean(new Date()) === true", true)] - [TestCase("Boolean_Array", "bound.EchoBoolean([]) === true", true)] - [TestCase("Boolean_Object", "bound.EchoBoolean({}) === true", true)] + [TestCase("Boolean_Number_0", "bound.EchoBoolean(0), false", true)] + [TestCase("Boolean_Number_1", "bound.EchoBoolean(1), false", true)] + [TestCase("Boolean_String", "bound.EchoBoolean('0'), false", true)] + [TestCase("Boolean_Date", "bound.EchoBoolean(new Date()), false", true)] + [TestCase("Boolean_Array", "bound.EchoBoolean([]), false", true)] + [TestCase("Boolean_Object", "bound.EchoBoolean({}), false", true)] /* |=CLR Type |=JavaScript values and objects | @@ -210,46 +196,175 @@ |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | SByte | - | - | - | + | - | - | - | - | +*/ + [TestCase("SByte_Undefined", "bound.EchoSByte(undefined), false", true)] + [TestCase("SByte_Null", "bound.EchoSByte(null), false", true)] + [TestCase("SByte_Boolean", "bound.EchoSByte(true), false", true)] + [TestCase("SByte_Number_-128", "bound.EchoSByte(-128) === -128", false)] + [TestCase("SByte_Number_+127", "bound.EchoSByte(+127) === +127", false)] + [TestCase("SByte_Number_Overflow", "bound.EchoSByte(+128), false", true)] + [TestCase("SByte_String", "bound.EchoSByte('0'), false", true)] + [TestCase("SByte_Date", "bound.EchoSByte(new Date()), false", true)] + [TestCase("SByte_Array", "bound.EchoSByte([]), false", true)] + [TestCase("SByte_Object", "bound.EchoSByte({}), false", true)] +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| SByte? | *null | *null | - | + | - | - | - | - | +*/ + [TestCase("SByte?_Undefined", "bound.EchoSByte(undefined) === null", false)] + [TestCase("SByte?_Null", "bound.EchoSByte(null) === null", false)] + [TestCase("SByte?_Number_-128", "bound.EchoSByte(-128) === -128", false)] + +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | Int16 | - | - | - | + | - | - | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| Int16? | - | - | - | + | - | - | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | Int32 | - | - | - | + | - | - | - | - | +*/ + [TestCase("Int32_Undefined", "bound.EchoInt32(undefined), false", true)] + [TestCase("Int32_Null", "bound.EchoInt32(null), false", true)] + [TestCase("Int32_Boolean", "bound.EchoInt32(true), false", true)] + [TestCase("Int32_Number_-2147483648", "bound.EchoInt32(-2147483648) === -2147483648", false)] + [TestCase("Int32_Number_+2147483647", "bound.EchoInt32(+2147483647) === +2147483647", false)] + [TestCase("Int32_Number_Overflow", "bound.EchoInt32(+2147483648), false", true)] + [TestCase("Int32_String", "bound.EchoInt32('0'), false", true)] + [TestCase("Int32_Date", "bound.EchoInt32(new Date()), false", true)] + [TestCase("Int32_Array", "bound.EchoInt32([]), false", true)] + [TestCase("Int32_Object", "bound.EchoInt32({}), false", true)] +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| Int32? | *null | *null | - | + | - | - | - | - | +*/ + [TestCase("Int32?_Undefined", "bound.EchoInt32(undefined) === null", false)] + [TestCase("Int32?_Null", "bound.EchoInt32(null) === null", false)] + [TestCase("Int32?_Number_-2147483648", "bound.EchoInt32(-2147483648) === -2147483648", false)] + +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | Int64 | - | - | - | + | - | - | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| Int64? | - | - | - | + | - | - | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | Byte | - | - | - | + | - | - | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| Byte? | - | - | - | + | - | - | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | UInt16 | - | - | - | + | - | - | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| UInt16? | - | - | - | + | - | - | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | UInt32 | - | - | - | + | - | - | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| UInt32? | - | - | - | + | - | - | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | UInt64 | - | - | - | + | - | - | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| UInt64? | - | - | - | + | - | - | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | Single | - | - | - | + | - | - | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| Single? | - | - | - | + | - | - | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | Double | - | - | - | + | - | - | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| Double? | - | - | - | + | - | - | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | Char | - | - | - | + | - | - | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| Char? | - | - | - | + | - | - | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | DateTime | - | - | - | - | - | + | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| DateTime? | - | - | - | - | - | + | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | Decimal | - | - | - | + | - | - | - | - | +*/ +/* +|=CLR Type |=JavaScript values and objects | +| |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | +| Decimal? | - | - | - | + | - | - | - | - | +*/ +/* |=CLR Type |=JavaScript values and objects | | |=undefined |=null |=Boolean |=Number |=String |=Date |=Array |=Object | | String | - | + | - | - | + | - | - | - | */ + [TestCase("String_Undefined", "bound.EchoString(undefined) === null", false)] + [TestCase("String_Null", "bound.EchoString(null) === null", false)] + [TestCase("String_Boolean", "bound.EchoString(true), false", true)] + [TestCase("String_Number_1000", "bound.EchoString(1000), false", true)] + [TestCase("String_String_Empty", "bound.EchoString('') === ''", false)] + [TestCase("String_String_Value", "bound.EchoString('Value') === 'Value'", false)] + [TestCase("String_Date", "bound.EchoString(new Date()), false", true)] + [TestCase("String_Array", "bound.EchoString([]), false", true)] + [TestCase("String_Object", "bound.EchoString({}), false", true)] + public void ExpectScriptExpr(string name, string jsExpr, bool expectScriptException) { string script = "return ((" + jsExpr + ")? 'pass' : 'fail');"; diff --git a/CefSharp.Tests/BoundObject.cs b/CefSharp.Tests/BoundObject.cs index 1b6a3ee8f..111d1f4ad 100644 --- a/CefSharp.Tests/BoundObject.cs +++ b/CefSharp.Tests/BoundObject.cs @@ -11,24 +11,147 @@ namespace CefSharp.Tests { } - public bool EchoBoolean(bool arg0) + public Boolean EchoBoolean(Boolean arg0) { return arg0; } - public bool? EchoNullableBoolean(bool? arg0) + public Boolean? EchoNullableBoolean(Boolean? arg0) { return arg0; } - - - public int EchoInt(int arg0) + public SByte EchoSByte(SByte arg0) { return arg0; } - public string EchoString(string arg0) + public SByte? EchoNullableSByte(SByte? arg0) + { + return arg0; + } + + public Int16 EchoInt16(Int16 arg0) + { + return arg0; + } + + public Int16? EchoNullableInt16(Int16? arg0) + { + return arg0; + } + + public Int32 EchoInt32(Int32 arg0) + { + return arg0; + } + + public Int32? EchoNullableInt32(Int32? arg0) + { + return arg0; + } + + public Int64 EchoInt64(Int64 arg0) + { + return arg0; + } + + public Int64? EchoNullableInt64(Int64? arg0) + { + return arg0; + } + + public Byte EchoByte(Byte arg0) + { + return arg0; + } + + public Byte? EchoNullableByte(Byte? arg0) + { + return arg0; + } + + public UInt16 EchoUInt16(UInt16 arg0) + { + return arg0; + } + + public UInt16? EchoNullableUInt16(UInt16? arg0) + { + return arg0; + } + + public UInt32 EchoUInt32(UInt32 arg0) + { + return arg0; + } + + public UInt32? EchoNullableUInt32(UInt32? arg0) + { + return arg0; + } + + public UInt64 EchoUInt64(UInt64 arg0) + { + return arg0; + } + + public UInt64? EchoNullableUInt64(UInt64? arg0) + { + return arg0; + } + + public Single EchoSingle(Single arg0) + { + return arg0; + } + + public Single? EchoNullableSingle(Single? arg0) + { + return arg0; + } + + public Double EchoDouble(Double arg0) + { + return arg0; + } + + public Double? EchoNullableDouble(Double? arg0) + { + return arg0; + } + + public Char EchoChar(Char arg0) + { + return arg0; + } + + public Char? EchoNullableChar(Char? arg0) + { + return arg0; + } + + public DateTime EchoDateTime(DateTime arg0) + { + return arg0; + } + + public DateTime? EchoNullableDateTime(DateTime? arg0) + { + return arg0; + } + + public Decimal EchoDecimal(Decimal arg0) + { + return arg0; + } + + public Decimal? EchoNullableDecimal(Decimal? arg0) + { + return arg0; + } + + public String EchoString(String arg0) { return arg0; } diff --git a/CefSharp/BindingHandler.cpp b/CefSharp/BindingHandler.cpp index 8320917b5..c637bc42e 100644 --- a/CefSharp/BindingHandler.cpp +++ b/CefSharp/BindingHandler.cpp @@ -61,7 +61,7 @@ namespace CefSharp Object^ self = bindingData->Get(); if(self == nullptr) { - exception = "binding's CLR object is null"; + exception = "Binding's CLR object is null."; return true; } @@ -72,7 +72,7 @@ namespace CefSharp if(members->Length == 0) { - exception = convertFromString("no member named " + memberName); + exception = convertFromString("No member named " + memberName + "."); return true; }