|
1 | 1 | import components.* |
| 2 | +import models.StringEntity |
2 | 3 | import org.junit.Before |
3 | 4 | import org.junit.Test |
4 | 5 | import utils.modifyForTest |
@@ -162,7 +163,55 @@ class SCTest { |
162 | 163 | } |
163 | 164 |
|
164 | 165 | @Test |
165 | | - fun `11 - (ANDROID COMPILATION) obfuscate xml and build (not real workflow)`() { |
| 166 | + fun `11 - (PLUGIN) obfuscate, restore and compare xml values with originals`() { |
| 167 | + val temp = tempPath() |
| 168 | + signingReportTask(temp).runCommand { _, report -> |
| 169 | + val configuration = defaultConfig().apply { |
| 170 | + stringFiles.add("strings_extra.xml") |
| 171 | + srcFolders.add("src${File.separator}other_source") |
| 172 | + } |
| 173 | + val files = backupFiles("$temp${File.separator}$testProjectName", configuration) |
| 174 | + assert(files.isNotEmpty()) |
| 175 | + files.forEach { file -> |
| 176 | + val entities = parseXML(file.file) |
| 177 | + assert(entities.isNotEmpty()) |
| 178 | + modifyXML(file.file, "$temp${File.separator}$mainModuleTest", report.extractFingerprint(), true) |
| 179 | + } |
| 180 | + val filesObfuscated = locateFiles("$temp${File.separator}$testProjectName", configuration) |
| 181 | + filesObfuscated.forEach { file -> |
| 182 | + val entities = parseXML(file.file) |
| 183 | + assert(entities.isEmpty()) |
| 184 | + } |
| 185 | + |
| 186 | + val restoredFiles = restoreFiles("$temp${File.separator}$testProjectName", defaultMainModule) |
| 187 | + assert(restoredFiles.isNotEmpty()) |
| 188 | + |
| 189 | + val originalEntities = mutableListOf<StringEntity>() |
| 190 | + files.forEach { file -> |
| 191 | + originalEntities.addAll(parseXML(file.file)) |
| 192 | + } |
| 193 | + assert(originalEntities.isNotEmpty()) |
| 194 | + |
| 195 | + val restoredEntities = mutableListOf<StringEntity>() |
| 196 | + restoredFiles.forEach { file -> |
| 197 | + restoredEntities.addAll(parseXML(file)) |
| 198 | + } |
| 199 | + assert(restoredEntities.isNotEmpty()) |
| 200 | + |
| 201 | + originalEntities.forEach { entity -> |
| 202 | + val eq = restoredEntities.find { |
| 203 | + it.name == entity.name |
| 204 | + } |
| 205 | + eq?.let { |
| 206 | + assert(entity.name == it.name) |
| 207 | + assert(entity.value == it.value) |
| 208 | + } |
| 209 | + } |
| 210 | + } |
| 211 | + } |
| 212 | + |
| 213 | + @Test |
| 214 | + fun `12 - (ANDROID COMPILATION) obfuscate xml and build (not real workflow)`() { |
166 | 215 | val temp = tempPath() |
167 | 216 | signingReportTask(temp).runCommand { _, report -> |
168 | 217 | val files = locateFiles("$temp${File.separator}$testProjectName", defaultConfig().apply { |
@@ -194,14 +243,14 @@ class SCTest { |
194 | 243 | } |
195 | 244 |
|
196 | 245 | @Test |
197 | | - fun `12 - (PLUGIN COMPILATION) plugin with no test`() { |
| 246 | + fun `13 - (PLUGIN COMPILATION) plugin with no test`() { |
198 | 247 | pluginBuildTask().runCommand { _, report -> |
199 | 248 | assert(report.contains("BUILD SUCCESSFUL")) |
200 | 249 | } |
201 | 250 | } |
202 | 251 |
|
203 | 252 | @Test |
204 | | - fun `13 - (ANDROID COMPILATION) plugin running on Android`() { |
| 253 | + fun `14 - (ANDROID COMPILATION) plugin running on Android`() { |
205 | 254 | pluginBuildTask().runCommand { _, report -> |
206 | 255 | assert(report.contains("BUILD SUCCESSFUL")) |
207 | 256 | } |
|
0 commit comments