FBProtocolHelpersTests.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 "FBProtocolHelpers.h"
  11. @interface FBProtocolHelpersTests : XCTestCase
  12. @end
  13. @implementation FBProtocolHelpersTests
  14. - (void)testValidPrefixedCapsParsing
  15. {
  16. NSError *error = nil;
  17. NSDictionary<NSString *, id> *parsedCaps = FBParseCapabilities(@{
  18. @"firstMatch": @[@{
  19. @"appium:bundleId": @"com.example.id"
  20. }]
  21. }, &error);
  22. XCTAssertNil(error);
  23. XCTAssertEqualObjects(parsedCaps[@"bundleId"], @"com.example.id");
  24. }
  25. - (void)testValidPrefixedCapsMerging
  26. {
  27. NSError *error = nil;
  28. NSDictionary<NSString *, id> *parsedCaps = FBParseCapabilities(@{
  29. @"firstMatch": @[@{
  30. @"bundleId": @"com.example.id"
  31. }],
  32. @"alwaysMatch": @{
  33. @"google:cap": @"super"
  34. }
  35. }, &error);
  36. XCTAssertNil(error);
  37. XCTAssertEqualObjects(parsedCaps[@"bundleId"], @"com.example.id");
  38. XCTAssertEqualObjects(parsedCaps[@"google:cap"], @"super");
  39. }
  40. - (void)testEmptyCaps
  41. {
  42. NSError *error = nil;
  43. NSDictionary<NSString *, id> *parsedCaps = FBParseCapabilities(@{}, &error);
  44. XCTAssertNil(error);
  45. XCTAssertEqual(parsedCaps.count, 0);
  46. }
  47. - (void)testCapsMergingFailure
  48. {
  49. NSError *error = nil;
  50. NSDictionary<NSString *, id> *parsedCaps = FBParseCapabilities(@{
  51. @"firstMatch": @[@{
  52. @"appium:bundleId": @"com.example.id"
  53. }],
  54. @"alwaysMatch": @{
  55. @"bundleId": @"other"
  56. }
  57. }, &error);
  58. XCTAssertNil(parsedCaps);
  59. XCTAssertNotNil(error);
  60. }
  61. - (void)testPrefixingStandardCapability
  62. {
  63. NSError *error = nil;
  64. NSDictionary<NSString *, id> *parsedCaps = FBParseCapabilities(@{
  65. @"firstMatch": @[@{
  66. @"appium:platformName": @"com.example.id"
  67. }]
  68. }, &error);
  69. XCTAssertNil(parsedCaps);
  70. XCTAssertNotNil(error);
  71. }
  72. @end