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

http://macfuse.googlecode.com/ · Objective C · 77 lines · 49 code · 15 blank · 13 comment · 0 complexity · 10f910f14e529f9834bd6e30c77a8c66 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 "KSServer.h"
  16. @interface KSServerTest : SenTestCase
  17. @end
  18. @implementation KSServerTest
  19. - (void)testCreation {
  20. KSServer *s = [[KSServer alloc] initWithURL:nil];
  21. STAssertNil(s, nil);
  22. s = [[KSServer alloc] init];
  23. STAssertNil(s, nil);
  24. s = [[KSServer alloc] initWithURL:[NSURL URLWithString:@"http://foo"]];
  25. STAssertNotNil(s, nil);
  26. STAssertEqualObjects([s url], [NSURL URLWithString:@"http://foo"], nil);
  27. STAssertNil([s params], nil);
  28. [s release];
  29. NSURL *url = [NSURL URLWithString:@"http://www.foo.com:8000/file.txt"];
  30. STAssertNotNil(url, nil);
  31. s = [[KSServer alloc] initWithURL:url];
  32. STAssertNotNil(s, nil);
  33. STAssertEqualObjects([s url], url, nil);
  34. STAssertNil([s params], nil);
  35. STAssertTrue([[s description] length] > 1, nil);
  36. [s release];
  37. NSDictionary *params = [NSDictionary dictionaryWithObject:@"a" forKey:@"b"];
  38. s = [[KSServer alloc] initWithURL:url params:params];
  39. STAssertNotNil(s, nil);
  40. STAssertEqualObjects([s url], url, nil);
  41. STAssertNotNil([s params], nil);
  42. STAssertEqualObjects([s params], params, nil);
  43. STAssertTrue([[s description] length] > 1, nil);
  44. [s release];
  45. }
  46. - (void)testAbstractMethods {
  47. NSURL *url = [NSURL URLWithString:@"http://www.foo.com:8000/file.txt"];
  48. STAssertNotNil(url, nil);
  49. KSServer *s = [[[KSServer alloc] initWithURL:url] autorelease];
  50. STAssertNotNil(s, nil);
  51. STAssertNil([s requestsForTickets:nil], nil);
  52. STAssertNil([s requestsForTickets:[NSMutableArray arrayWithCapacity:1]], nil);
  53. NSData *data = [NSData dataWithBytes:(void *)"hi mom" length:6];
  54. STAssertNil([s updateInfosForResponse:nil data:data outOfBandData:NULL], nil);
  55. STAssertNil([s updateInfosForResponse:nil data:nil outOfBandData:NULL], nil);
  56. STAssertNil([s updateInfosForResponse:nil data:data outOfBandData:NULL], nil);
  57. STAssertNil([s updateInfosForResponse:nil data:nil outOfBandData:NULL], nil);
  58. NSDictionary *oob;
  59. STAssertNil([s updateInfosForResponse:nil data:nil outOfBandData:&oob], nil);
  60. STAssertNil(oob, nil);
  61. }
  62. @end