FIRAppDistributionMachOTests.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2020 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. #import <XCTest/XCTest.h>
  16. #import <FirebaseCore/FIRAppInternal.h>
  17. #import "FIRAppDistributionMachO+Private.h"
  18. @interface FIRAppDistributionMachOTests : XCTestCase
  19. @end
  20. @implementation FIRAppDistributionMachOTests
  21. - (NSString*)resourcePath:(NSString*)path {
  22. NSBundle* bundle = [NSBundle bundleForClass:[self class]];
  23. NSString* resourcePath = [bundle resourcePath];
  24. return [resourcePath stringByAppendingPathComponent:path];
  25. }
  26. - (void)testCodeHashForSingleArchIntelSimulator {
  27. FIRAppDistributionMachO* macho;
  28. macho = [[FIRAppDistributionMachO alloc] initWithPath:[self resourcePath:@"x86_64-executable"]];
  29. XCTAssertEqualObjects([macho codeHash], @"442eb836efe1f56bf8a65b2a0a78b2f8d3e792e7");
  30. }
  31. - (void)testCodeHashForMultipleArch {
  32. FIRAppDistributionMachO* macho;
  33. macho =
  34. [[FIRAppDistributionMachO alloc] initWithPath:[self resourcePath:@"armv7-armv7s-executable"]];
  35. XCTAssertEqualObjects([macho codeHash], @"80cc0ec0af8a0169831abcc73177eb2b57990bc0");
  36. }
  37. - (void)testCodeHashForNonExistentBinary {
  38. FIRAppDistributionMachO* macho;
  39. macho = [[FIRAppDistributionMachO alloc] initWithPath:[self resourcePath:@"missing-file"]];
  40. XCTAssertEqualObjects([macho codeHash], @"da39a3ee5e6b4b0d3255bfef95601890afd80709");
  41. }
  42. @end