Unity_iPhone_Tests.m 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. {
  22. [unityApp repaint];
  23. [[NSRunLoop mainRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.001f]];
  24. }
  25. #endif
  26. [self waitForExpectationsWithTimeout: 1000000 handler: nil];
  27. }
  28. @end