mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Test framework loading as well (we recently had a fault there)
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39954 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3653340722
commit
32563778cd
3 changed files with 49 additions and 8 deletions
|
@ -2,6 +2,7 @@
|
|||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
BUNDLE_NAME = TestBundle
|
||||
FRAMEWORK_NAME = TestFramework
|
||||
|
||||
TestBundle_OBJC_FILES = TestBundle.m
|
||||
TestBundle_RESOURCE_FILES = NonLocalRes.txt
|
||||
|
@ -9,6 +10,13 @@ TestBundle_LANGUAGES = English French de
|
|||
TestBundle_LOCALIZED_RESOURCE_FILES = TextRes.txt
|
||||
TestBundle_NEEDS_GUI = NO
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
|
||||
TestFramework_OBJC_FILES = TestFramework.m
|
||||
TestFramework_RESOURCE_FILES = NonLocalRes.txt
|
||||
TestFramework_LANGUAGES = English French de
|
||||
TestFramework_LOCALIZED_RESOURCE_FILES = TextRes.txt
|
||||
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
include $(GNUSTEP_MAKEFILES)/framework.make
|
||||
check:: all
|
||||
|
|
16
Tests/base/NSBundle/Resources/TestFramework.m
Normal file
16
Tests/base/NSBundle/Resources/TestFramework.m
Normal file
|
@ -0,0 +1,16 @@
|
|||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
@interface TestFramework : NSObject
|
||||
{
|
||||
|
||||
}
|
||||
-(NSString *)test;
|
||||
@end
|
||||
|
||||
@implementation TestFramework
|
||||
-(NSString *)test
|
||||
{
|
||||
return @"Something";
|
||||
}
|
||||
@end
|
|
@ -6,18 +6,19 @@
|
|||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
|
||||
int main()
|
||||
@interface NSObject (TestMock)
|
||||
- (NSString*)test;
|
||||
@end
|
||||
|
||||
|
||||
static void _testBundle(NSString* name, NSString* className)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *path, *localPath;
|
||||
NSBundle *bundle;
|
||||
NSArray *arr, *carr;
|
||||
|
||||
NSString *path, *localPath;
|
||||
path = [[[[[NSFileManager defaultManager] currentDirectoryPath]
|
||||
stringByStandardizingPath] stringByAppendingPathComponent: @"Resources"]
|
||||
stringByAppendingPathComponent: @"TestBundle.bundle"];
|
||||
|
||||
/* --- [NSBundle -pathsForResourcesOfType:inDirectory:] --- */
|
||||
stringByAppendingPathComponent: name];
|
||||
bundle = [NSBundle bundleWithPath: path];
|
||||
arr = [bundle pathsForResourcesOfType: @"txt" inDirectory: nil];
|
||||
PASS((arr && [arr count]),
|
||||
|
@ -77,7 +78,23 @@ int main()
|
|||
@"Resources/de.lproj/TextRes.txt"];
|
||||
PASS([arr containsObject: localPath],
|
||||
"Returned array for 'German' contains localized resource");
|
||||
Class clz = [bundle classNamed: className];
|
||||
PASS(clz, "Class can be loaded from bundle");
|
||||
id obj = [clz new];
|
||||
PASS(obj, "Objects from bundle-loaded classes can be instantiated");
|
||||
PASS_EQUAL([obj test], @"Something", "Correct method called");
|
||||
[obj release];
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
START_SET("Bundle")
|
||||
_testBundle(@"TestBundle.bundle", @"TestBundle");
|
||||
END_SET("Bundle")
|
||||
START_SET("Framework")
|
||||
_testBundle(@"TestFramework.framework", @"TestFramework");
|
||||
END_SET("Framework");
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue