mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-09 16:38:45 +00:00
Merge branch 'master' of git://github.com/280north/cappuccino into CPDecimalNumber
This commit is contained in:
commit
aae415c1ee
11 files changed
+301
-21
No files matched your search
@@ -250,11 +250,11 @@
|
||||
|
||||
/*!
|
||||
Returns \c YES if the collection view is
|
||||
selected, and \c NO otherwise.
|
||||
selectable, and \c NO otherwise.
|
||||
*/
|
||||
- (BOOL)isSelected
|
||||
- (BOOL)isSelectable
|
||||
{
|
||||
return _isSelected;
|
||||
return _isSelectable;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -675,6 +675,7 @@
|
||||
var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
|
||||
CPCollectionViewMaxItemSizeKey = @"CPCollectionViewMaxItemSizeKey",
|
||||
CPCollectionViewVerticalMarginKey = @"CPCollectionViewVerticalMarginKey",
|
||||
CPCollectionViewSelectableKey = @"CPCollectionViewSelectableKey",
|
||||
CPCollectionViewBackgroundColorsKey = @"CPCollectionViewBackgroundColorsKey";
|
||||
|
||||
|
||||
@@ -695,7 +696,10 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
|
||||
|
||||
_minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey] || CGSizeMakeZero();
|
||||
_maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey] || CGSizeMakeZero();
|
||||
|
||||
_verticalMargin = [aCoder decodeFloatForKey:CPCollectionViewVerticalMarginKey];
|
||||
|
||||
_isSelectable = [aCoder decodeBoolForKey:CPCollectionViewSelectableKey];
|
||||
|
||||
[self setBackgroundColors:[aCoder decodeObjectForKey:CPCollectionViewBackgroundColorsKey]];
|
||||
|
||||
@@ -704,7 +708,6 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
|
||||
_selectionIndexes = [CPIndexSet indexSet];
|
||||
|
||||
_allowsEmptySelection = YES;
|
||||
_isSelectable = YES;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -716,10 +719,12 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
|
||||
|
||||
if (!CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()))
|
||||
[aCoder encodeSize:_minItemSize forKey:CPCollectionViewMinItemSizeKey];
|
||||
|
||||
|
||||
if (!CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero()))
|
||||
[aCoder encodeSize:_maxItemSize forKey:CPCollectionViewMaxItemSizeKey];
|
||||
|
||||
|
||||
[aCoder encodeBool:_isSelectable forKey:CPCollectionViewSelectableKey];
|
||||
|
||||
[aCoder encodeFloat:_verticalMargin forKey:CPCollectionViewVerticalMarginKey];
|
||||
|
||||
[aCoder encodeObject:_backgroundColors forKey:CPCollectionViewBackgroundColorsKey];
|
||||
|
||||
@@ -281,7 +281,7 @@ var CPSearchFieldSearchImage = nil,
|
||||
/*!
|
||||
Sets the menu template object used to dynamically construct the receiver's pop-up icon menu.
|
||||
@param menu The menu template to use.
|
||||
The receiver looks for the tag constants described in ÒMenu tagsÓ to determine how to populate the menu with items related to recent searches. See ÒConfiguring a Search MenuÓ for a sample of how you might set up the search menu template.
|
||||
The receiver looks for the tag constants described in ŇMenu tagsÓ to determine how to populate the menu with items related to recent searches. See ŇConfiguring a Search MenuÓ for a sample of how you might set up the search menu template.
|
||||
*/
|
||||
- (void)setSearchMenuTemplate:(CPMenu)menu
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
You use each instance of CPViewController to manage a single view (and hierarchy). For a simple view controller,
|
||||
this entails managing the view hierarchy responsible for presenting your application content.
|
||||
A typical view hierarchy consists of a root viewÑa reference to which is available in the view property of this classÑ
|
||||
A typical view hierarchy consists of a root viewŃa reference to which is available in the view property of this classŃ
|
||||
and one or more subviews presenting the actual content. In the case of navigation and tab bar controllers, the view
|
||||
controller manages not only the high-level view hierarchy (which provides the navigation controls) but also one
|
||||
or more additional view controllers that handle the presentation of the application content.
|
||||
@@ -104,8 +104,8 @@
|
||||
If you create your views manually, you must override this method and use it to create your view and assign it to the view property.
|
||||
The default implementation for programmatic views is to create a plain view. You can invoke super to utilize this view.
|
||||
|
||||
If you use Interface Builder to create your views and initialize the view controllerÑthat is, you initialize the view using the
|
||||
initWithCibName:bundle: methodÑthen you must not override this method. The consequences risk shattering the space-time continuum.
|
||||
If you use Interface Builder to create your views and initialize the view controllerŃthat is, you initialize the view using the
|
||||
initWithCibName:bundle: methodŃthen you must not override this method. The consequences risk shattering the space-time continuum.
|
||||
|
||||
Note: The cib loading system is currently asynchronous.
|
||||
*/
|
||||
|
||||
Vendored
+1
-1
Submodule External/browserjs updated: 9eb026b82b...98a71a4122.
Vendored
+1
-1
Submodule External/narwhal updated: 4eb47f95f1...cd6e4b02ab.
@@ -134,7 +134,7 @@ var objj_eval = exports.objj_eval = function(code)
|
||||
}
|
||||
|
||||
// prepocesses Objective-J code into JavaScript, which will perform imports synchronously when eval'd
|
||||
var objj_preprocess_sync = function(code, path)
|
||||
window.objj_preprocess_sync = function(code, path)
|
||||
{
|
||||
var fragments = objj_preprocess(code, new objj_bundle(), new objj_file(), OBJJ_PREPROCESSOR_DEBUG_SYMBOLS)
|
||||
|
||||
@@ -153,7 +153,7 @@ var objj_preprocess_sync = function(code, path)
|
||||
}
|
||||
|
||||
// synchronously perform an import
|
||||
var objj_import_sync = function(pathOrPaths, isLocal)
|
||||
window.objj_import_sync = function(pathOrPaths, isLocal)
|
||||
{
|
||||
var context = new objj_context();
|
||||
context.pushFragment(fragment_create_file(pathOrPaths, new objj_bundle(), isLocal, NULL));
|
||||
|
||||
@@ -118,7 +118,7 @@ task :install => [:tools_download] do
|
||||
end
|
||||
|
||||
task :test => [:build] do
|
||||
tests = "'" + FileList['Tests/**/*.j'].join("' '") + "'"
|
||||
tests = "'" + FileList['Tests/**/*Test.j'].join("' '") + "'"
|
||||
build_result = %x{ojtest #{tests} }
|
||||
|
||||
if build_result.match(/Test suite failed/i)
|
||||
|
||||
@@ -2,15 +2,32 @@
|
||||
@import <AppKit/AppKit.j>
|
||||
|
||||
@implementation CPCollectionViewTest : OJTestCase
|
||||
{
|
||||
CPCollectionView _collectionView;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
_collectionView = [[CPCollectionView alloc] initWithFrame:CGRectMakeZero()];
|
||||
}
|
||||
|
||||
- (void)testItemPrototypeActuallyReturnsTheItemPrototype
|
||||
{
|
||||
var propertiesCollectionView = [[CPCollectionView alloc] initWithFrame:CGRectMakeZero()],
|
||||
itemPrototype = [[CPCollectionViewItem alloc] init];
|
||||
|
||||
[propertiesCollectionView setItemPrototype:itemPrototype];
|
||||
var itemPrototype = [[CPCollectionViewItem alloc] init];
|
||||
[_collectionView setItemPrototype:itemPrototype];
|
||||
|
||||
[self assert:[CPCollectionViewItem class] equals:[[propertiesCollectionView itemPrototype] class]];
|
||||
[self assert:itemPrototype same:[_collectionView itemPrototype]];
|
||||
}
|
||||
|
||||
- (void)testIsSelectableGetter
|
||||
{
|
||||
var collectionView = [[CPCollectionView alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[collectionView setSelectable:YES];
|
||||
[self assertTrue:[collectionView isSelectable]];
|
||||
|
||||
[collectionView setSelectable:NO];
|
||||
[self assertFalse:[collectionView isSelectable]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,82 @@
|
||||
@import <Foundation/CPArray.j>
|
||||
@import <Foundation/CPData.j>
|
||||
@import <Foundation/CPDictionary.j>
|
||||
@import <Foundation/CPKeyedArchiver.j>
|
||||
@import <Foundation/CPNumber.j>
|
||||
|
||||
@implementation CPDataTest : OJTestCase
|
||||
{
|
||||
}
|
||||
|
||||
-(void)setUp
|
||||
{
|
||||
string_data = [[CPData alloc] initWithString:@"CPData Test"];
|
||||
|
||||
// Plist helpers
|
||||
keys = [@"key1", @"key2", @"key3", @"key4"];
|
||||
objects = [@"Some random characters", NO, 9.9, 8.8];
|
||||
dict = [CPDictionary dictionaryWithObjects:objects forKeys:keys];
|
||||
|
||||
plist_data = [[CPData alloc] initWithPlistObject:dict];
|
||||
}
|
||||
|
||||
-(void)testStringLength
|
||||
{
|
||||
var data = [[CPData alloc] initWithString:@"CPData Test"];
|
||||
[self assert:[data length] equals:11];
|
||||
|
||||
var data_cm = [CPData dataWithString:@"CPData Test"];
|
||||
[self assert:[data_cm length] equals:11];
|
||||
}
|
||||
|
||||
-(void)testPlistLength
|
||||
{
|
||||
var data = [[CPData alloc] initWithPlistObject:dict];
|
||||
[self assert:[data length] equals:93];
|
||||
|
||||
var data_cm = [CPData dataWithPlistObject:dict];
|
||||
[self assert:[data length] equals:93];
|
||||
}
|
||||
|
||||
-(void)testDescription
|
||||
{
|
||||
[self assert:[string_data description] equals:[string_data string]];
|
||||
}
|
||||
|
||||
-(void)testString
|
||||
{
|
||||
[self assert:[string_data string] equals:@"CPData Test"];
|
||||
}
|
||||
|
||||
-(void)testStringFromPlist
|
||||
{
|
||||
[self assert:[plist_data string] equals:"280NPLIST;1.0;D;K;4;key4f;3;8.8K;4;key3f;3;9.9K;4;key2F;K;4;key1S;22;Some random charactersE;"];
|
||||
}
|
||||
|
||||
-(void)testPlistObject
|
||||
{
|
||||
[self assert:[[plist_data plistObject] objectForKey:@"key1"] equals:@"Some random characters"];
|
||||
[self assert:[[plist_data plistObject] objectForKey:@"key2"] equals:[CPNumber numberWithBool:NO]];
|
||||
[self assert:[[plist_data plistObject] objectForKey:@"key3"] equals:[CPNumber numberWithDouble:9.9]];
|
||||
[self assert:[[plist_data plistObject] objectForKey:@"key4"] equals:[CPNumber numberWithDouble:8.8]];
|
||||
|
||||
[self assert:[plist_data plistObject] equals:dict];
|
||||
}
|
||||
|
||||
-(void)testSetPlistObject
|
||||
{
|
||||
var data = [[CPData alloc] init];
|
||||
[data setPlistObject:dict];
|
||||
|
||||
[self assert:[data plistObject] equals:dict];
|
||||
}
|
||||
|
||||
-(void)testSetString
|
||||
{
|
||||
var data = [[CPData alloc] init];
|
||||
[data setString:@"CPData Test"];
|
||||
|
||||
[self assert:[data string] equals:@"CPData Test"];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,176 @@
|
||||
@import <Foundation/CPDictionary.j>
|
||||
|
||||
@implementation CPDictionaryTest : OJTestCase
|
||||
{
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
json = {
|
||||
"key1": ['1', '2', '3'],
|
||||
"key2": "This is a string",
|
||||
"key3": {
|
||||
"another": "object"
|
||||
}
|
||||
}
|
||||
|
||||
string_dict = [[CPDictionary alloc] initWithObjects:[@"1", @"2"] forKeys:[@"key1", @"key2"]];
|
||||
json_dict = [CPDictionary dictionaryWithJSObject:json recursively:YES];
|
||||
}
|
||||
|
||||
- (void)testInitWithDictionary
|
||||
{
|
||||
var dict = [[CPDictionary alloc] initWithObjects:[@"1", @"2"] forKeys:[@"key1", @"key2"]];
|
||||
|
||||
var new_dict = [[CPDictionary alloc] initWithDictionary:dict];
|
||||
[self assert:[new_dict objectForKey:@"key1"] equals:[dict objectForKey:@"key1"]];
|
||||
[self assert:[new_dict objectForKey:@"key2"] equals:[dict objectForKey:@"key2"]];
|
||||
|
||||
var new_dict_cm = [CPDictionary dictionaryWithDictionary:dict];
|
||||
[self assert:[new_dict_cm objectForKey:@"key1"] equals:[dict objectForKey:@"key1"]];
|
||||
[self assert:[new_dict_cm objectForKey:@"key2"] equals:[dict objectForKey:@"key2"]];
|
||||
}
|
||||
|
||||
- (void)testInitWithObjects
|
||||
{
|
||||
var dict = [[CPDictionary alloc] initWithObjects:[@"1", @"2"] forKeys:[@"key1", @"key2"]];
|
||||
[self assert:[dict objectForKey:@"key1"] equals:@"1"];
|
||||
[self assert:[dict objectForKey:@"key2"] equals:@"2"];
|
||||
[self assert:[dict count] equals:2];
|
||||
|
||||
var dict_cm = [CPDictionary dictionaryWithObjects:[@"1", @"2"] forKeys:[@"key1", @"key2"]];
|
||||
[self assert:[dict_cm objectForKey:@"key1"] equals:@"1"];
|
||||
[self assert:[dict_cm objectForKey:@"key2"] equals:@"2"];
|
||||
[self assert:[dict_cm count] equals:2];
|
||||
}
|
||||
|
||||
- (void)testDictionaryWithObject
|
||||
{
|
||||
var dict = [CPDictionary dictionaryWithObject:@"1" forKey:@"key1"];
|
||||
[self assert:[dict objectForKey:@"key1"] equals:@"1"];
|
||||
[self assert:[dict count] equals:1];
|
||||
}
|
||||
|
||||
- (void)testDictionaryWithJSObjectRecursive
|
||||
{
|
||||
var dict = [CPDictionary dictionaryWithJSObject:json recursively:YES];
|
||||
[self assert:[dict count] equals:3];
|
||||
[self assert:[[dict objectForKey:@"key3"] count] equals:1];
|
||||
}
|
||||
|
||||
- (void)testDictionaryWithJSObjectNonRecursive
|
||||
{
|
||||
var non_recursive_dict = [CPDictionary dictionaryWithJSObject:json recursively:NO];
|
||||
[self assertThrows:[non_recursive_dict objectForKey:@"key3"]];
|
||||
}
|
||||
|
||||
- (void)testCopy
|
||||
{
|
||||
var copy = [string_dict copy];
|
||||
[self assert:copy notSame:string_dict];
|
||||
[self assert:[copy objectForKey:@"key1"] equals:[string_dict objectForKey:@"key1"]];
|
||||
}
|
||||
|
||||
- (void)testCount
|
||||
{
|
||||
[self assert:[string_dict count] equals:2];
|
||||
[self assert:[json_dict count] equals:3];
|
||||
}
|
||||
|
||||
- (void)testAllKeys
|
||||
{
|
||||
[self assert:[string_dict allKeys] equals:[@"key2", @"key1"]];
|
||||
[self assert:[json_dict allKeys] equals:[@"key1", @"key2", @"key3"]];
|
||||
}
|
||||
|
||||
- (void)testAllValues
|
||||
{
|
||||
[self assert:[string_dict allValues] equals:[@"1", @"2"]];
|
||||
// Had to get object from key to get test passing
|
||||
[self assert:[json_dict allValues] equals:[[json_dict objectForKey:@"key3"], @"This is a string", ['1', '2', '3']]];
|
||||
}
|
||||
|
||||
- (void)testObjectForKey
|
||||
{
|
||||
[self assert:[string_dict objectForKey:@"key1"] equals:"1"];
|
||||
[self assert:[json_dict objectForKey:@"key1"] equals:['1', '2', '3']];
|
||||
}
|
||||
|
||||
- (void)testKeyEnumerator
|
||||
{
|
||||
var dict = [[CPDictionary alloc] init];
|
||||
[self assertNull:[[dict keyEnumerator] nextObject]];
|
||||
[self assertNotNull:[[dict keyEnumerator] allObjects]];
|
||||
|
||||
[self assertNotNull:[[string_dict keyEnumerator] nextObject]];
|
||||
[self assertNotNull:[[json_dict keyEnumerator] nextObject]];
|
||||
[self assertNotNull:[[string_dict keyEnumerator] allObjects]];
|
||||
[self assertNotNull:[[json_dict keyEnumerator] allObjects]];
|
||||
}
|
||||
|
||||
- (void)testObjectEnumerator
|
||||
{
|
||||
var dict = [[CPDictionary alloc] init];
|
||||
[self assertNull:[[dict objectEnumerator] nextObject]];
|
||||
[self assertNotNull:[[dict objectEnumerator] allObjects]];
|
||||
|
||||
[self assertNotNull:[[string_dict objectEnumerator] nextObject]];
|
||||
[self assertNotNull:[[json_dict objectEnumerator] nextObject]];
|
||||
[self assertNotNull:[[string_dict objectEnumerator] allObjects]];
|
||||
[self assertNotNull:[[json_dict objectEnumerator] allObjects]];
|
||||
}
|
||||
|
||||
- (void)testIsEqualToDictionary
|
||||
{
|
||||
[self assertTrue:[string_dict isEqualToDictionary:[string_dict copy]]];
|
||||
[self assertTrue:[json_dict isEqualToDictionary:[json_dict copy]]];
|
||||
[self assertFalse:[json_dict isEqualToDictionary:[string_dict copy]]];
|
||||
}
|
||||
|
||||
- (void)testRemoveAllObjects
|
||||
{
|
||||
[string_dict removeAllObjects];
|
||||
[json_dict removeAllObjects];
|
||||
[self assert:[string_dict count] equals:0];
|
||||
[self assert:[json_dict count] equals:0];
|
||||
}
|
||||
|
||||
- (void)testRemoveObjectForKey
|
||||
{
|
||||
[string_dict removeObjectForKey:@"key1"];
|
||||
[json_dict removeObjectForKey:@"key1"];
|
||||
[self assert:[string_dict count] equals:1];
|
||||
[self assert:[json_dict count] equals:2];
|
||||
[self assertThrows:[string_dict objectForKey:@"key1"]];
|
||||
[self assertThrows:[json_dict objectForKey:@"key1"]];
|
||||
}
|
||||
|
||||
- (void)testRemoveObjectsForKeys
|
||||
{
|
||||
[string_dict removeObjectsForKeys:[@"key1"]];
|
||||
[json_dict removeObjectsForKeys:[@"key1", @"key2"]];
|
||||
[self assert:[string_dict count] equals:1];
|
||||
[self assert:[json_dict count] equals:1];
|
||||
[self assertThrows:[string_dict objectForKey:@"key1"]];
|
||||
[self assertThrows:[json_dict objectForKey:@"key1"]];
|
||||
[self assertThrows:[json_dict objectForKey:@"key2"]];
|
||||
}
|
||||
|
||||
- (void)testSetObjectForKey
|
||||
{
|
||||
var dict = [[CPDictionary alloc] init];
|
||||
[dict setObject:@"setObjectForKey test" forKey:@"key1"];
|
||||
[self assert:[dict objectForKey:@"key1"] equals:@"setObjectForKey test"];
|
||||
[self assert:[dict count] equals:1];
|
||||
}
|
||||
|
||||
- (void)testAddEntriesFromDictionary
|
||||
{
|
||||
var dict = [[CPDictionary alloc] initWithObjects:[@"1", @"2"] forKeys:[@"key4", @"key5"]];
|
||||
[string_dict addEntriesFromDictionary:dict]
|
||||
[json_dict addEntriesFromDictionary:dict]
|
||||
[self assert:[string_dict count] equals:4];
|
||||
[self assert:[json_dict count] equals:5];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,4 +1,4 @@
|
||||
@import "CPURL.j"
|
||||
@import <Foundation/CPURL.j>
|
||||
|
||||
var exampleProtocol = "http",
|
||||
exampleUser = "foo",
|
||||
|
||||
Reference in new issue
Block a user