mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-20 23:35:01 +00:00
Fixed: Test cases for the new or changed delegate methods and notifications.
This commit is contained in:
1 parent
2b7be2e3f1
commit
1fe9c39dd5
1 file changed
+119
-19
+119
-19
@@ -48,26 +48,91 @@
|
||||
|
||||
- (void)testTextViewSelectionRange
|
||||
{
|
||||
//TODO : uncomment once ojtest will be up to date on travis
|
||||
var range;
|
||||
//
|
||||
//[delegateSpy selector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:) times:1 arguments:[textView, CPMakeRange(0,0), CPMakeRange(0, 18)]];
|
||||
//[delegateSpy selector:@selector(textViewDidChangeSelection:) times:1];
|
||||
//[textView selectAll:self];
|
||||
//range = [[textView selectedRanges] firstObject];
|
||||
//[self assert:0 equals:range.location];
|
||||
//[self assert:18 equals:range.length];
|
||||
// [delegateSpy verifyThatAllExpectationsHaveBeenMet];
|
||||
//
|
||||
//
|
||||
// [delegateSpy reset];
|
||||
// [delegateSpy selector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:) times:1 arguments:[textView, CPMakeRange(0, 18), CPMakeRange(3, 6)]];
|
||||
// [delegateSpy selector:@selector(textViewDidChangeSelection:) times:1];
|
||||
//[textView setSelectedRange:CPMakeRange(3, 6)];
|
||||
//range = [[textView selectedRanges] firstObject];
|
||||
//[self assert:3 equals:range.location];
|
||||
//[self assert:6 equals:range.length];
|
||||
// [delegateSpy verifyThatAllExpectationsHaveBeenMet];
|
||||
|
||||
[delegateSpy selector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:) times:1 arguments:[textView, CPMakeRange(0,0), CPMakeRange(0, 18)]];
|
||||
[delegateSpy selector:@selector(textViewDidChangeSelection:) times:1];
|
||||
[delegateSpy selector:@selector(textView:shouldChangeTypingAttributes:toAttributes:) times:1];
|
||||
[delegateSpy selector:@selector(textViewDidChangeTypingAttributes:) times:1];
|
||||
[delegateSpy selector:@selector(textDidChange:) times:0];
|
||||
[delegateSpy selector:@selector(textShouldBeginEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textDidBeginEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textShouldEndEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textDidEndEditing:) times:0];
|
||||
[textView selectAll:self];
|
||||
range = [[textView selectedRanges] firstObject];
|
||||
[self assert:0 equals:range.location];
|
||||
[self assert:18 equals:range.length];
|
||||
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
|
||||
|
||||
[delegateSpy reset];
|
||||
[delegateSpy selector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:) times:1 arguments:[textView, CPMakeRange(0, 18), CPMakeRange(3, 6)]];
|
||||
[delegateSpy selector:@selector(textViewDidChangeSelection:) times:1];
|
||||
[delegateSpy selector:@selector(textView:shouldChangeTypingAttributes:toAttributes:) times:1];
|
||||
[delegateSpy selector:@selector(textViewDidChangeTypingAttributes:) times:1];
|
||||
[delegateSpy selector:@selector(textDidChange:) times:0];
|
||||
[delegateSpy selector:@selector(textShouldBeginEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textDidBeginEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textShouldEndEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textDidEndEditing:) times:0];
|
||||
[textView setSelectedRange:CPMakeRange(3, 6)];
|
||||
range = [[textView selectedRanges] firstObject];
|
||||
[self assert:3 equals:range.location];
|
||||
[self assert:6 equals:range.length];
|
||||
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
|
||||
|
||||
// When selecting the same range again textView:shouldChangeTypingAttributes:toAttributes: or textViewDidChangeTypingAttributes: should not be triggered
|
||||
[delegateSpy reset];
|
||||
[delegateSpy selector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:) times:1 arguments:[textView, CPMakeRange(3, 6), CPMakeRange(3, 6)]];
|
||||
[delegateSpy selector:@selector(textViewDidChangeSelection:) times:1];
|
||||
[delegateSpy selector:@selector(textView:shouldChangeTypingAttributes:toAttributes:) times:0];
|
||||
[delegateSpy selector:@selector(textViewDidChangeTypingAttributes:) times:0];
|
||||
[delegateSpy selector:@selector(textDidChange:) times:0];
|
||||
[delegateSpy selector:@selector(textShouldBeginEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textDidBeginEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textShouldEndEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textDidEndEditing:) times:0];
|
||||
[textView setSelectedRange:CPMakeRange(3, 6)];
|
||||
range = [[textView selectedRanges] firstObject];
|
||||
[self assert:3 equals:range.location];
|
||||
[self assert:6 equals:range.length];
|
||||
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
|
||||
}
|
||||
|
||||
- (void)testTextDidChange
|
||||
{
|
||||
[delegateSpy selector:@selector(textDidChange:) times:1];
|
||||
[delegateSpy selector:@selector(textShouldBeginEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textDidBeginEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textShouldEndEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textDidEndEditing:) times:0];
|
||||
[textView setString:@"New text"];
|
||||
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
|
||||
}
|
||||
|
||||
- (void)testTextBeginEditing
|
||||
{
|
||||
[delegateSpy selector:@selector(textDidChange:) times:1];
|
||||
[delegateSpy selector:@selector(textShouldBeginEditing:) times:1];
|
||||
[delegateSpy selector:@selector(textDidBeginEditing:) times:1];
|
||||
[delegateSpy selector:@selector(textShouldEndEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textDidEndEditing:) times:0];
|
||||
[self assertTrue:[theWindow makeFirstResponder:textView]];
|
||||
[textView insertText:@"New text"];
|
||||
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
|
||||
}
|
||||
|
||||
- (void)testTextEndEditing
|
||||
{
|
||||
[self assertTrue:[theWindow makeFirstResponder:textView]];
|
||||
[textView insertText:@"New text"];
|
||||
[delegateSpy selector:@selector(textDidChange:) times:0];
|
||||
[delegateSpy selector:@selector(textShouldBeginEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textDidBeginEditing:) times:0];
|
||||
[delegateSpy selector:@selector(textShouldEndEditing:) times:1];
|
||||
[delegateSpy selector:@selector(textDidEndEditing:) times:1];
|
||||
[self assertFalse:[theWindow makeFirstResponder:nil]];
|
||||
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -79,9 +144,44 @@
|
||||
return newSelectedCharRange;
|
||||
}
|
||||
|
||||
- (CPDictionary)textView:(CPTextView)textView shouldChangeTypingAttributes:(CPDictionary)oldTypingAttributes toAttributes:(CPDictionary)newTypingAttributes
|
||||
{
|
||||
return newTypingAttributes;
|
||||
}
|
||||
|
||||
- (void)textViewDidChangeSelection:(CPNotification)aNotification
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)textViewDidChangeTypingAttributes:(CPNotification)aNotification
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)textDidChange:(CPNotification)aNotification
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)textShouldBeginEditing:(CPText)aTextObject
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)textDidBeginEditing:(CPNotification)aNotification
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)textShouldEndEditing:(CPText)aTextObject
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)textDidEndEditing:(CPNotification)aNotification
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user