mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-29 18:02:03 +00:00
Fixed: CPSplitView tried to auto save even without an auto save name.
This commit is contained in:
1 parent
b26b0a321b
commit
ab3f260757
2 files changed
+48
-8
No files matched your search
@@ -1002,7 +1002,7 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
*/
|
||||
- (void)_autosave
|
||||
{
|
||||
if (!_shouldAutosave)
|
||||
if (!_shouldAutosave || !autosaveName)
|
||||
return;
|
||||
|
||||
var userDefaults = [CPUserDefaults standardUserDefaults],
|
||||
@@ -1068,6 +1068,8 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
*/
|
||||
- (CPString)_framesKeyForAutosaveName:(CPString)theAutosaveName
|
||||
{
|
||||
if (!theAutosaveName)
|
||||
return nil;
|
||||
return @"CPSplitView Subview Frames " + theAutosaveName;
|
||||
}
|
||||
|
||||
@@ -1076,6 +1078,8 @@ The sum of the views and the sum of the dividers should be equal to the size of
|
||||
*/
|
||||
- (CPString)_precollapseKeyForAutosaveName:(CPString)theAutosaveName
|
||||
{
|
||||
if (!theAutosaveName)
|
||||
return nil;
|
||||
return @"CPSplitView Subview Precollapse Positions " + theAutosaveName;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,25 +2,31 @@
|
||||
@import <AppKit/CPApplication.j>
|
||||
@import <AppKit/CPSplitView.j>
|
||||
|
||||
[CPApplication sharedApplication]
|
||||
[CPApplication sharedApplication];
|
||||
|
||||
@implementation CPSplitViewTest : OJTestCase
|
||||
{
|
||||
CPSplitView splitView;
|
||||
CPView viewA;
|
||||
CPView viewB;
|
||||
}
|
||||
|
||||
- (void)testSplitViewResize
|
||||
- (void)setUp
|
||||
{
|
||||
var splitView = [[CPSplitView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)],
|
||||
viewA = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)],
|
||||
viewB = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
|
||||
splitView = [[CPSplitView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
||||
viewA = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
|
||||
viewB = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
|
||||
|
||||
[splitView addSubview:viewA];
|
||||
[splitView addSubview:viewB];
|
||||
[splitView setVertical:NO];
|
||||
|
||||
var dividerThickness = [splitView dividerThickness];
|
||||
|
||||
[splitView setPosition:50 ofDividerAtIndex:0];
|
||||
}
|
||||
|
||||
- (void)testSplitViewResize
|
||||
{
|
||||
var dividerThickness = [splitView dividerThickness];
|
||||
|
||||
[self assert:50 equals:[viewA frameSize].height];
|
||||
[self assert:(50 - dividerThickness) equals:[viewB frameSize].height];
|
||||
@@ -36,4 +42,34 @@
|
||||
[self assert:(120 - dividerThickness) equals:[viewB frameSize].height];
|
||||
}
|
||||
|
||||
- (void)testAutosave
|
||||
{
|
||||
// Verify that the split view does not attempt to auto save without an auto save name.
|
||||
|
||||
[[CPUserDefaults standardUserDefaults] setPersistentStoreClass:CPUserDefaultsFailingStore forDomain:CPApplicationDomain reloadData:NO];
|
||||
|
||||
[splitView setPosition:50 ofDividerAtIndex:0];
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
This store always fails.
|
||||
*/
|
||||
@implementation CPUserDefaultsFailingStore : CPUserDefaultsStore
|
||||
{
|
||||
}
|
||||
|
||||
- (CPData)data
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setData:(CPData)aData
|
||||
{
|
||||
[CPException raise:@"CPUnsupportedMethodException" reason:@"Data should not be stored in CPUserDefaultsFailingStore."];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user