mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 13:07:02 +00:00
77 lines
2.5 KiB
Plaintext
77 lines
2.5 KiB
Plaintext
|
|
@import <AppKit/CPView.j>
|
|
@import <AppKit/CPApplication.j>
|
|
|
|
[CPApplication sharedApplication]
|
|
|
|
@implementation CPViewTest : OJTestCase
|
|
{
|
|
CPView view;
|
|
}
|
|
|
|
- (void)setUp
|
|
{
|
|
view = [[CPView alloc] initWithFrame:CGRectMakeZero()];
|
|
[super setUp];
|
|
}
|
|
|
|
- (void)testCanCreate
|
|
{
|
|
[self assertTrue:!!view];
|
|
}
|
|
|
|
/*
|
|
During the layout process for the view, _CPImageAndTextView.j throws
|
|
a ReferenceError with the following:
|
|
|
|
"hasDOMImageElement" is not defined
|
|
|
|
The referenced variable is #if PLATFORM(DOM) excluded in all other
|
|
instances. While not isolated to the behaviour of a CPView alone, the
|
|
following test ensures that pending actions in the _CPDisplayServer can
|
|
be flushed without touching unimplemented portions of the test platform
|
|
(e.g. the DOM). There are times where we want to confirm that some setting
|
|
requiring relayout (e.g. string truncation based on available space), the
|
|
following test should help ensure those types of tests are safe to carry
|
|
out with ojunit.
|
|
|
|
Demonstrates issue #562.
|
|
*/
|
|
- (void)testCanFlushPendingLayoutWork
|
|
{
|
|
[self assert:undefined same:[_CPDisplayServer run]];
|
|
}
|
|
|
|
- (void)testThemeState
|
|
{
|
|
[self assertTrue:[view hasThemeState:CPThemeStateNormal] message:@"CPView should initialy have CPThemeStateNormal"];
|
|
[self assertFalse:[view hasThemeState:CPThemeStateDisabled] message:@"view should be disabled"];
|
|
|
|
[view setThemeState:CPThemeStateDisabled];
|
|
[self assertTrue:[view hasThemeState:CPThemeStateDisabled] message:@"The view should be CPThemeStateDisabled"];
|
|
|
|
[view setThemeState:CPThemeStateHighlighted];
|
|
[self assertTrue:[view hasThemeState:CPThemeStateHighlighted] message:@"Theme state should be CPThemeStateHighlighted"];
|
|
|
|
[view setThemeState:CPThemeStateNormal | CPThemeStateHighlighted];
|
|
[self assertFalse:[view hasThemeState:CPThemeStateNormal] message:@"CPThemeStateNormal cannot exist as part of a compound state"];
|
|
[self assertTrue:[view hasThemeState:CPThemeStateHighlighted] message:@"The view should be CPThemeStateHighlighted"];
|
|
}
|
|
|
|
- (void)testThemeAttributes
|
|
{
|
|
var attributes = [CPView themeAttributes];
|
|
|
|
if (attributes)
|
|
{
|
|
var keys = [attributes allKeys],
|
|
firstKey = [keys objectAtIndex:0];
|
|
|
|
[self assertTrue:[view hasThemeAttribute:[firstKey]] message:[view className] + " should have the theme attribute \"" + firstKey + "\""];
|
|
}
|
|
|
|
[self assertFalse:[view hasThemeAttribute:@"foobar"] message:[view className] + " should not have theme attribute \"" + firstKey + "\""];
|
|
}
|
|
|
|
@end
|