Add support to test gui in gormtool

This commit is contained in:
Gregory John Casamento 2023-12-11 02:32:39 -05:00
parent d0879eeb84
commit 5c3b84748e
3 changed files with 30 additions and 4 deletions

View file

@ -78,6 +78,10 @@
- (IBAction) testInterface: (id)sender;
- (IBAction) endTesting: (id)sender;
// Testing...
- (void) setTestingInterface: (BOOL)testing;
- (BOOL) isTestingInterface;
@end
#endif // import guard

View file

@ -71,6 +71,9 @@
path = [bundle pathForImageResource: @"GormTesting"];
testingImage = [[NSImage alloc] initWithContentsOfFile: path];
}
// Initialize ivars
isTesting = NO;
// regular notifications...
[nc addObserver: self
@ -419,7 +422,7 @@
- (IBAction) testInterface: (id)sender
{
if (isTesting == NO)
if (isTesting == NO || [self isInTool])
{
// top level objects
NS_DURING
@ -831,6 +834,11 @@
return isTesting;
}
- (void) setTestingInterface: (BOOL)testing
{
isTesting = testing;
}
- (NSImage*) linkImage
{
return linkImage;

View file

@ -91,7 +91,7 @@
NSMutableDictionary *result = [NSMutableDictionary dictionary];
NSProcessInfo *pi = [NSProcessInfo processInfo];
NSMutableArray *args = [NSMutableArray arrayWithArray: [pi arguments]];
BOOL filenameIsLastObject = NO;
// BOOL filenameIsLastObject = NO;
NSString *file = nil;
// If the --read option isn't specified, we assume that the last argument is
@ -99,7 +99,7 @@
if ([args containsObject: @"--read"] == NO)
{
file = [args lastObject];
filenameIsLastObject = YES;
// filenameIsLastObject = YES;
[args removeObject: file];
NSDebugLog(@"file = %@", file);
@ -237,6 +237,12 @@
parse_val = YES;
}
if ([obj isEqualToString: @"--test"])
{
[pair setArgument: obj];
parse_val = NO;
}
// If there is no parameter for the argument, set it anyway...
if (parse_val == NO)
{
@ -253,7 +259,8 @@
NSProcessInfo *pi = [NSProcessInfo processInfo];
[NSClassSwapper setIsInInterfaceBuilder: YES];
[self setTestingInterface: NO];
if ([[pi arguments] count] > 1)
{
NSString *file = nil;
@ -465,6 +472,13 @@
}
}
}
opt = [args objectForKey: @"--test"];
if (opt != nil)
{
NSLog(@"Control-C to end");
[self testInterface: self];
}
}
[NSClassSwapper setIsInInterfaceBuilder: NO];