Files
cappuccino/Tests/AppKit/CPStepperTest.j
T
Alexandre Wilhelm 6fe9dae3d6 Fixed: AppKit unit-tests are not standalone
Previously, every AppKit tests used the same sharedApplication. Due to this implementation, a could not pass because a previous test made failed the current test. For instance, a test could fail because the window of the previous test resigned (just imagine a new window is the key window in the current test), and this resign could raise an error. The error was displayed for the current test thought this test was perfect !

We now instead of using sharedApplication create a new CPApplication per unit-test file in the class method setUp.
2015-07-07 14:12:19 -07:00

86 lines
1.7 KiB
Plaintext

@import <AppKit/CPStepper.j>
@import <AppKit/CPApplication.j>
@implementation CPStepperTest : OJTestCase
{
CPStepper stepper;
}
+ (void)setUp
{
// This will init the global var CPApp which are used internally in the AppKit
[[CPApplication alloc] init];
}
- (void)setUp
{
stepper = [CPStepper stepper];
[stepper setValueWraps:NO];
}
- (void)testCanCreate
{
[self assertTrue:!!stepper];
}
- (void)testPerformIncrease
{
[stepper performClickUp:nil];
[self assert:1 equals:[stepper doubleValue]];
}
- (void)testPerformDecrease
{
[stepper setDoubleValue:2];
[stepper performClickDown:nil];
[self assert:1 equals:[stepper doubleValue]];
}
- (void)testPerformClickUpIncreaseWithIncrement
{
[stepper setIncrement:10];
[stepper performClickUp:nil];
[self assert:10 equals:[stepper doubleValue]];
}
- (void)testPerformClickDownIncreaseWithIncrement
{
[stepper setIncrement:10];
[stepper performClickDown:nil];
[self assert:0 equals:[stepper doubleValue]];
}
- (void)testPerformMaxValue
{
[stepper setDoubleValue:59];
[stepper performClickUp:nil];
[stepper performClickUp:nil];
[stepper performClickUp:nil];
[self assert:59 equals:[stepper doubleValue]];
}
- (void)testPerformMinValue
{
[stepper setDoubleValue:-0];
[stepper performClickDown:nil];
[stepper performClickDown:nil];
[stepper performClickDown:nil];
[self assert:0 equals:[stepper doubleValue]];
}
- (void)setToBigValue
{
[stepper setDoubleValue:1000];
[self assert:100 equals:[stepper doubleValue]];
}
- (void)setToSmallValue
{
[stepper setDoubleValue:-1000];
[self assert:-100 equals:[stepper doubleValue]];
}
@end