FBSessionTests.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 "FBSession.h"
  11. #import "FBConfiguration.h"
  12. #import "XCUIApplicationDouble.h"
  13. @interface FBSessionTests : XCTestCase
  14. @property (nonatomic, strong) FBSession *session;
  15. @property (nonatomic, strong) XCUIApplication *testedApplication;
  16. @property (nonatomic) BOOL shouldTerminateAppValue;
  17. @end
  18. @implementation FBSessionTests
  19. - (void)setUp
  20. {
  21. [super setUp];
  22. self.testedApplication = (id)XCUIApplicationDouble.new;
  23. self.shouldTerminateAppValue = FBConfiguration.shouldTerminateApp;
  24. [FBConfiguration setShouldTerminateApp:NO];
  25. self.session = [FBSession initWithApplication:self.testedApplication];
  26. }
  27. - (void)tearDown
  28. {
  29. [self.session kill];
  30. [FBConfiguration setShouldTerminateApp:self.shouldTerminateAppValue];
  31. [super tearDown];
  32. }
  33. - (void)testSessionFetching
  34. {
  35. FBSession *fetchedSession = [FBSession sessionWithIdentifier:self.session.identifier];
  36. XCTAssertEqual(self.session, fetchedSession);
  37. }
  38. - (void)testSessionFetchingBadIdentifier
  39. {
  40. XCTAssertNil([FBSession sessionWithIdentifier:@"FAKE_IDENTIFIER"]);
  41. }
  42. - (void)testSessionCreation
  43. {
  44. XCTAssertNotNil(self.session.identifier);
  45. XCTAssertNotNil(self.session.elementCache);
  46. }
  47. - (void)testActiveSession
  48. {
  49. XCTAssertEqual(self.session, [FBSession activeSession]);
  50. }
  51. - (void)testActiveSessionIsNilAfterKilling
  52. {
  53. [self.session kill];
  54. XCTAssertNil([FBSession activeSession]);
  55. }
  56. @end