55using EngineBinaryFileRewriter ;
66using NUnit . Framework ;
77using UnityEditor ;
8+ using UnityEngine ;
89
910public class FixFreezingInAsyncResourceUploadBlocking
1011{
@@ -25,26 +26,7 @@ public void TestAndroidGradleProject([Values] bool stripEngineCode)
2526 Utility . BuildAndroid ( GradleProjectDir , development , stripEngineCode , Feature , TargetAndroidArchitectures ) ;
2627 }
2728
28- int archCount = 0 ;
29-
30- foreach ( var kv in Utility . AndroidArchitectures )
31- {
32- var arch = kv . Key ;
33- var archName = kv . Value ;
34-
35- var path = Path . Combine ( GradleProjectDir , "unityLibrary/src/main/jniLibs" , archName , "libunity.so" ) ;
36- if ( File . Exists ( path ) )
37- {
38- var diffs = GetDiffs ( Feature , BuildTarget . Android , arch , development ) . ToArray ( ) ;
39-
40- var backupPath = Path . Combine ( AndroidBackupDir , archName , "libunity.so" ) ;
41- Utility . CompareFiles ( backupPath , path , diffs ) ;
42-
43- archCount ++ ;
44- }
45- }
46-
47- Assert . AreEqual ( 2 , archCount ) ;
29+ Utility . ValidateAndroid ( GradleProjectDir , development , Feature , AndroidBackupDir , GetDiffs ) ;
4830 }
4931
5032 [ Test ]
@@ -57,66 +39,18 @@ public void TestAndroidApk([Values] bool stripEngineCode)
5739 Utility . BuildAndroid ( Apk , development , stripEngineCode , Feature , TargetAndroidArchitectures ) ;
5840 }
5941
60- string outputDir = Path . GetFileNameWithoutExtension ( Apk ) ;
61- Utility . Unzip ( Apk , outputDir ) ;
62-
63- int archCount = 0 ;
64-
65- foreach ( var kv in Utility . AndroidArchitectures )
66- {
67- var arch = kv . Key ;
68- var archName = kv . Value ;
69-
70- var path = Path . Combine ( outputDir , "lib" , archName , "libunity.so" ) ;
71- if ( File . Exists ( path ) )
72- {
73- var diffs = GetDiffs ( Feature , BuildTarget . Android , arch , development ) . ToArray ( ) ;
74-
75- var backupPath = Path . Combine ( AndroidBackupDir , archName , "libunity.so" ) ;
76- Utility . CompareFiles ( backupPath , path , diffs ) ;
77-
78- archCount ++ ;
79- }
80- }
81-
82- Assert . AreEqual ( 2 , archCount ) ;
42+ Utility . ValidateAndroid ( Apk , development , Feature , AndroidBackupDir , GetDiffs ) ;
8343 }
8444
8545 [ TestCase ( false ) ]
8646 public void TestIOS ( bool development )
8747 {
8848 Utility . BuildIOS ( XcodeProjectDir , development , Feature ) ;
8949
90- var path = Path . Combine ( XcodeProjectDir , "Libraries/libiPhone-lib.a" ) ;
91- var backupPath = path + ".bak" ;
92-
93- #if UNITY_2020_1_OR_NEWER
94- var diffsInUIDAndGID = Utility . GetDiffsInUIDAndGID ( backupPath , path ) ;
95- var diffs = GetDiffs ( Feature , BuildTarget . iOS , Architecture . ARM64 , development , diffsInUIDAndGID ) . ToArray ( ) ;
96-
97- Utility . CompareFiles ( backupPath , path , diffs ) ;
98- #else
99- var archs = new Architecture [ ] { Architecture . ARMv7 , Architecture . ARM64 } ;
100-
101- foreach ( var arch in archs )
102- {
103- var archStr = arch . ToString ( ) . ToLowerInvariant ( ) ;
104-
105- string file1 = $ "{ archStr } .a";
106- string file2 = $ "{ archStr } .a.bak";
107-
108- Utility . ExtractThinLibrary ( path , archStr , file1 ) ;
109- Utility . ExtractThinLibrary ( backupPath , archStr , file2 ) ;
110-
111- var diffsInUIDAndGID = Utility . GetDiffsInUIDAndGID ( file2 , file1 ) ;
112- var diffs = GetDiffs ( Feature , BuildTarget . iOS , arch , development , diffsInUIDAndGID ) . ToArray ( ) ;
113-
114- Utility . CompareFiles ( file2 , file1 , diffs ) ;
115- }
116- #endif
50+ Utility . ValidateIOS ( XcodeProjectDir , development , Feature , GetDiffs ) ;
11751 }
11852
119- private static ( int , int ) [ ] GetDiffs ( string feature , BuildTarget target , Architecture architecture , bool development , ( int , int ) [ ] diffsInUIDAndGID = null )
53+ private static ( int , int ) [ ] GetDiffs ( string feature , BuildTarget target , Architecture architecture , bool development )
12054 {
12155 var rule = Utility . GetCodeRewriteRule ( feature , target , architecture , development ) ;
12256 Assert . IsNotNull ( rule ) ;
@@ -127,23 +61,14 @@ private static (int, int)[] GetDiffs(string feature, BuildTarget target, Archite
12761 var diffs = new List < ( int , int ) > ( ) ;
12862
12963 if ( target == BuildTarget . iOS )
130- {
131- expectedCount = diffsInUIDAndGID . Length + repeat * ( diffsInUIDAndGID . Length + 24 ) ;
132-
133- diffs . AddRange ( diffsInUIDAndGID ) ;
134- }
64+ expectedCount = repeat * 24 ;
13565 else
136- {
13766 expectedCount = architecture == Architecture . ARMv7 ? 11 : 24 ;
138- }
13967
14068 Assert . AreEqual ( 1 , rule . Symbols . Length ) ;
14169
14270 while ( repeat -- > 0 )
14371 {
144- if ( target == BuildTarget . iOS )
145- diffs . AddRange ( diffsInUIDAndGID ) ;
146-
14772 foreach ( var symbol in rule . Symbols )
14873 {
14974 Assert . AreEqual ( 6 , symbol . Instructions . Length ) ;
@@ -163,6 +88,7 @@ private static (int, int)[] GetDiffs(string feature, BuildTarget target, Archite
16388 }
16489
16590 Assert . AreEqual ( expectedCount , diffs . Count ) ;
91+
16692 return diffs . ToArray ( ) ;
16793 }
16894}
0 commit comments