-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[unity]il2cpp优化打开后,对Delegate.Invoke的支持
- Loading branch information
1 parent
c0a018d
commit bcfabbd
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
|
||
namespace Puerts.UnitTest | ||
{ | ||
public delegate void TestCallback(string msg); | ||
class DelegateTestClass | ||
{ | ||
public TestCallback Callback; | ||
|
||
public void CSMessage() | ||
{ | ||
Callback("cs_msg"); | ||
} | ||
}; | ||
|
||
[TestFixture] | ||
public class DelegateTest | ||
{ | ||
[Test] | ||
public void DelegateBase() | ||
{ | ||
var jsEnv = UnitTestEnv.GetEnv(); | ||
|
||
jsEnv.Eval(@" | ||
globalThis.deleteobj = new CS.Puerts.UnitTest.DelegateTestClass() | ||
deleteobj.Callback = (msg) => globalThis.info = msg; | ||
deleteobj.CSMessage(); | ||
"); | ||
|
||
string info = jsEnv.Eval<string>("globalThis.info"); | ||
Assert.AreEqual("cs_msg", info); | ||
|
||
jsEnv.Eval(@"deleteobj.Callback.Invoke('js_msg')"); | ||
info = jsEnv.Eval<string>("globalThis.info"); | ||
Assert.AreEqual("js_msg", info); | ||
} | ||
} | ||
} |