Unity_iPhone_Tests.m 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #import "Preprocessor.h"
  2. #import <XCTest/XCTest.h>
  3. #import "UnityAppController+Rendering.h"
  4. @interface UnityTest : XCTestCase
  5. @end
  6. @implementation UnityTest
  7. - (void)testRunUnity
  8. {
  9. XCTestExpectation *expectation = [self expectationWithDescription: @"testRunUnity"];
  10. __block bool running = true;
  11. id<UIApplicationDelegate> delegate = [(UIApplication*)[UIApplication sharedApplication] delegate];
  12. [delegate performSelector: @selector(setQuitHandler:) withObject:^{
  13. [expectation fulfill];
  14. running = false;
  15. }];
  16. // When Apple TV device doesn't have attached monitor or TV it doesn't run display link. So we force
  17. // player loop here.
  18. #ifdef PLATFORM_TVOS
  19. UnityAppController* unityApp = [(UIApplication*)[UIApplication sharedApplication] delegate];
  20. while (running){
  21. [unityApp repaint];
  22. [[NSRunLoop mainRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.001f]];
  23. }
  24. #endif
  25. [self waitForExpectationsWithTimeout: 1000000 handler: nil];
  26. }
  27. @end