private NSArrayWrapper(Parcel in) { try { int size = in.readInt(); byte[] data = new byte[size]; in.readByteArray(data); array = (NSArray) BinaryPropertyListParser.parse(data); } catch (Exception e) { e.printStackTrace(); } }
public void assertFilesEqual(Path expected, Path actual) throws IOException { if (!expected.isAbsolute()) { expected = templatePath.resolve(expected); } if (!actual.isAbsolute()) { actual = destPath.resolve(actual); } if (!Files.isRegularFile(actual)) { fail("Expected file " + actual + " could not be found."); } String extension = MorePaths.getFileExtension(actual); String cleanPathToObservedFile = MoreStrings.withoutSuffix(templatePath.relativize(expected).toString(), EXPECTED_SUFFIX); switch (extension) { // For Apple .plist and .stringsdict files, we define equivalence if: // 1. The two files are the same type (XML or binary) // 2. If binary: unserialized objects are deeply-equivalent. // Otherwise, fall back to exact string match. case "plist": case "stringsdict": NSObject expectedObject; try { expectedObject = BinaryPropertyListParser.parse(expected.toFile()); } catch (Exception e) { // Not binary format. expectedObject = null; } NSObject observedObject; try { observedObject = BinaryPropertyListParser.parse(actual.toFile()); } catch (Exception e) { // Not binary format. observedObject = null; } assertTrue( String.format( "In %s, expected plist to be of %s type.", cleanPathToObservedFile, (expectedObject != null) ? "binary" : "XML"), (expectedObject != null) == (observedObject != null)); if (expectedObject != null) { // These keys depend on the locally installed version of Xcode, so ignore them // in comparisons. String[] ignoredKeys = { "DTSDKName", "DTPlatformName", "DTPlatformVersion", "MinimumOSVersion", "DTSDKBuild", "DTPlatformBuild", "DTXcode", "DTXcodeBuild" }; if (observedObject instanceof NSDictionary && expectedObject instanceof NSDictionary) { for (String key : ignoredKeys) { ((NSDictionary) observedObject).remove(key); ((NSDictionary) expectedObject).remove(key); } } assertEquals( String.format( "In %s, expected binary plist contents to match.", cleanPathToObservedFile), expectedObject, observedObject); break; } else { assertFileContentsEqual(expected, actual); } break; default: assertFileContentsEqual(expected, actual); } }