mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 20:50:44 +00:00
* Tests/gui/NSSavePanel/setDelegate_reload.m: Rewrite to remove
use of @defs(). Base on idea by Wolfgang Lux <wolfgang.lux@gmail.com> git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36313 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
14584bb4e2
commit
bfd8c9cba9
2 changed files with 62 additions and 75 deletions
|
@ -1,3 +1,9 @@
|
|||
2013-03-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Tests/gui/NSSavePanel/setDelegate_reload.m: Rewrite to remove
|
||||
use of @defs().
|
||||
Base on idea by Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
2013-03-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSTableColumn.m (-initWithCoder:): Make columns
|
||||
|
|
|
@ -7,20 +7,16 @@ delegate changes.
|
|||
|
||||
#include "Testing.h"
|
||||
|
||||
/*#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSBundle.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSBrowser.h>
|
||||
#include <AppKit/NSMatrix.h>
|
||||
#include <AppKit/NSSavePanel.h>
|
||||
#include <AppKit/NSWindow.h>*/
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
/* Ugly but automatable. :) */
|
||||
typedef struct
|
||||
@implementation NSSavePanel (TestDelegate)
|
||||
|
||||
- (NSMatrix *)lastColumnMatrix
|
||||
{
|
||||
@defs(NSSavePanel);
|
||||
} NSSavePanel_ivars;
|
||||
return [_browser matrixInColumn: [_browser lastColumn]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface Delegate : NSObject
|
||||
@end
|
||||
|
@ -30,76 +26,61 @@ typedef struct
|
|||
static BOOL pressed;
|
||||
static NSSavePanel *sp;
|
||||
|
||||
+(BOOL) panel: (NSSavePanel *)p
|
||||
shouldShowFilename: (NSString *)fname
|
||||
+ (BOOL) panel: (NSSavePanel *)p
|
||||
shouldShowFilename: (NSString *)fname
|
||||
{
|
||||
// printf("should show '%s'?\n",[fname cString]);
|
||||
if ([[fname lastPathComponent] isEqual: @"B"])
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
if ([[fname lastPathComponent] isEqual: @"B"])
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*+(void) foo
|
||||
{
|
||||
printf("did press button\n");
|
||||
pressed=YES;
|
||||
[sp validateVisibleColumns];
|
||||
}*/
|
||||
|
||||
@end
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NSAutoreleasePool *arp=[NSAutoreleasePool new];
|
||||
NSSavePanel *p;
|
||||
NSBrowser *b;
|
||||
NSMatrix *m;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSSavePanel *p;
|
||||
NSMatrix *m;
|
||||
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
sp=p=[NSSavePanel savePanel];
|
||||
[p setShowsHiddenFiles: NO];
|
||||
[p setDirectory: [[[[[NSBundle mainBundle] bundlePath]
|
||||
stringByDeletingLastPathComponent] stringByDeletingLastPathComponent]
|
||||
stringByAppendingPathComponent: @"dummy"]];
|
||||
|
||||
b=((NSSavePanel_ivars *)p)->_browser;
|
||||
m=[b matrixInColumn: [b lastColumn]];
|
||||
pass([m numberOfRows] == 2
|
||||
&& [[[m cellAtRow: 0 column: 0] stringValue] isEqual: @"A"]
|
||||
&& [[[m cellAtRow: 1 column: 0] stringValue] isEqual: @"B"],
|
||||
"browser initially contains all files");
|
||||
|
||||
[p setDelegate: [Delegate self]];
|
||||
b=((NSSavePanel_ivars *)p)->_browser;
|
||||
m=[b matrixInColumn: [b lastColumn]];
|
||||
pass([m numberOfRows] == 1
|
||||
&& [[[m cellAtRow: 0 column: 0] stringValue] isEqual: @"A"],
|
||||
"browser is reloaded after -setDelegate:");
|
||||
|
||||
/* Not really a -setDelegate: issue, but the other methods involved are
|
||||
documented as doing the wrong thing. */
|
||||
[p setDelegate: nil];
|
||||
b=((NSSavePanel_ivars *)p)->_browser;
|
||||
m=[b matrixInColumn: [b lastColumn]];
|
||||
testHopeful = YES;
|
||||
pass([m numberOfRows] == 2
|
||||
&& [[[m cellAtRow: 0 column: 0] stringValue] isEqual: @"A"]
|
||||
&& [[[m cellAtRow: 1 column: 0] stringValue] isEqual: @"B"],
|
||||
"browser contains all files after resetting delegate");
|
||||
testHopeful = NO;
|
||||
|
||||
[b scrollColumnsLeftBy: [b lastColumn]];
|
||||
[p setDelegate: [Delegate self]];
|
||||
b=((NSSavePanel_ivars *)p)->_browser;
|
||||
m=[b matrixInColumn: [b lastColumn]];
|
||||
pass([m numberOfRows] == 1
|
||||
&& [[[m cellAtRow: 0 column: 0] stringValue] isEqual: @"A"],
|
||||
"browser is reloaded after -setDelegate: (2)");
|
||||
|
||||
[arp release];
|
||||
return 0;
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
p = [NSSavePanel savePanel];
|
||||
[p setShowsHiddenFiles: NO];
|
||||
[p setDirectory: [[[[[NSBundle mainBundle] bundlePath]
|
||||
stringByDeletingLastPathComponent] stringByDeletingLastPathComponent]
|
||||
stringByAppendingPathComponent: @"dummy"]];
|
||||
|
||||
m = [p lastColumnMatrix];
|
||||
pass([m numberOfRows] == 2
|
||||
&& [[[m cellAtRow: 0 column: 0] stringValue] isEqual: @"A"]
|
||||
&& [[[m cellAtRow: 1 column: 0] stringValue] isEqual: @"B"],
|
||||
"browser initially contains all files");
|
||||
|
||||
[p setDelegate: [Delegate self]];
|
||||
m = [p lastColumnMatrix];
|
||||
pass([m numberOfRows] == 1
|
||||
&& [[[m cellAtRow: 0 column: 0] stringValue] isEqual: @"A"],
|
||||
"browser is reloaded after -setDelegate:");
|
||||
|
||||
/* Not really a -setDelegate: issue, but the other methods involved are
|
||||
documented as doing the wrong thing. */
|
||||
[p setDelegate: nil];
|
||||
m = [p lastColumnMatrix];
|
||||
testHopeful = YES;
|
||||
pass([m numberOfRows] == 2
|
||||
&& [[[m cellAtRow: 0 column: 0] stringValue] isEqual: @"A"]
|
||||
&& [[[m cellAtRow: 1 column: 0] stringValue] isEqual: @"B"],
|
||||
"browser contains all files after resetting delegate");
|
||||
testHopeful = NO;
|
||||
|
||||
[p setDelegate: [Delegate self]];
|
||||
m = [p lastColumnMatrix];
|
||||
pass([m numberOfRows] == 1
|
||||
&& [[[m cellAtRow: 0 column: 0] stringValue] isEqual: @"A"],
|
||||
"browser is reloaded after -setDelegate: (2)");
|
||||
|
||||
[arp release];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue