PageRenderTime 200ms CodeModel.GetById 187ms app.highlight 10ms RepoModel.GetById 2ms app.codeStats 0ms

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