FBPickerWheelSelectTests.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "XCUIElement+FBPickerWheel.h"
  12. #import "XCUIElement+FBWebDriverAttributes.h"
  13. #import "FBXCodeCompatibility.h"
  14. @interface FBPickerWheelSelectTests : FBIntegrationTestCase
  15. @end
  16. @implementation FBPickerWheelSelectTests
  17. static const CGFloat DEFAULT_OFFSET = (CGFloat)0.2;
  18. - (void)setUp
  19. {
  20. [super setUp];
  21. static dispatch_once_t onceToken;
  22. dispatch_once(&onceToken, ^{
  23. [self launchApplication];
  24. [self goToAttributesPage];
  25. });
  26. }
  27. - (void)testSelectNextPickerValue
  28. {
  29. XCUIElement *element = self.testedApplication.pickerWheels.allElementsBoundByIndex.firstObject;
  30. XCTAssertTrue(element.exists);
  31. XCTAssertEqualObjects(element.wdType, @"XCUIElementTypePickerWheel");
  32. NSError *error;
  33. NSString *previousValue = element.wdValue;
  34. XCTAssertTrue([element fb_selectNextOptionWithOffset:DEFAULT_OFFSET error:&error]);
  35. XCTAssertNotEqualObjects(previousValue, element.wdValue);
  36. }
  37. - (void)testSelectPreviousPickerValue
  38. {
  39. XCUIElement *element = [self.testedApplication.pickerWheels elementBoundByIndex:1];
  40. XCTAssertTrue(element.exists);
  41. XCTAssertEqualObjects(element.wdType, @"XCUIElementTypePickerWheel");
  42. NSError *error;
  43. NSString *previousValue = element.wdValue;
  44. XCTAssertTrue([element fb_selectPreviousOptionWithOffset:DEFAULT_OFFSET error:&error]);
  45. XCTAssertNotEqualObjects(previousValue, element.wdValue);
  46. }
  47. @end