@@ -183,6 +183,17 @@ public NewObject PushObject()
183183 {
184184 return new NewObject ( ) ;
185185 }
186+
187+ public static string AddPackage ( string descFilePath )
188+ {
189+ return descFilePath ;
190+ }
191+ public static string AddPackage ( string assetPath , LoadResource loadFunc )
192+ {
193+ return assetPath ;
194+ }
195+
196+ public delegate object LoadResource ( string name , string extension , System . Type type , out TestEnum destroyMethod ) ;
186197 }
187198
188199 public enum ConstructorParam
@@ -1559,6 +1570,41 @@ public void EnumParamCheck() // https://github.com/Tencent/puerts/issues/2018
15591570 " ) ;
15601571 }
15611572
1573+ [ Test ]
1574+ public void AddPackageTest ( )
1575+ {
1576+ var jsEnv = UnitTestEnv . GetEnv ( ) ;
1577+ // Test AddPackage with single string parameter
1578+ var result1 = jsEnv . Eval < string > ( @"
1579+ (function() {
1580+ const CrossLangTestHelper = CS.Puerts.UnitTest.CrossLangTestHelper;
1581+ const result = CrossLangTestHelper.AddPackage('test/path/to/desc.json');
1582+ return result;
1583+ })()
1584+ " ) ;
1585+ Assert . AreEqual ( "test/path/to/desc.json" , result1 ) ;
1586+
1587+ // Test AddPackage with string and delegate parameters
1588+ var result2 = jsEnv . Eval < string > ( @"
1589+ (function() {
1590+ const CrossLangTestHelper = CS.Puerts.UnitTest.CrossLangTestHelper;
1591+ const TestEnum = CS.Puerts.UnitTest.TestEnum;
1592+
1593+ // Create a load function delegate
1594+ const loadFunc = function(name, extension, type, outDestroyMethod) {
1595+ // outDestroyMethod is an out parameter, set it to TestEnum.A
1596+ outDestroyMethod.value = TestEnum.A;
1597+ return { name: name, ext: extension };
1598+ };
1599+
1600+ const result = CrossLangTestHelper.AddPackage('test/asset/path', loadFunc);
1601+ return result;
1602+ })()
1603+ " ) ;
1604+ Assert . AreEqual ( "test/asset/path" , result2 ) ;
1605+ jsEnv . Tick ( ) ;
1606+ }
1607+
15621608 [ Test ]
15631609 public void PassNullTest ( )
15641610 {
0 commit comments