FBVideoRecordingTests.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import <XCTest/XCTest.h>
  10. #import "FBIntegrationTestCase.h"
  11. #import "FBConfiguration.h"
  12. #import "FBMacros.h"
  13. #import "FBScreenRecordingPromise.h"
  14. #import "FBScreenRecordingRequest.h"
  15. #import "FBScreenRecordingContainer.h"
  16. #import "FBXCTestDaemonsProxy.h"
  17. @interface FBVideoRecordingTests : FBIntegrationTestCase
  18. @end
  19. @implementation FBVideoRecordingTests
  20. - (void)setUp
  21. {
  22. [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"DisableDiagnosticScreenRecordings"];
  23. [super setUp];
  24. }
  25. - (void)testStartingAndStoppingVideoRecording
  26. {
  27. // Video recording is only available since iOS 17
  28. if (SYSTEM_VERSION_LESS_THAN(@"17.0")) {
  29. return;
  30. }
  31. FBScreenRecordingRequest *recordingRequest = [[FBScreenRecordingRequest alloc] initWithFps:24
  32. codec:0];
  33. NSError *error;
  34. FBScreenRecordingPromise *promise = [FBXCTestDaemonsProxy startScreenRecordingWithRequest:recordingRequest
  35. error:&error];
  36. XCTAssertNotNil(promise);
  37. XCTAssertNotNil(promise.identifier);
  38. XCTAssertNil(error);
  39. [FBScreenRecordingContainer.sharedInstance storeScreenRecordingPromise:promise
  40. fps:24
  41. codec:0];
  42. XCTAssertEqual(FBScreenRecordingContainer.sharedInstance.screenRecordingPromise, promise);
  43. [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.]];
  44. BOOL isSuccessfull = [FBXCTestDaemonsProxy stopScreenRecordingWithUUID:promise.identifier error:&error];
  45. XCTAssertTrue(isSuccessfull);
  46. XCTAssertNil(error);
  47. [FBScreenRecordingContainer.sharedInstance reset];
  48. XCTAssertNil(FBScreenRecordingContainer.sharedInstance.screenRecordingPromise);
  49. }
  50. @end