libs-gui/Tests/gui/NSNibLoading/basic.m

77 lines
2 KiB
Mathematica
Raw Permalink Normal View History

#import "ObjectTesting.h"
2021-10-12 22:46:47 +00:00
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
2021-10-11 14:07:29 +00:00
// For some nib/xibs the AppDelegate is defined...
2021-10-12 22:24:35 +00:00
@interface AppDelegate : NSObject
2021-10-11 23:31:16 +00:00
{
IBOutlet NSWindow *window;
}
2021-10-11 14:07:29 +00:00
@end
@implementation AppDelegate
@end
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSArray **testObjects;
BOOL success = NO;
NSFileManager *mgr = [NSFileManager defaultManager];
NSString *path = [mgr currentDirectoryPath];
NSBundle *bundle = [[NSBundle alloc] initWithPath: path];
START_SET("NSNibLoading GNUstep basic")
NS_DURING
{
[NSApplication sharedApplication];
}
NS_HANDLER
{
if ([[localException name] isEqualToString: NSInternalInconsistencyException ])
SKIP("It looks like GNUstep backend is not yet installed")
}
2021-10-12 22:24:35 +00:00
NS_ENDHANDLER
if ([[path lastPathComponent] isEqualToString: @"obj"])
{
path = [path stringByDeletingLastPathComponent];
}
2021-10-12 22:24:35 +00:00
PASS(bundle != nil, "NSBundle was initialized");
2021-10-11 14:07:29 +00:00
2021-10-11 23:31:16 +00:00
NS_DURING
{
success = [bundle loadNibNamed: @"Test-gorm"
owner: [NSApplication sharedApplication]
topLevelObjects: testObjects];
2021-10-12 22:24:35 +00:00
PASS(success == YES, ".gorm file was loaded properly using loadNibNamed:owner:topLevelObjects:");
2021-10-11 23:31:16 +00:00
success = [bundle loadNibNamed: @"Test-xib"
owner: [NSApplication sharedApplication]
topLevelObjects: testObjects];
2021-10-12 22:24:35 +00:00
PASS(success == YES, ".xib file was loaded properly using loadNibNamed:owner:topLevelObjects:");
2021-10-11 23:31:16 +00:00
success = [bundle loadNibNamed: @"Test-nib"
owner: [NSApplication sharedApplication]
topLevelObjects: testObjects];
2021-10-12 22:24:35 +00:00
PASS(success == YES, ".nib file was loaded properly using loadNibNamed:owner:topLevelObjects:");
2021-10-11 23:31:16 +00:00
}
NS_HANDLER
{
NSLog(@"%@", [localException reason]);
}
2021-10-12 22:24:35 +00:00
NS_ENDHANDLER
END_SET("NSNibLoading GNUstep basic")
[arp release];
return 0;
}