Merge branch 'desktop' into jake

Conflicts:
	Objective-J/CommonJS/objective-j/lib-js/objective-j.js
This commit is contained in:
Francisco Ryan Tolmasky I committed 2009-10-18 17:40:13 -07:00
commit 6fc02623df
9 files changed
+228 -15

No files matched your search

+5
View File
@@ -298,6 +298,11 @@ CPRunContinuesResponse = -1002;
[CPPlatform terminateApplication];
}
- (void)activateIgnoringOtherApps:(BOOL)shouldIgnoreOtherApps
{
[CPPlatform activateIgnoringOtherApps:shouldIgnoreOtherApps];
}
/*!
Calls \c -finishLaunching method which results in starting
the main event loop.
+11 -6
View File
@@ -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];
+2
View File
@@ -1264,6 +1264,8 @@ CPTexturedBackgroundWindowMask
if (_leftMouseDownView != _firstResponder && [_leftMouseDownView acceptsFirstResponder])
[self makeFirstResponder:_leftMouseDownView];
[CPApp activateIgnoringOtherApps:YES];
var theWindow = [anEvent window];
if ([theWindow isKeyWindow] || [theWindow becomesKeyOnlyIfNeeded])
+8
View File
@@ -45,4 +45,12 @@
window.cpTerminate();
}
+ (void)activateIgnoringOtherApps:(BOOL)shouldIgnoreOtherApps
{
#if PLATFORM(DOM)
if (typeof window["cpActivateIgnoringOtherApps"] === "function")
window.cpActivateIgnoringOtherApps(!!shouldIgnoreOtherApps);
#endif
}
@end
@@ -135,7 +135,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)
@@ -155,7 +155,7 @@ var objj_preprocess_sync = function(code, path)
// FIXME: Why does this need to be global?
// synchronously perform an import
global.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));
+1 -1
View File
@@ -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)
+22 -5
View File
@@ -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
+176
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
@import "CPURL.j"
@import <Foundation/CPURL.j>
var exampleProtocol = "http",
exampleUser = "foo",