From 10dff130d20bb7dc0c0ea2119c7dff7b3743fd76 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Mon, 20 Dec 1999 14:59:05 +0000 Subject: [PATCH] Added testing stuff git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@5589 72102866-910b-0410-8b05-ffd578937521 --- Testing/GNUmakefile | 44 +++++++++++++++++++ Testing/GormTest.m | 100 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 Testing/GNUmakefile create mode 100644 Testing/GormTest.m diff --git a/Testing/GNUmakefile b/Testing/GNUmakefile new file mode 100644 index 00000000..33a43a79 --- /dev/null +++ b/Testing/GNUmakefile @@ -0,0 +1,44 @@ +# GNUmakefile: makefile for GNUstep nib loading test +# +# Copyright (C) 1999 Free Software Foundation, Inc. +# +# Author: Richard Frith-Macdonald +# Date: 1999 +# +# This file is part of GNUstep. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA +# + +include $(GNUSTEP_MAKEFILES)/common.make + +# +# MAIN APP +# +APP_NAME = GormTest +GormTest_RESOURCE_FILES = \ + + +GormTest_OBJC_FILES = \ + GormTest.m + +-include GNUmakefile.preamble + +-include GNUmakefile.local + +include $(GNUSTEP_MAKEFILES)/application.make + +-include GNUmakefile.postamble + diff --git a/Testing/GormTest.m b/Testing/GormTest.m new file mode 100644 index 00000000..25748163 --- /dev/null +++ b/Testing/GormTest.m @@ -0,0 +1,100 @@ +/* GormTest.m + * + * Copyright (C) 1999 Free Software Foundation, Inc. + * + * Author: Richard Frith-Macdonald + * Date: 1999 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include + +@interface Controller: NSObject +{ +} +- (id)open: (id) sender; +@end + +@implementation Controller + +- (id) open: (id)sender +{ + NSArray *fileTypes = [NSArray arrayWithObject: @"nib"]; + NSOpenPanel *oPanel = [NSOpenPanel openPanel]; + int result; + + [oPanel setAllowsMultipleSelection: NO]; + [oPanel setCanChooseFiles: YES]; + [oPanel setCanChooseDirectories: NO]; + result = [oPanel runModalForDirectory: NSHomeDirectory() + file: nil + types: fileTypes]; + if (result == NSOKButton) + { + [NSBundle loadNibFile: [oPanel filename] + externalNameTable: + [NSDictionary dictionaryWithObject: NSApp forKey: @"NSOwner"] + withZone: NSDefaultMallocZone()]; + [[NSApp delegate] makeKeyAndOrderFront: self]; + return self; + } + return nil; /* Failed */ +} +@end + +int +main (void) +{ + NSAutoreleasePool *pool; + NSApplication *app; + NSMenu *mainMenu; + NSMenu *windowsMenu; + NSMenuItem *menuItem; + Controller *appController; + + pool = [NSAutoreleasePool new]; + initialize_gnustep_backend (); + app = [NSApplication sharedApplication]; + + mainMenu = [[NSMenu alloc] initWithTitle: @"Gorm Test"]; + + [mainMenu addItemWithTitle: @"Open" + action: @selector(open:) + keyEquivalent: @"o"]; + + menuItem = [mainMenu addItemWithTitle: @"Windows" + action: NULL + keyEquivalent: @""]; + windowsMenu = [NSMenu new]; + [mainMenu setSubmenu: windowsMenu forItem: menuItem]; + + [mainMenu addItemWithTitle: @"Quit" + action: @selector(terminate:) + keyEquivalent: @"q"]; + + [app setMainMenu: mainMenu]; + [app setWindowsMenu: windowsMenu]; + [mainMenu display]; + appController = [Controller new]; + [app setDelegate: appController]; + [app run]; + [pool release]; + return 0; +} +