From 6fe9dae3d62af995f2481bfebdd706aeb0b21365 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Tue, 7 Jul 2015 14:12:19 -0700 Subject: [PATCH] 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. --- Tests/AppKit/CPAnimationTest.j | 14 +++++++++----- Tests/AppKit/CPApplicationTest.j | 6 ++++++ Tests/AppKit/CPArrayControllerPerformance.j | 9 +++++++++ Tests/AppKit/CPArrayControllerTest.j | 6 ++++++ Tests/AppKit/CPAutosizePerformance.j | 9 ++++++--- Tests/AppKit/CPBrowserTest.j | 7 ++++++- Tests/AppKit/CPButtonTest.j | 9 ++++++--- Tests/AppKit/CPCheckBoxTest.j | 8 ++++++-- Tests/AppKit/CPCollectionViewTest.j | 6 ++++++ Tests/AppKit/CPColorTest.j | 6 ++++++ Tests/AppKit/CPColorWellTest.j | 8 ++++++-- Tests/AppKit/CPComboBoxTest.j | 8 ++++++-- Tests/AppKit/CPDOMDisplayServerTest.j | 6 ++++++ Tests/AppKit/CPDatePickerTest.j | 7 ++++++- Tests/AppKit/CPEventTest.j | 6 +++--- Tests/AppKit/CPFontManagerTest.j | 8 ++++++-- Tests/AppKit/CPFontTest.j | 6 ++++++ Tests/AppKit/CPImageTest.j | 6 ++++++ Tests/AppKit/CPKeyEquivalentPerformance.j | 11 +++++++++-- Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j | 9 ++++++--- Tests/AppKit/CPKeyValueBindingTest.j | 6 ++++++ Tests/AppKit/CPLevelIndicatorTest.j | 14 ++++++++++---- Tests/AppKit/CPMenuTest.j | 8 ++++++-- .../AppKit/CPMenuValidatedUserInterfaceItemTest.j | 6 ++++++ Tests/AppKit/CPOutlineViewTest.j | 7 ++++++- Tests/AppKit/CPPasteboardTest.j | 6 ++++++ Tests/AppKit/CPPopUpButtonTest.j | 6 ++++++ Tests/AppKit/CPPredicateEditorTest.j | 6 ++++++ Tests/AppKit/CPResponderTest.j | 8 ++++++-- Tests/AppKit/CPScrollViewTest.j | 7 ++++++- Tests/AppKit/CPSearchFieldTest.j | 6 ++++++ Tests/AppKit/CPSegmentedControlTest.j | 6 ++++++ Tests/AppKit/CPSliderTest.j | 6 ++++++ Tests/AppKit/CPSplitViewTest.j | 9 ++++++--- Tests/AppKit/CPStepperTest.j | 8 ++++++-- Tests/AppKit/CPTabViewTest.j | 8 ++++++-- Tests/AppKit/CPTableViewReloadDataTest.j | 8 ++++++-- Tests/AppKit/CPTableViewTableColumnTest.j | 8 ++++++-- Tests/AppKit/CPTableViewTest.j | 8 ++++++-- Tests/AppKit/CPTextFieldTest.j | 7 ++++++- Tests/AppKit/CPThemeTest.j | 6 ++++++ Tests/AppKit/CPTokenFieldTest.j | 8 ++++++-- Tests/AppKit/CPTreeNodeTest.j | 8 ++++++-- Tests/AppKit/CPViewTest.j | 9 ++++++--- Tests/AppKit/CPWindowTest.j | 9 ++++++--- .../01_WithoutBindings/WithoutBindingsTest.j | 6 +++--- .../02_WithBindings/WithBindingsTest.j | 6 +++--- 47 files changed, 286 insertions(+), 69 deletions(-) diff --git a/Tests/AppKit/CPAnimationTest.j b/Tests/AppKit/CPAnimationTest.j index d151d82bc..ef40b7859 100644 --- a/Tests/AppKit/CPAnimationTest.j +++ b/Tests/AppKit/CPAnimationTest.j @@ -1,8 +1,6 @@ @import @import -[CPApplication sharedApplication]; - @implementation CPAnimation (TestMethods) { } @@ -18,11 +16,17 @@ { } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)testScheduleTimerWithIntervalBasedOnDefaultFrameRate { var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear]; [animation startAnimation]; - + [self assert:1.0/60.0 equals:[[animation timer] timeInterval]]; } @@ -31,7 +35,7 @@ var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear]; [animation setFrameRate:30]; [animation startAnimation]; - + [self assert:1.0/30.0 equals:[[animation timer] timeInterval]]; } @@ -40,7 +44,7 @@ var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear]; [animation setFrameRate:0]; [animation startAnimation]; - + [self assert:0.0001 equals:[[animation timer] timeInterval]]; } diff --git a/Tests/AppKit/CPApplicationTest.j b/Tests/AppKit/CPApplicationTest.j index 0b7114f01..8e1944902 100644 --- a/Tests/AppKit/CPApplicationTest.j +++ b/Tests/AppKit/CPApplicationTest.j @@ -61,6 +61,12 @@ var globalResults = []; CPWindow aWindow; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { // This sets up the CPApp convenience variable, the unit tests fails diff --git a/Tests/AppKit/CPArrayControllerPerformance.j b/Tests/AppKit/CPArrayControllerPerformance.j index 98137b1ee..ad4dac44b 100644 --- a/Tests/AppKit/CPArrayControllerPerformance.j +++ b/Tests/AppKit/CPArrayControllerPerformance.j @@ -6,6 +6,15 @@ var ELEMENTS = 200, REPEATS = 25; @implementation CPArrayControllerPerformance : OJTestCase +{ + +} + ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} - (CPArrayController)setupWithElements:(int)aCount { diff --git a/Tests/AppKit/CPArrayControllerTest.j b/Tests/AppKit/CPArrayControllerTest.j index 35b8e3388..bb70aef60 100644 --- a/Tests/AppKit/CPArrayControllerTest.j +++ b/Tests/AppKit/CPArrayControllerTest.j @@ -18,6 +18,12 @@ CPArray depValues @accessors; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (CPArray)makeTestArray { return [[Employee employeeWithName:@"Francisco" department:[Department departmentWithName:@"Cappuccino"]], diff --git a/Tests/AppKit/CPAutosizePerformance.j b/Tests/AppKit/CPAutosizePerformance.j index 443d8135d..b9b75daa3 100644 --- a/Tests/AppKit/CPAutosizePerformance.j +++ b/Tests/AppKit/CPAutosizePerformance.j @@ -1,15 +1,18 @@ @import @import -[CPApplication sharedApplication]; - - @implementation CPAutosizePerformance : OJTestCase { CPInteger NUMBER_OF_VIEWS; CPInteger RESIZES_COUNT; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { NUMBER_OF_VIEWS = 50; diff --git a/Tests/AppKit/CPBrowserTest.j b/Tests/AppKit/CPBrowserTest.j index bc29049bb..93d8f5c84 100644 --- a/Tests/AppKit/CPBrowserTest.j +++ b/Tests/AppKit/CPBrowserTest.j @@ -2,13 +2,18 @@ @class CPBrowserDelegate - @implementation CPBrowserTest : OJTestCase { CPBrowser browser; CPBrowserDelegate delegate; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { browser = [[CPBrowser alloc] initWithFrame:CGRectMake(0, 0, 500, 300)]; diff --git a/Tests/AppKit/CPButtonTest.j b/Tests/AppKit/CPButtonTest.j index 38f8a4286..00ba2dd1b 100644 --- a/Tests/AppKit/CPButtonTest.j +++ b/Tests/AppKit/CPButtonTest.j @@ -1,16 +1,19 @@ - @import @import @import -[CPApplication sharedApplication]; - @implementation CPButtonTest : OJTestCase { CPButton button; BOOL wasClicked; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { button = [CPButton buttonWithTitle:"hello world"]; diff --git a/Tests/AppKit/CPCheckBoxTest.j b/Tests/AppKit/CPCheckBoxTest.j index 528c7bd30..6dc5d4bd5 100644 --- a/Tests/AppKit/CPCheckBoxTest.j +++ b/Tests/AppKit/CPCheckBoxTest.j @@ -1,11 +1,15 @@ @import -[CPApplication sharedApplication] - @implementation CPCheckBoxTest : OJTestCase { } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + /*! Verify that CPCheckBox placeholders work, both explicit and default ones. */ diff --git a/Tests/AppKit/CPCollectionViewTest.j b/Tests/AppKit/CPCollectionViewTest.j index 5000e1a84..c8d69aa6a 100644 --- a/Tests/AppKit/CPCollectionViewTest.j +++ b/Tests/AppKit/CPCollectionViewTest.j @@ -7,6 +7,12 @@ id _globalResults; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { _collectionView = [[CPCollectionView alloc] initWithFrame:CGRectMakeZero()]; diff --git a/Tests/AppKit/CPColorTest.j b/Tests/AppKit/CPColorTest.j index b357a6805..a63f89aac 100644 --- a/Tests/AppKit/CPColorTest.j +++ b/Tests/AppKit/CPColorTest.j @@ -4,6 +4,12 @@ { } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)testHexStringConversion { var colors = ['000000', '0099CC', '7E8EAB', 'FFFFFF']; diff --git a/Tests/AppKit/CPColorWellTest.j b/Tests/AppKit/CPColorWellTest.j index 2e57ee0b9..ddaf11921 100644 --- a/Tests/AppKit/CPColorWellTest.j +++ b/Tests/AppKit/CPColorWellTest.j @@ -1,13 +1,17 @@ @import @import -[CPApplication sharedApplication]; - @implementation CPColorWellTest : OJTestCase { CPColorWell colorWell; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { colorWell = [[CPColorWell alloc] initWithFrame:CGRectMakeZero()]; diff --git a/Tests/AppKit/CPComboBoxTest.j b/Tests/AppKit/CPComboBoxTest.j index 3d12ed91c..875e2cf90 100644 --- a/Tests/AppKit/CPComboBoxTest.j +++ b/Tests/AppKit/CPComboBoxTest.j @@ -4,14 +4,18 @@ @import "CPNotificationCenterHelper.j" -[CPApplication sharedApplication]; - @implementation CPComboBoxTest : OJTestCase { CPComboBox comboBox; BOOL wasClicked } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { comboBox = [[CPComboBox alloc] initWithFrame:CGRectMake(0, 0, 200, 30)]; diff --git a/Tests/AppKit/CPDOMDisplayServerTest.j b/Tests/AppKit/CPDOMDisplayServerTest.j index caf7f3aee..147d240e7 100644 --- a/Tests/AppKit/CPDOMDisplayServerTest.j +++ b/Tests/AppKit/CPDOMDisplayServerTest.j @@ -8,6 +8,12 @@ BOOL aTransform; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { // set up a dummy DOM element. diff --git a/Tests/AppKit/CPDatePickerTest.j b/Tests/AppKit/CPDatePickerTest.j index 6b0779d92..79af6033e 100644 --- a/Tests/AppKit/CPDatePickerTest.j +++ b/Tests/AppKit/CPDatePickerTest.j @@ -4,13 +4,18 @@ @import @import -[CPApplication sharedApplication]; @implementation CPDatePickerTest : OJTestCase { CPDatePicker datePicker; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { datePicker = [[CPDatePicker alloc] initWithFrame:CGRectMake(200, 28, 0, 0)]; diff --git a/Tests/AppKit/CPEventTest.j b/Tests/AppKit/CPEventTest.j index 176be1648..46706d1ab 100644 --- a/Tests/AppKit/CPEventTest.j +++ b/Tests/AppKit/CPEventTest.j @@ -5,10 +5,10 @@ { } -- (void)setUp ++ (void)setUp { - // CPApplication must be initialised for some event handling to work. - [CPApplication sharedApplication]; + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; } /*! diff --git a/Tests/AppKit/CPFontManagerTest.j b/Tests/AppKit/CPFontManagerTest.j index 04e817701..c6cbdc5e7 100644 --- a/Tests/AppKit/CPFontManagerTest.j +++ b/Tests/AppKit/CPFontManagerTest.j @@ -1,7 +1,5 @@ @import -[CPApplication sharedApplication]; - @implementation CPFontManagerTest : OJTestCase { CPFont fontA; @@ -12,6 +10,12 @@ int tag @accessors; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { fontA = [CPFont systemFontOfSize:8.0]; diff --git a/Tests/AppKit/CPFontTest.j b/Tests/AppKit/CPFontTest.j index 77a51ff09..70d3fd9fc 100644 --- a/Tests/AppKit/CPFontTest.j +++ b/Tests/AppKit/CPFontTest.j @@ -9,6 +9,12 @@ CPFont _boldCustomFont; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { _systemFont = [CPFont systemFontOfSize:15]; diff --git a/Tests/AppKit/CPImageTest.j b/Tests/AppKit/CPImageTest.j index 2e808a78c..c639c712f 100644 --- a/Tests/AppKit/CPImageTest.j +++ b/Tests/AppKit/CPImageTest.j @@ -4,6 +4,12 @@ { } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)testInitWithContentsOfFile_nil { var image = [[CPImage alloc] initWithContentsOfFile:nil]; diff --git a/Tests/AppKit/CPKeyEquivalentPerformance.j b/Tests/AppKit/CPKeyEquivalentPerformance.j index 84ea9e7b1..bc1a5ebf2 100644 --- a/Tests/AppKit/CPKeyEquivalentPerformance.j +++ b/Tests/AppKit/CPKeyEquivalentPerformance.j @@ -3,9 +3,16 @@ @import @import -[CPApplication sharedApplication]; - @implementation CPKeyEquivalentPerformance : OJTestCase +{ + +} + ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} - (void)testKeyEquivalentSpeed { diff --git a/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j b/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j index d1bb9af84..d5f6010e2 100644 --- a/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j +++ b/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j @@ -18,11 +18,14 @@ CPObjectController objectController @accessors; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { - // CPApp must be initialised or action sending will not work. - [CPApplication sharedApplication]; - track = [Track new]; [track setVolume:5.0]; } diff --git a/Tests/AppKit/CPKeyValueBindingTest.j b/Tests/AppKit/CPKeyValueBindingTest.j index 8412e18a9..97de7ee33 100644 --- a/Tests/AppKit/CPKeyValueBindingTest.j +++ b/Tests/AppKit/CPKeyValueBindingTest.j @@ -21,6 +21,12 @@ CPArrayController arrayController @accessors; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)testExposingBindings { [BindingTester exposeBinding:@"foo"]; diff --git a/Tests/AppKit/CPLevelIndicatorTest.j b/Tests/AppKit/CPLevelIndicatorTest.j index 7047c8dea..e6d200286 100644 --- a/Tests/AppKit/CPLevelIndicatorTest.j +++ b/Tests/AppKit/CPLevelIndicatorTest.j @@ -7,6 +7,12 @@ { } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + + (CPLevelIndicator)indicatorWithLowWarning { var levelIndicator = [[CPLevelIndicator alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; @@ -44,7 +50,7 @@ [levelIndicator setObjectValue:4]; [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; - + [self assert:[CPColor yellowColor] equals:[GET_LEVEL_INDICATOR_SEGMENT(levelIndicator, 0) backgroundColor]]; } @@ -54,7 +60,7 @@ [levelIndicator setObjectValue:2]; [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; - + [self assert:[CPColor redColor] equals:[GET_LEVEL_INDICATOR_SEGMENT(levelIndicator, 0) backgroundColor]]; } @@ -74,7 +80,7 @@ [levelIndicator setObjectValue:6]; [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; - + [self assert:[CPColor yellowColor] equals:[GET_LEVEL_INDICATOR_SEGMENT(levelIndicator, 0) backgroundColor]]; } @@ -84,7 +90,7 @@ [levelIndicator setObjectValue:8]; [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; - + [self assert:[CPColor redColor] equals:[GET_LEVEL_INDICATOR_SEGMENT(levelIndicator, 0) backgroundColor]]; } @end diff --git a/Tests/AppKit/CPMenuTest.j b/Tests/AppKit/CPMenuTest.j index 44a16e0dd..3e377ae20 100644 --- a/Tests/AppKit/CPMenuTest.j +++ b/Tests/AppKit/CPMenuTest.j @@ -1,10 +1,8 @@ - @import @import @import @import -[CPApplication sharedApplication] @implementation CPMenuTest : OJTestCase { @@ -19,6 +17,12 @@ CPMenuItem anInstantiatedMenuItem; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { // Set up a fairly complete menu to have something to work with. diff --git a/Tests/AppKit/CPMenuValidatedUserInterfaceItemTest.j b/Tests/AppKit/CPMenuValidatedUserInterfaceItemTest.j index 5757c368d..0d7716211 100644 --- a/Tests/AppKit/CPMenuValidatedUserInterfaceItemTest.j +++ b/Tests/AppKit/CPMenuValidatedUserInterfaceItemTest.j @@ -9,6 +9,12 @@ var CPMenuValidatedUserInterfaceItemTestValidatedItems = []; MenuTarget _menuTarget @accessors(property=menuTarget); } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { _menuTarget = [[MenuTarget alloc] init]; diff --git a/Tests/AppKit/CPOutlineViewTest.j b/Tests/AppKit/CPOutlineViewTest.j index 129c6965b..38ba86ef2 100644 --- a/Tests/AppKit/CPOutlineViewTest.j +++ b/Tests/AppKit/CPOutlineViewTest.j @@ -2,7 +2,6 @@ @class TestOutlineDataSource - @implementation CPOutlineViewTest : OJTestCase { CPOutlineView outlineView; @@ -10,6 +9,12 @@ TestOutlineDataSource dataSource; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { outlineView = [[CPOutlineView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; diff --git a/Tests/AppKit/CPPasteboardTest.j b/Tests/AppKit/CPPasteboardTest.j index 860576ca2..d6d5b5596 100644 --- a/Tests/AppKit/CPPasteboardTest.j +++ b/Tests/AppKit/CPPasteboardTest.j @@ -6,6 +6,12 @@ { } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)testSetString_forType_ { var pboard = [CPPasteboard generalPasteboard]; diff --git a/Tests/AppKit/CPPopUpButtonTest.j b/Tests/AppKit/CPPopUpButtonTest.j index 9e07b8366..fd74197cf 100644 --- a/Tests/AppKit/CPPopUpButtonTest.j +++ b/Tests/AppKit/CPPopUpButtonTest.j @@ -9,6 +9,12 @@ id objects @accessors; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { button = [CPPopUpButton new]; diff --git a/Tests/AppKit/CPPredicateEditorTest.j b/Tests/AppKit/CPPredicateEditorTest.j index a0063f254..db8869a62 100644 --- a/Tests/AppKit/CPPredicateEditorTest.j +++ b/Tests/AppKit/CPPredicateEditorTest.j @@ -6,6 +6,12 @@ CPPredicateEditor _editor; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { _editor = [[CPPredicateEditor alloc] initWithFrame:CGRectMakeZero()]; diff --git a/Tests/AppKit/CPResponderTest.j b/Tests/AppKit/CPResponderTest.j index 8bc0a940b..861d63d17 100644 --- a/Tests/AppKit/CPResponderTest.j +++ b/Tests/AppKit/CPResponderTest.j @@ -4,14 +4,18 @@ @import -[CPApplication sharedApplication] - @implementation CPResponderTest : OJTestCase { CPWindow theWindow; CPResponder responder; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { responder = [TestResponder new]; diff --git a/Tests/AppKit/CPScrollViewTest.j b/Tests/AppKit/CPScrollViewTest.j index 5728f87f3..d3e58f1a0 100644 --- a/Tests/AppKit/CPScrollViewTest.j +++ b/Tests/AppKit/CPScrollViewTest.j @@ -2,12 +2,17 @@ @import "CPNotificationCenterHelper.j" -[CPApplication sharedApplication]; @implementation CPScrollViewTest : OJTestCase { } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + /*! Test that scroll views don't generate bad layouts when very small. */ diff --git a/Tests/AppKit/CPSearchFieldTest.j b/Tests/AppKit/CPSearchFieldTest.j index 3bd6029a8..60a0d7536 100644 --- a/Tests/AppKit/CPSearchFieldTest.j +++ b/Tests/AppKit/CPSearchFieldTest.j @@ -5,6 +5,12 @@ CPSearchField _searchField; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { _searchField = [[CPSearchField alloc] initWithFrame:CGRectMakeZero()]; diff --git a/Tests/AppKit/CPSegmentedControlTest.j b/Tests/AppKit/CPSegmentedControlTest.j index f56c7f0a5..bf846be11 100644 --- a/Tests/AppKit/CPSegmentedControlTest.j +++ b/Tests/AppKit/CPSegmentedControlTest.j @@ -6,6 +6,12 @@ CPSegmentedControl _segmentedControl; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { _segmentedControl = [[CPSegmentedControl alloc] initWithFrame:CGRectMakeZero()]; diff --git a/Tests/AppKit/CPSliderTest.j b/Tests/AppKit/CPSliderTest.j index d80184aff..724378263 100644 --- a/Tests/AppKit/CPSliderTest.j +++ b/Tests/AppKit/CPSliderTest.j @@ -4,6 +4,12 @@ { } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)testIsContinuous { // While normally testing simple instance variables is a waste of time, diff --git a/Tests/AppKit/CPSplitViewTest.j b/Tests/AppKit/CPSplitViewTest.j index 6551c07b5..977d47e00 100644 --- a/Tests/AppKit/CPSplitViewTest.j +++ b/Tests/AppKit/CPSplitViewTest.j @@ -1,9 +1,6 @@ - @import @import -[CPApplication sharedApplication]; - @implementation CPSplitViewTest : OJTestCase { CPSplitView splitView; @@ -11,6 +8,12 @@ CPView viewB; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { splitView = [[CPSplitView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; diff --git a/Tests/AppKit/CPStepperTest.j b/Tests/AppKit/CPStepperTest.j index 59ced54d5..37cbe3098 100644 --- a/Tests/AppKit/CPStepperTest.j +++ b/Tests/AppKit/CPStepperTest.j @@ -1,13 +1,17 @@ @import @import -[CPApplication sharedApplication] - @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]; diff --git a/Tests/AppKit/CPTabViewTest.j b/Tests/AppKit/CPTabViewTest.j index 6d668742d..9c86436d9 100644 --- a/Tests/AppKit/CPTabViewTest.j +++ b/Tests/AppKit/CPTabViewTest.j @@ -1,8 +1,6 @@ @import @import - - @implementation CPTabView (TEST) - (CPSegmentedControl)tabs @@ -25,6 +23,12 @@ CPTabViewItem _tabItem2; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { _tabView = [[CPTabView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]; diff --git a/Tests/AppKit/CPTableViewReloadDataTest.j b/Tests/AppKit/CPTableViewReloadDataTest.j index fdd99e70a..c6cacddee 100644 --- a/Tests/AppKit/CPTableViewReloadDataTest.j +++ b/Tests/AppKit/CPTableViewReloadDataTest.j @@ -1,7 +1,5 @@ @import -[CPApplication sharedApplication]; - @implementation CPTableViewReloadDataTest : OJTestCase { CPWindow theWindow; @@ -9,6 +7,12 @@ CPArray tableContent; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { tableContent = []; diff --git a/Tests/AppKit/CPTableViewTableColumnTest.j b/Tests/AppKit/CPTableViewTableColumnTest.j index 261e4a734..bad588c1d 100644 --- a/Tests/AppKit/CPTableViewTableColumnTest.j +++ b/Tests/AppKit/CPTableViewTableColumnTest.j @@ -1,13 +1,17 @@ @import -[CPApplication sharedApplication]; - @implementation CPTableViewTableColumnTest : OJTestCase { CPWindow theWindow; CPTableView tableView; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { // setup a reasonable table diff --git a/Tests/AppKit/CPTableViewTest.j b/Tests/AppKit/CPTableViewTest.j index e3e29dccb..bd6a0799f 100644 --- a/Tests/AppKit/CPTableViewTest.j +++ b/Tests/AppKit/CPTableViewTest.j @@ -2,8 +2,6 @@ @import "CPNotificationCenterHelper.j" -[CPApplication sharedApplication]; - @implementation CPTableViewTest : OJTestCase { CPWindow theWindow; @@ -15,6 +13,12 @@ int selectionDidChangeNotificationsReceived; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { // setup a reasonable table diff --git a/Tests/AppKit/CPTextFieldTest.j b/Tests/AppKit/CPTextFieldTest.j index f14bfb6a7..c00934230 100644 --- a/Tests/AppKit/CPTextFieldTest.j +++ b/Tests/AppKit/CPTextFieldTest.j @@ -1,11 +1,16 @@ @import -[CPApplication sharedApplication] @implementation CPTextFieldTest : OJTestCase { } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + /*! Detect regressions with JS object theme attribute encoding in subclasses. diff --git a/Tests/AppKit/CPThemeTest.j b/Tests/AppKit/CPThemeTest.j index 0c85d6ee9..37942b3be 100644 --- a/Tests/AppKit/CPThemeTest.j +++ b/Tests/AppKit/CPThemeTest.j @@ -4,6 +4,12 @@ { } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)testCreatingThemeState { var themeState = new ThemeState({'test': true, 'test1': true}); diff --git a/Tests/AppKit/CPTokenFieldTest.j b/Tests/AppKit/CPTokenFieldTest.j index cd65113ad..a046ed1af 100644 --- a/Tests/AppKit/CPTokenFieldTest.j +++ b/Tests/AppKit/CPTokenFieldTest.j @@ -2,8 +2,6 @@ @class TestDelegateTokenField -[CPApplication sharedApplication]; - @implementation CPTokenFieldTest : OJTestCase { CPWindow _theWindow; @@ -12,6 +10,12 @@ } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { _theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 1024.0, 768.0) diff --git a/Tests/AppKit/CPTreeNodeTest.j b/Tests/AppKit/CPTreeNodeTest.j index 3bb5510a8..c53c3d6f8 100644 --- a/Tests/AppKit/CPTreeNodeTest.j +++ b/Tests/AppKit/CPTreeNodeTest.j @@ -1,13 +1,17 @@ - @import - @implementation CPTreeNodeTest : OJTestCase { CPTreeNode treeNode; CPTreeNode childNode; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { treeNode = [CPTreeNode treeNodeWithRepresentedObject:nil]; diff --git a/Tests/AppKit/CPViewTest.j b/Tests/AppKit/CPViewTest.j index 549773b26..3f73a614d 100644 --- a/Tests/AppKit/CPViewTest.j +++ b/Tests/AppKit/CPViewTest.j @@ -1,9 +1,6 @@ - @import @import -[CPApplication sharedApplication] - var methodCalled; @implementation CPViewTest : OJTestCase @@ -16,6 +13,12 @@ var methodCalled; CPWindow window; } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { window = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 1000.0, 1000.0) styleMask:CPWindowNotSizable]; diff --git a/Tests/AppKit/CPWindowTest.j b/Tests/AppKit/CPWindowTest.j index cf51e8cba..6b635d930 100644 --- a/Tests/AppKit/CPWindowTest.j +++ b/Tests/AppKit/CPWindowTest.j @@ -1,15 +1,18 @@ - @import @import @import -[CPApplication sharedApplication]; - @implementation CPWindowTest : OJTestCase { CPWindow _window @accessors(property=window); } ++ (void)setUp +{ + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; +} + - (void)setUp { _window = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 1024.0, 768.0) diff --git a/Tests/AppKit/WithAndWithoutBindingsIntegration/01_WithoutBindings/WithoutBindingsTest.j b/Tests/AppKit/WithAndWithoutBindingsIntegration/01_WithoutBindings/WithoutBindingsTest.j index 134fed5d4..9aadbb1aa 100644 --- a/Tests/AppKit/WithAndWithoutBindingsIntegration/01_WithoutBindings/WithoutBindingsTest.j +++ b/Tests/AppKit/WithAndWithoutBindingsIntegration/01_WithoutBindings/WithoutBindingsTest.j @@ -30,10 +30,10 @@ { } -- (void)setUp ++ (void)setUp { - // CPApp must be initialised or action sending will not work. - [CPApplication sharedApplication]; + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; } - (void)test diff --git a/Tests/AppKit/WithAndWithoutBindingsIntegration/02_WithBindings/WithBindingsTest.j b/Tests/AppKit/WithAndWithoutBindingsIntegration/02_WithBindings/WithBindingsTest.j index fe266be8a..31064148b 100644 --- a/Tests/AppKit/WithAndWithoutBindingsIntegration/02_WithBindings/WithBindingsTest.j +++ b/Tests/AppKit/WithAndWithoutBindingsIntegration/02_WithBindings/WithBindingsTest.j @@ -32,10 +32,10 @@ { } -- (void)setUp ++ (void)setUp { - // CPApp must be initialised or action sending will not work. - [CPApplication sharedApplication]; + // This will init the global var CPApp which are used internally in the AppKit + [[CPApplication alloc] init]; } - (void)test