/core/externals/update-engine/Core/KSUpdateInfoTest.m

http://macfuse.googlecode.com/ · Objective C · 77 lines · 52 code · 11 blank · 14 comment · 0 complexity · c00532d049b2d1f4cea6f534d2e71db0 MD5 · raw file

  1. // Copyright 2008 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <SenTestingKit/SenTestingKit.h>
  15. #import "KSUpdateInfo.h"
  16. #import "KSExistenceChecker.h"
  17. #import "KSTicket.h"
  18. @interface KSUpdateInfoTest : SenTestCase
  19. @end
  20. @implementation KSUpdateInfoTest
  21. - (void)testAccessors {
  22. KSUpdateInfo *update = [[[KSUpdateInfo alloc] init] autorelease];
  23. STAssertNotNil(update, nil);
  24. STAssertNil([update productID], nil);
  25. STAssertNil([update codebaseURL], nil);
  26. STAssertNil([update codeSize], nil);
  27. STAssertNil([update codeHash], nil);
  28. STAssertNil([update moreInfoURLString], nil);
  29. STAssertNil([update promptUser], nil);
  30. STAssertNil([update requireReboot], nil);
  31. STAssertNil([update localizationBundle], nil);
  32. STAssertNil([update displayVersion], nil);
  33. STAssertNil([update version], nil);
  34. STAssertNil([update ticket], nil);
  35. KSTicket *ticket =
  36. [KSTicket ticketWithProductID:@"com.google.glockenspiel"
  37. version:@"17"
  38. existenceChecker:[KSExistenceChecker trueChecker]
  39. serverURL:[[[NSURL alloc] init] autorelease]];
  40. // Now, make sure these return non-nil values for a real dictionary.
  41. update = [NSDictionary dictionaryWithObjectsAndKeys:
  42. @"foo", kServerProductID,
  43. [NSURL URLWithString:@"a://a"], kServerCodebaseURL,
  44. [NSNumber numberWithInt:2], kServerCodeSize,
  45. @"zzz", kServerCodeHash,
  46. @"a://b", kServerMoreInfoURLString,
  47. [NSNumber numberWithBool:YES], kServerPromptUser,
  48. [NSNumber numberWithBool:YES], kServerRequireReboot,
  49. @"/Hassel/Hoff", kServerLocalizationBundle,
  50. @"1.3.2 (with pudding)", kServerDisplayVersion,
  51. @"1.3.2", kServerVersion,
  52. ticket, kTicket,
  53. nil];
  54. STAssertEqualObjects(@"foo", [update productID], nil);
  55. STAssertEqualObjects([NSURL URLWithString:@"a://a"], [update codebaseURL], nil);
  56. STAssertEqualObjects([NSNumber numberWithInt:2], [update codeSize], nil);
  57. STAssertEqualObjects(@"zzz", [update codeHash], nil);
  58. STAssertEqualObjects(@"a://b", [update moreInfoURLString], nil);
  59. STAssertEqualObjects([NSNumber numberWithBool:YES], [update promptUser], nil);
  60. STAssertEqualObjects([NSNumber numberWithBool:YES], [update requireReboot], nil);
  61. STAssertEqualObjects(@"/Hassel/Hoff", [update localizationBundle], nil);
  62. STAssertEqualObjects(@"1.3.2 (with pudding)", [update displayVersion], nil);
  63. STAssertEqualObjects(@"1.3.2", [update version], nil);
  64. STAssertEqualObjects(ticket, [update ticket], nil);
  65. }
  66. @end