/core/externals/update-engine/Common/KSActionTest.m

http://macfuse.googlecode.com/ · Objective C · 65 lines · 27 code · 11 blank · 27 comment · 1 complexity · 85ac805a6828e8af5ab18cea63639209 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 "KSAction.h"
  16. #import "KSActionProcessor.h"
  17. #import "KSActionPipe.h"
  18. @interface KSActionTest : SenTestCase
  19. @end
  20. // Notes about this unit test
  21. // --------------------------
  22. // KSAction is an abstract class, and there's currently nothing to isolate and
  23. // test in this unit test. So, here we'll just test that we can instantiate it
  24. // (yes, I know we're instantiating an "abstract" class, but at least it ensures
  25. // that everything compiles and all the machinery works up to that point) and
  26. // verify that we get a non-nil instance. If more functionality is added to the
  27. // KSAction class in the future, the unit test is already setup for it.
  28. //
  29. // Also note that we *can* test how concrete KSAction instances interact with
  30. // the KSActionProcessor, and we do that in the KSActionProcessorTest file.
  31. @implementation KSActionTest
  32. - (void)testBasic {
  33. KSAction *action = [[[KSAction alloc] init] autorelease];
  34. STAssertNotNil(action, nil);
  35. STAssertTrue([action isRunning] == NO, nil);
  36. STAssertNil([action processor], nil);
  37. [action setProcessor:[[[KSActionProcessor alloc] init] autorelease]];
  38. STAssertNotNil([action processor], nil);
  39. // The in/out pipes should never be nil.
  40. STAssertNotNil([action inPipe], nil);
  41. STAssertNotNil([action outPipe], nil);
  42. [action setInPipe:[KSActionPipe pipe]];
  43. [action setOutPipe:[KSActionPipe pipe]];
  44. STAssertNotNil([action inPipe], nil);
  45. STAssertNotNil([action outPipe], nil);
  46. [action setInPipe:nil];
  47. [action setOutPipe:nil];
  48. STAssertNotNil([action inPipe], nil);
  49. STAssertNotNil([action outPipe], nil);
  50. [action terminateAction];
  51. // Since KSAction itself is an "abstract" class, calling performAction:
  52. // on it would _GTMDevAssert and abort the test.
  53. }
  54. @end