FIRAppEnvironmentUtilTest.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2018 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/FIRAppEnvironmentUtil.h>
  17. #import "FIRTestCase.h"
  18. @interface FIRAppEnvironmentUtilTest : FIRTestCase
  19. @property(nonatomic) id processInfoMock;
  20. @end
  21. @implementation FIRAppEnvironmentUtilTest
  22. - (void)setUp {
  23. [super setUp];
  24. _processInfoMock = OCMPartialMock([NSProcessInfo processInfo]);
  25. }
  26. - (void)tearDown {
  27. [super tearDown];
  28. [_processInfoMock stopMocking];
  29. }
  30. - (void)testSystemVersionInfoMajorOnly {
  31. NSOperatingSystemVersion osTen = {.majorVersion = 10, .minorVersion = 0, .patchVersion = 0};
  32. OCMStub([self.processInfoMock operatingSystemVersion]).andReturn(osTen);
  33. XCTAssertTrue([[FIRAppEnvironmentUtil systemVersion] isEqualToString:@"10.0"]);
  34. }
  35. - (void)testSystemVersionInfoMajorMinor {
  36. NSOperatingSystemVersion osTenTwo = {.majorVersion = 10, .minorVersion = 2, .patchVersion = 0};
  37. OCMStub([self.processInfoMock operatingSystemVersion]).andReturn(osTenTwo);
  38. XCTAssertTrue([[FIRAppEnvironmentUtil systemVersion] isEqualToString:@"10.2"]);
  39. }
  40. - (void)testSystemVersionInfoMajorMinorPatch {
  41. NSOperatingSystemVersion osTenTwoOne = {.majorVersion = 10, .minorVersion = 2, .patchVersion = 1};
  42. OCMStub([self.processInfoMock operatingSystemVersion]).andReturn(osTenTwoOne);
  43. XCTAssertTrue([[FIRAppEnvironmentUtil systemVersion] isEqualToString:@"10.2.1"]);
  44. }
  45. @end