mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-14 14:41:28 +00:00
Lint.
This commit is contained in:
@@ -432,7 +432,8 @@ var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
var transformOrigin = "50% 100%",
|
||||
frame = [self frame],
|
||||
preferredEdge = [_windowView preferredEdge],
|
||||
posX, posY;
|
||||
posX,
|
||||
posY;
|
||||
|
||||
switch (preferredEdge)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
@import "_CGGeometry.j"
|
||||
|
||||
|
||||
CPMinXEdge = 0;
|
||||
CPMinYEdge = 1;
|
||||
CPMaxXEdge = 2;
|
||||
|
||||
@@ -100,71 +100,70 @@
|
||||
- (void)testAffineTransformConcat
|
||||
{
|
||||
var testcases = {
|
||||
"identity concat" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeIdentity(),
|
||||
CGAffineTransformMakeIdentity()),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
"identity concat" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeIdentity(),
|
||||
CGAffineTransformMakeIdentity()),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
|
||||
"translation" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeTranslation(3, 4),
|
||||
CGAffineTransformMakeTranslation(-3, -4)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
"translation" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeTranslation(3, 4),
|
||||
CGAffineTransformMakeTranslation(-3, -4)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
|
||||
"translation (reversed)" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeTranslation(-3, -4),
|
||||
CGAffineTransformMakeTranslation(3, 4)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
"translation (reversed)" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeTranslation(-3, -4),
|
||||
CGAffineTransformMakeTranslation(3, 4)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
|
||||
"scale" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeScale(3, 4),
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
"scale" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeScale(3, 4),
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
|
||||
"scale (reversed)" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeScale(1 / 3, 1 / 4),
|
||||
CGAffineTransformMakeScale(3, 4)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
"scale (reversed)" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeScale(1 / 3, 1 / 4),
|
||||
CGAffineTransformMakeScale(3, 4)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeRotation(PI),
|
||||
CGAffineTransformMakeRotation(-PI)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
};
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeRotation(PI),
|
||||
CGAffineTransformMakeRotation(-PI)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
};
|
||||
|
||||
for ( var key in testcases )
|
||||
for (var key in testcases)
|
||||
[self compareTransform:testcases[key].testdata with:testcases[key].expdata message:key];
|
||||
}
|
||||
|
||||
- (void)testPointApplyAffineTransform
|
||||
{
|
||||
var testcases = {
|
||||
"translate to zero" : {
|
||||
testdata: CGPointApplyAffineTransform(CGPointMake(3, 4),
|
||||
CGAffineTransformMakeTranslation(-3, -4)),
|
||||
expdata: CGPointMakeZero()
|
||||
},
|
||||
"translate to zero" : {
|
||||
testdata: CGPointApplyAffineTransform(CGPointMake(3, 4),
|
||||
CGAffineTransformMakeTranslation(-3, -4)),
|
||||
expdata: CGPointMakeZero()
|
||||
},
|
||||
|
||||
"scale to 1,1" : {
|
||||
testdata: CGPointApplyAffineTransform(CGPointMake(3, 4),
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4)),
|
||||
expdata: CGPointMake(1, 1)
|
||||
},
|
||||
"scale to 1,1" : {
|
||||
testdata: CGPointApplyAffineTransform(CGPointMake(3, 4),
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4)),
|
||||
expdata: CGPointMake(1, 1)
|
||||
},
|
||||
|
||||
"scale and translate to zero" : {
|
||||
testdata: CGPointApplyAffineTransform(CGPointMake(3, 4),
|
||||
CGAffineTransformConcat(
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4),
|
||||
CGAffineTransformMakeTranslation(-1, -1))),
|
||||
expdata: CGPointMakeZero()
|
||||
|
||||
},
|
||||
};
|
||||
"scale and translate to zero" : {
|
||||
testdata: CGPointApplyAffineTransform(CGPointMake(3, 4),
|
||||
CGAffineTransformConcat(
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4),
|
||||
CGAffineTransformMakeTranslation(-1, -1))),
|
||||
expdata: CGPointMakeZero()
|
||||
},
|
||||
};
|
||||
|
||||
for (var key in testcases)
|
||||
[self comparePoint:testcases[key].testdata with:testcases[key].expdata message:key];
|
||||
@@ -173,74 +172,73 @@
|
||||
- (void)testSizeApplyAffineTransform
|
||||
{
|
||||
var testcases = {
|
||||
"translation on size should do nothing" : {
|
||||
testdata: CGSizeApplyAffineTransform(CGSizeMake(3, 12),
|
||||
CGAffineTransformMakeTranslation(-3, -4)),
|
||||
expdata: CGSizeMake(3, 12)
|
||||
},
|
||||
"translation on size should do nothing" : {
|
||||
testdata: CGSizeApplyAffineTransform(CGSizeMake(3, 12),
|
||||
CGAffineTransformMakeTranslation(-3, -4)),
|
||||
expdata: CGSizeMake(3, 12)
|
||||
},
|
||||
|
||||
"scale to 1,1" : {
|
||||
testdata: CGSizeApplyAffineTransform(CGSizeMake(3, 4),
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4) ),
|
||||
expdata: CGSizeMake(1, 1)
|
||||
},
|
||||
"scale to 1,1" : {
|
||||
testdata: CGSizeApplyAffineTransform(CGSizeMake(3, 4),
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4) ),
|
||||
expdata: CGSizeMake(1, 1)
|
||||
},
|
||||
|
||||
"scale and translate combined" : {
|
||||
testdata: CGSizeApplyAffineTransform(CGSizeMake(3, 4),
|
||||
CGAffineTransformConcat(
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4),
|
||||
CGAffineTransformMakeTranslation(-1, -1))),
|
||||
expdata: CGSizeMake(1, 1)
|
||||
"scale and translate combined" : {
|
||||
testdata: CGSizeApplyAffineTransform(CGSizeMake(3, 4),
|
||||
CGAffineTransformConcat(
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4),
|
||||
CGAffineTransformMakeTranslation(-1, -1))),
|
||||
expdata: CGSizeMake(1, 1)
|
||||
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
for ( var key in testcases )
|
||||
for (var key in testcases)
|
||||
[self compareSize:testcases[key].testdata with:testcases[key].expdata message:key];
|
||||
}
|
||||
|
||||
- (void)testAffineTransformIsIdentityPositive
|
||||
{
|
||||
var testcases = {
|
||||
"identity is identity" : {
|
||||
testdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
var testcases = {
|
||||
"identity is identity" : {
|
||||
testdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
|
||||
"zero rotation is identity" : {
|
||||
testdata: CGAffineTransformMakeRotation(0),
|
||||
},
|
||||
"zero rotation is identity" : {
|
||||
testdata: CGAffineTransformMakeRotation(0),
|
||||
},
|
||||
|
||||
"zero translation is identity" : {
|
||||
testdata: CGAffineTransformMakeTranslation(0,0)
|
||||
},
|
||||
"zero translation is identity" : {
|
||||
testdata: CGAffineTransformMakeTranslation(0,0)
|
||||
},
|
||||
|
||||
"one scale is identity" : {
|
||||
testdata: CGAffineTransformMakeScale(1, 1)
|
||||
},
|
||||
"one scale is identity" : {
|
||||
testdata: CGAffineTransformMakeScale(1, 1)
|
||||
},
|
||||
|
||||
"identity concat'ed" : {
|
||||
testdata: CGAffineTransformConcat( CGAffineTransformMakeIdentity(),
|
||||
CGAffineTransformMakeIdentity() ),
|
||||
},
|
||||
"identity concat'ed" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeIdentity(),
|
||||
CGAffineTransformMakeIdentity()),
|
||||
},
|
||||
|
||||
"translation" : {
|
||||
testdata: CGAffineTransformConcat( CGAffineTransformMakeTranslation(3, 4),
|
||||
CGAffineTransformMakeTranslation(-3, -4) ),
|
||||
},
|
||||
"translation" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeTranslation(3, 4),
|
||||
CGAffineTransformMakeTranslation(-3, -4)),
|
||||
},
|
||||
|
||||
"scale" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeScale(3, 4),
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4)),
|
||||
},
|
||||
"scale" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeScale(3, 4),
|
||||
CGAffineTransformMakeScale(1 / 3, 1 / 4)),
|
||||
},
|
||||
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeRotation(-PI),
|
||||
CGAffineTransformMakeRotation(PI)),
|
||||
},
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeRotation(-PI),
|
||||
CGAffineTransformMakeRotation(PI)),
|
||||
},
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
for ( var key in testcases )
|
||||
for (var key in testcases)
|
||||
[self assert:YES
|
||||
equals:CGAffineTransformIsIdentity(testcases[key].testdata)
|
||||
message:key];
|
||||
@@ -249,30 +247,29 @@
|
||||
- (void)testAffineTransformIsIdentityNegative
|
||||
{
|
||||
var testcases = {
|
||||
"some random transform" : {
|
||||
testdata: CGAffineTransformMake(1, 1, 1, 1, 1, 1)
|
||||
},
|
||||
"some random transform" : {
|
||||
testdata: CGAffineTransformMake(1, 1, 1, 1, 1, 1)
|
||||
},
|
||||
|
||||
"non-zero translation is not identity" : {
|
||||
testdata: CGAffineTransformMakeTranslation(1, 1)
|
||||
},
|
||||
"non-zero translation is not identity" : {
|
||||
testdata: CGAffineTransformMakeTranslation(1, 1)
|
||||
},
|
||||
|
||||
"non-one scale is not identity" : {
|
||||
testdata: CGAffineTransformMakeScale(2,2)
|
||||
},
|
||||
"non-one scale is not identity" : {
|
||||
testdata: CGAffineTransformMakeScale(2,2)
|
||||
},
|
||||
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformMakeRotation(PI),
|
||||
},
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformMakeRotation(PI),
|
||||
},
|
||||
|
||||
// TODO a two-pi rotation is actually identity
|
||||
"2PI rotation is NOT identity?" : {
|
||||
testdata: CGAffineTransformMakeRotation(PI * 2),
|
||||
},
|
||||
// TODO a two-pi rotation is actually identity
|
||||
"2PI rotation is NOT identity?" : {
|
||||
testdata: CGAffineTransformMakeRotation(PI * 2),
|
||||
},
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
for ( var key in testcases )
|
||||
for (var key in testcases)
|
||||
[self assert:NO
|
||||
equals:CGAffineTransformIsIdentity(testcases[key].testdata)
|
||||
message:key];
|
||||
@@ -281,38 +278,38 @@
|
||||
- (void)testAffineTransformEqualToTransform
|
||||
{
|
||||
var testcases = {
|
||||
"identity" : {
|
||||
lhs: CGAffineTransformMakeIdentity(),
|
||||
rhs: CGAffineTransformMakeIdentity(),
|
||||
expdata: YES
|
||||
},
|
||||
"identity" : {
|
||||
lhs: CGAffineTransformMakeIdentity(),
|
||||
rhs: CGAffineTransformMakeIdentity(),
|
||||
expdata: YES
|
||||
},
|
||||
|
||||
"translate" : {
|
||||
lhs: CGAffineTransformMakeTranslation(1, 1),
|
||||
rhs: CGAffineTransformMakeTranslation(1, 1),
|
||||
expdata: YES
|
||||
},
|
||||
"translate" : {
|
||||
lhs: CGAffineTransformMakeTranslation(1, 1),
|
||||
rhs: CGAffineTransformMakeTranslation(1, 1),
|
||||
expdata: YES
|
||||
},
|
||||
|
||||
"scale" : {
|
||||
lhs: CGAffineTransformMakeScale(1, 1),
|
||||
rhs: CGAffineTransformMakeScale(1, 1),
|
||||
expdata: YES
|
||||
},
|
||||
"scale" : {
|
||||
lhs: CGAffineTransformMakeScale(1, 1),
|
||||
rhs: CGAffineTransformMakeScale(1, 1),
|
||||
expdata: YES
|
||||
},
|
||||
|
||||
"rotation" : {
|
||||
lhs: CGAffineTransformMakeRotation(PI),
|
||||
rhs: CGAffineTransformMakeRotation(PI),
|
||||
expdata: YES
|
||||
},
|
||||
"rotation" : {
|
||||
lhs: CGAffineTransformMakeRotation(PI),
|
||||
rhs: CGAffineTransformMakeRotation(PI),
|
||||
expdata: YES
|
||||
},
|
||||
|
||||
"translate and scale" : {
|
||||
lhs: CGAffineTransformMakeScale(1, 1),
|
||||
rhs: CGAffineTransformMakeTranslation(1, 1),
|
||||
expdata: NO
|
||||
},
|
||||
};
|
||||
"translate and scale" : {
|
||||
lhs: CGAffineTransformMakeScale(1, 1),
|
||||
rhs: CGAffineTransformMakeTranslation(1, 1),
|
||||
expdata: NO
|
||||
},
|
||||
};
|
||||
|
||||
for ( var key in testcases )
|
||||
for (var key in testcases)
|
||||
[self assert:testcases[key].expdata
|
||||
equals:CGAffineTransformEqualToTransform(testcases[key].lhs, testcases[key].rhs)
|
||||
message:key];
|
||||
@@ -322,28 +319,28 @@
|
||||
{
|
||||
// FIXME?: should there be a leading space on these strings
|
||||
var testcases = {
|
||||
"identity" : {
|
||||
testdata: CGAffineTransformMakeIdentity(),
|
||||
expdata: " [[ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1]]"
|
||||
},
|
||||
"identity" : {
|
||||
testdata: CGAffineTransformMakeIdentity(),
|
||||
expdata: " [[ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1]]"
|
||||
},
|
||||
|
||||
"scale" : {
|
||||
testdata: CGAffineTransformMakeScale(3, 4),
|
||||
expdata: " [[ 3, 0, 0 ], [ 0, 4, 0 ], [ 0, 0, 1]]"
|
||||
},
|
||||
"scale" : {
|
||||
testdata: CGAffineTransformMakeScale(3, 4),
|
||||
expdata: " [[ 3, 0, 0 ], [ 0, 4, 0 ], [ 0, 0, 1]]"
|
||||
},
|
||||
|
||||
"translation" : {
|
||||
testdata: CGAffineTransformMakeTranslation(3, 4),
|
||||
expdata: " [[ 1, 0, 0 ], [ 0, 1, 0 ], [ 3, 4, 1]]"
|
||||
},
|
||||
"translation" : {
|
||||
testdata: CGAffineTransformMakeTranslation(3, 4),
|
||||
expdata: " [[ 1, 0, 0 ], [ 0, 1, 0 ], [ 3, 4, 1]]"
|
||||
},
|
||||
|
||||
"scale and translation" : {
|
||||
testdata: CGAffineTransformTranslate(CGAffineTransformMakeScale(3, 4), 5, 6),
|
||||
expdata: " [[ 3, 0, 0 ], [ 0, 4, 0 ], [ 15, 24, 1]]"
|
||||
},
|
||||
};
|
||||
"scale and translation" : {
|
||||
testdata: CGAffineTransformTranslate(CGAffineTransformMakeScale(3, 4), 5, 6),
|
||||
expdata: " [[ 3, 0, 0 ], [ 0, 4, 0 ], [ 15, 24, 1]]"
|
||||
},
|
||||
};
|
||||
|
||||
for ( var key in testcases )
|
||||
for (var key in testcases)
|
||||
[self assert:testcases[key].expdata
|
||||
equals:CGStringCreateWithCGAffineTransform(testcases[key].testdata)
|
||||
message:key];
|
||||
@@ -352,48 +349,48 @@
|
||||
- (void)testStringFromCGAffineTransform
|
||||
{
|
||||
var testcases = {
|
||||
"identity" : {
|
||||
testdata: CGAffineTransformMakeIdentity(),
|
||||
expdata: "{1, 0, 0, 1, 0, 0}"
|
||||
},
|
||||
"identity" : {
|
||||
testdata: CGAffineTransformMakeIdentity(),
|
||||
expdata: "{1, 0, 0, 1, 0, 0}"
|
||||
},
|
||||
|
||||
"scale" : {
|
||||
testdata: CGAffineTransformMakeScale(3, 4),
|
||||
expdata: "{3, 0, 0, 4, 0, 0}"
|
||||
},
|
||||
"scale" : {
|
||||
testdata: CGAffineTransformMakeScale(3, 4),
|
||||
expdata: "{3, 0, 0, 4, 0, 0}"
|
||||
},
|
||||
|
||||
"translation" : {
|
||||
testdata: CGAffineTransformMakeTranslation(3, 4),
|
||||
expdata: "{1, 0, 0, 1, 3, 4}"
|
||||
},
|
||||
"translation" : {
|
||||
testdata: CGAffineTransformMakeTranslation(3, 4),
|
||||
expdata: "{1, 0, 0, 1, 3, 4}"
|
||||
},
|
||||
|
||||
"rotation - zero" : {
|
||||
testdata: CGAffineTransformMakeRotation(0),
|
||||
expdata: "{1, 0, 0, 1, 0, 0}"
|
||||
},
|
||||
"rotation - zero" : {
|
||||
testdata: CGAffineTransformMakeRotation(0),
|
||||
expdata: "{1, 0, 0, 1, 0, 0}"
|
||||
},
|
||||
|
||||
"rotation - pi" : {
|
||||
testdata: CGAffineTransformMakeRotation(PI),
|
||||
expdata: "{-1, 1.2246467991473532e-16, -1.2246467991473532e-16, -1, 0, 0}"
|
||||
},
|
||||
"rotation - pi" : {
|
||||
testdata: CGAffineTransformMakeRotation(PI),
|
||||
expdata: "{-1, 1.2246467991473532e-16, -1.2246467991473532e-16, -1, 0, 0}"
|
||||
},
|
||||
|
||||
"rotation - 2pi" : {
|
||||
testdata: CGAffineTransformMakeRotation(2 * PI),
|
||||
expdata: "{1, -2.4492935982947064e-16, 2.4492935982947064e-16, 1, 0, 0}"
|
||||
},
|
||||
"rotation - 2pi" : {
|
||||
testdata: CGAffineTransformMakeRotation(2 * PI),
|
||||
expdata: "{1, -2.4492935982947064e-16, 2.4492935982947064e-16, 1, 0, 0}"
|
||||
},
|
||||
|
||||
"rotation - 3pi" : {
|
||||
testdata: CGAffineTransformMakeRotation(3 * PI),
|
||||
expdata: "{-1, 3.6739403974420594e-16, -3.6739403974420594e-16, -1, 0, 0}"
|
||||
},
|
||||
"rotation - 3pi" : {
|
||||
testdata: CGAffineTransformMakeRotation(3 * PI),
|
||||
expdata: "{-1, 3.6739403974420594e-16, -3.6739403974420594e-16, -1, 0, 0}"
|
||||
},
|
||||
|
||||
"scale and translation and rotate" : {
|
||||
testdata: CGAffineTransformRotate(CGAffineTransformTranslate(CGAffineTransformMakeScale(3, 4), 5, 6), PI),
|
||||
expdata: "{-3, 4.898587196589413e-16, -3.6739403974420594e-16, -4, 15, 24}"
|
||||
},
|
||||
};
|
||||
"scale and translation and rotate" : {
|
||||
testdata: CGAffineTransformRotate(CGAffineTransformTranslate(CGAffineTransformMakeScale(3, 4), 5, 6), PI),
|
||||
expdata: "{-3, 4.898587196589413e-16, -3.6739403974420594e-16, -4, 15, 24}"
|
||||
},
|
||||
};
|
||||
|
||||
for ( var key in testcases )
|
||||
for (var key in testcases)
|
||||
[self assert:testcases[key].expdata
|
||||
equals:CPStringFromCGAffineTransform(testcases[key].testdata)
|
||||
message:key];
|
||||
@@ -407,20 +404,20 @@
|
||||
sin = SIN(ang);
|
||||
|
||||
var testcases = {
|
||||
"affine transform rotate failed" : {
|
||||
testdata: CGAffineTransformRotate(transform, ang),
|
||||
expdata: CGAffineTransformMake( transform.a * cos + transform.c * sin,
|
||||
transform.b * cos + transform.d * sin,
|
||||
transform.c * cos - transform.a * sin,
|
||||
transform.d * cos - transform.b * sin,
|
||||
transform.tx,transform.ty )
|
||||
},
|
||||
"affine transform rotate failed" : {
|
||||
testdata: CGAffineTransformRotate(transform, ang),
|
||||
expdata: CGAffineTransformMake(transform.a * cos + transform.c * sin,
|
||||
transform.b * cos + transform.d * sin,
|
||||
transform.c * cos - transform.a * sin,
|
||||
transform.d * cos - transform.b * sin,
|
||||
transform.tx,transform.ty)
|
||||
},
|
||||
|
||||
"rotation negation" : {
|
||||
testdata: CGAffineTransformRotate(CGAffineTransformRotate(CGAffineTransformMakeScale(3, 4), PI), -PI),
|
||||
expdata: CGAffineTransformMakeScale(3, 4)
|
||||
}
|
||||
};
|
||||
"rotation negation" : {
|
||||
testdata: CGAffineTransformRotate(CGAffineTransformRotate(CGAffineTransformMakeScale(3, 4), PI), -PI),
|
||||
expdata: CGAffineTransformMakeScale(3, 4)
|
||||
}
|
||||
};
|
||||
|
||||
for (var key in testcases)
|
||||
[self compareTransform:testcases[key].testdata with:testcases[key].expdata message:key];
|
||||
@@ -440,33 +437,33 @@
|
||||
transform.a * transform.ty));
|
||||
|
||||
var testcases = {
|
||||
"test invert algorithm" : {
|
||||
testdata: transform,
|
||||
expdata: invertedtransform
|
||||
},
|
||||
"test invert algorithm" : {
|
||||
testdata: transform,
|
||||
expdata: invertedtransform
|
||||
},
|
||||
|
||||
"identity should be it self on inversion" : {
|
||||
testdata: CGAffineTransformMakeIdentity(),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
"identity should be it self on inversion" : {
|
||||
testdata: CGAffineTransformMakeIdentity(),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformMakeRotation(-PI),
|
||||
expdata: CGAffineTransformMakeRotation(PI),
|
||||
},
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformMakeRotation(-PI),
|
||||
expdata: CGAffineTransformMakeRotation(PI),
|
||||
},
|
||||
|
||||
"translation" : {
|
||||
testdata: CGAffineTransformMakeTranslation(4, 5),
|
||||
expdata: CGAffineTransformMakeTranslation(-4, -5)
|
||||
},
|
||||
"translation" : {
|
||||
testdata: CGAffineTransformMakeTranslation(4, 5),
|
||||
expdata: CGAffineTransformMakeTranslation(-4, -5)
|
||||
},
|
||||
|
||||
"scale" : {
|
||||
testdata: CGAffineTransformMakeScale(3, 4),
|
||||
expdata: CGAffineTransformMakeScale(1 / 3, 1 / 4)
|
||||
},
|
||||
};
|
||||
"scale" : {
|
||||
testdata: CGAffineTransformMakeScale(3, 4),
|
||||
expdata: CGAffineTransformMakeScale(1 / 3, 1 / 4)
|
||||
},
|
||||
};
|
||||
|
||||
for ( var key in testcases )
|
||||
for (var key in testcases)
|
||||
[self compareTransform:CGAffineTransformInvert(testcases[key].testdata)
|
||||
with:testcases[key].expdata
|
||||
message:key];
|
||||
@@ -474,35 +471,34 @@
|
||||
|
||||
- (void)testRectApplyAffineTransform
|
||||
{
|
||||
var rect = CGRectMake( 3,4,5,6 );
|
||||
var rect = CGRectMake(3, 4, 5, 6),
|
||||
testcases = {
|
||||
"identity does nothing" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformMakeIdentity() ),
|
||||
expdata: rect
|
||||
},
|
||||
|
||||
var testcases = {
|
||||
"identity does nothing" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformMakeIdentity() ),
|
||||
expdata: rect
|
||||
},
|
||||
"rotation 90 degrees" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformMakeRotation(PI / 2)),
|
||||
expdata: CGRectMake(-10, 3.0000000000000004, 6, 5)
|
||||
},
|
||||
|
||||
"rotation 90 degrees" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformMakeRotation(PI/2)),
|
||||
expdata: CGRectMake(-10, 3.0000000000000004, 6, 5)
|
||||
},
|
||||
"translation" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformMakeTranslation(3, 4)),
|
||||
expdata: CGRectMake(6, 8, 5, 6)
|
||||
},
|
||||
|
||||
"translation" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformMakeTranslation(3, 4)),
|
||||
expdata: CGRectMake(6, 8, 5, 6)
|
||||
},
|
||||
"scale" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformMakeScale(1, 4)),
|
||||
expdata: CGRectMake(3, 16, 5, 24)
|
||||
},
|
||||
|
||||
"scale" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformMakeScale(1,4)),
|
||||
expdata: CGRectMake(3, 16, 5, 24)
|
||||
},
|
||||
|
||||
"rotate, translate and scale" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformRotate(CGAffineTransformTranslate(CGAffineTransformMakeScale(3, 4),5,6), PI)),
|
||||
expdata: CGRectMake(-9.000000000000004, -16,
|
||||
15.000000000000002, 24.000000000000004)
|
||||
},
|
||||
};
|
||||
"rotate, translate and scale" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformRotate(CGAffineTransformTranslate(CGAffineTransformMakeScale(3, 4),5,6), PI)),
|
||||
expdata: CGRectMake(-9.000000000000004, -16,
|
||||
15.000000000000002, 24.000000000000004)
|
||||
},
|
||||
};
|
||||
|
||||
for (var key in testcases)
|
||||
[self compareRect:testcases[key].testdata with:testcases[key].expdata message:key];
|
||||
|
||||
+25
-26
@@ -4,15 +4,15 @@
|
||||
|
||||
- (void)testColorCreateReturnNullIfNull
|
||||
{
|
||||
[self assert:NULL equals:CGColorCreate( NULL, [1,2,3] ) message:"colorspace null failed"];
|
||||
[self assert:NULL
|
||||
equals:CGColorCreate( CGColorSpaceCreateDeviceRGB(), NULL )
|
||||
[self assert:NULL equals:CGColorCreate(NULL, [1, 2, 3]) message:"colorspace null failed"];
|
||||
[self assert:NULL
|
||||
equals:CGColorCreate(CGColorSpaceCreateDeviceRGB(), NULL)
|
||||
message:"components null failed"];
|
||||
}
|
||||
|
||||
- (void)testColorCreateEnsureComponentsAreCopied
|
||||
{
|
||||
var colorspace = CGColorSpaceCreateDeviceRGB(),
|
||||
var colorspace = CGColorSpaceCreateDeviceRGB(),
|
||||
components = [2,3,4,5],
|
||||
clr = CGColorCreate(colorspace, components);
|
||||
|
||||
@@ -26,24 +26,24 @@
|
||||
var clr = CGColorCreate(CGColorSpaceCreateDeviceRGB(), [0.4, 0.3, 0.2, 0.2]),
|
||||
newclr = CGColorCreate(CGColorSpaceCreateDeviceRGB(), [0.4, 0.3, 0.2, 0.2]);
|
||||
newclr.components[newclr.components.length - 1] = 0.6;
|
||||
[self assert:0.6 equals:clr.components[clr.components.length-1]];
|
||||
[self assert:0.6 equals:clr.components[clr.components.length - 1]];
|
||||
}
|
||||
|
||||
- (void)testColorCreate
|
||||
{
|
||||
var colorspace = CGColorSpaceCreateDeviceRGB(),
|
||||
var colorspace = CGColorSpaceCreateDeviceRGB(),
|
||||
components = [2,3,4,5],
|
||||
clruid = CFHashCode(colorspace) + components.join("");
|
||||
|
||||
// Can't access the colormap cache, but it would be nice to
|
||||
// Can't access the colormap cache, but it would be nice to
|
||||
// [self assert:NULL equals:_CGColorMap[clruid]];
|
||||
|
||||
var clr = CGColorCreate( colorspace, components );
|
||||
var clr = CGColorCreate(colorspace, components);
|
||||
[self assert:colorspace equals:clr.colorspace message:"colorspace failed"];
|
||||
[self assert:[1,1,1,1] equals:clr.components message:"components failed"];
|
||||
[self assert:NULL equals:clr.pattern message:"pattern failed"];
|
||||
|
||||
// Can't access the colormap cache, but it would be nice to
|
||||
// Can't access the colormap cache, but it would be nice to
|
||||
// [self assert:clr equals:_CGColorMap[clruid]];
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@
|
||||
{
|
||||
// it returns it's argument, a little artifical but will fail if something
|
||||
// changes with the function.
|
||||
[self assert:"banana" equals:CGColorCreateCopy( "banana" )];
|
||||
[self assert:"banana" equals:CGColorCreateCopy("banana")];
|
||||
|
||||
var colorspace = CGColorSpaceCreateDeviceRGB(),
|
||||
components = [2,3,4,5],
|
||||
var colorspace = CGColorSpaceCreateDeviceRGB(),
|
||||
components = [2, 3, 4, 5],
|
||||
clr = CGColorCreate( colorspace, components );
|
||||
[self assert:clr equals:CGColorCreateCopy(clr)];
|
||||
}
|
||||
@@ -62,9 +62,9 @@
|
||||
- (void)testColorCreateGenericGray
|
||||
{
|
||||
var clr = CGColorCreateGenericGray(0.3, 0.5);
|
||||
[self assert:CGColorSpaceCreateDeviceRGB()
|
||||
[self assert:CGColorSpaceCreateDeviceRGB()
|
||||
equals:clr.colorspace message:"colorspace failed"];
|
||||
[self assert:[ROUND(0.3*255)/255,ROUND(0.3*255)/255,ROUND(0.3*255)/255,0.5]
|
||||
[self assert:[ROUND(0.3 * 255) / 255, ROUND(0.3 * 255) / 255, ROUND(0.3 * 255) / 255, 0.5]
|
||||
equals:clr.components message:"components failed"];
|
||||
[self assert:NULL equals:clr.pattern message:"pattern failed"];
|
||||
}
|
||||
@@ -72,9 +72,9 @@
|
||||
- (void)testColorCreateGenericRGB
|
||||
{
|
||||
var clr = CGColorCreateGenericRGB(0.4,0.3,0.2,0.1);
|
||||
[self assert:CGColorSpaceCreateDeviceRGB()
|
||||
[self assert:CGColorSpaceCreateDeviceRGB()
|
||||
equals:clr.colorspace message:"colorspace failed"];
|
||||
[self assert:[ROUND(0.4*255)/255,ROUND(0.3*255)/255,ROUND(0.2*255)/255,0.1]
|
||||
[self assert:[ROUND(0.4 * 255) / 255, ROUND(0.3 * 255) / 255,ROUND(0.2 * 255) / 255, 0.1]
|
||||
equals:clr.components message:"components failed"];
|
||||
[self assert:NULL equals:clr.pattern message:"pattern failed"];
|
||||
}
|
||||
@@ -84,8 +84,7 @@
|
||||
var clr = CGColorCreateGenericCMYK(0.2, 0.3, 0.4, 0.5, 0.6)
|
||||
[self assert:CGColorSpaceCreateDeviceCMYK()
|
||||
equals:clr.colorspace message:"colorspace failed"];
|
||||
[self assert:[ROUND(0.2*255)/255,ROUND(0.3*255)/255,ROUND(0.4*255)/255,
|
||||
ROUND(0.5*255)/255, 0.6]
|
||||
[self assert:[ROUND(0.2 * 255) / 255,ROUND(0.3 * 255) / 255,ROUND(0.4 * 255) / 255, ROUND(0.5 * 255) / 255, 0.6]
|
||||
equals:clr.components message:"components failed"];
|
||||
[self assert:NULL equals:clr.pattern message:"pattern failed"];
|
||||
}
|
||||
@@ -107,9 +106,9 @@
|
||||
|
||||
// ensure that null is returned
|
||||
[self assert:NULL equals:CGColorCreateWithPattern(NULL, "a new pattern", [])];
|
||||
[self assert:NULL equals:CGColorCreateWithPattern(CGColorSpaceCreateDeviceRGB(),
|
||||
[self assert:NULL equals:CGColorCreateWithPattern(CGColorSpaceCreateDeviceRGB(),
|
||||
NULL, [])];
|
||||
[self assert:NULL equals:CGColorCreateWithPattern(CGColorSpaceCreateDeviceRGB(),
|
||||
[self assert:NULL equals:CGColorCreateWithPattern(CGColorSpaceCreateDeviceRGB(),
|
||||
"a new pattern", NULL)];
|
||||
[self assert:NULL equals:CGColorCreateWithPattern(NULL, NULL, NULL)];
|
||||
}
|
||||
@@ -130,8 +129,8 @@
|
||||
- (void)testColorGetComponents
|
||||
{
|
||||
var clr = CGColorCreateGenericCMYK(0.2, 0.3, 0.4, 0.5, 0.6);
|
||||
[self assert:[ROUND(0.2*255)/255, ROUND(0.3*255)/255, ROUND(0.4*255)/255,
|
||||
ROUND(0.5*255)/255, ROUND(0.6*255)/255]
|
||||
[self assert:[ROUND(0.2 * 255) / 255, ROUND(0.3 * 255) / 255, ROUND(0.4 * 255) / 255,
|
||||
ROUND(0.5 * 255) / 255, ROUND(0.6 * 255) / 255]
|
||||
equals:CGColorGetComponents(clr)];
|
||||
}
|
||||
|
||||
@@ -153,7 +152,7 @@
|
||||
var clr = CGColorCreateWithPattern(CGColorSpaceCreateDeviceRGB(), "a new pattern",
|
||||
[1,1,1,1]);
|
||||
[self assert:1 equals:CGColorGetAlpha(clr) message:"initial alpha"];
|
||||
|
||||
|
||||
var newclr = CGColorCreateCopyWithAlpha(clr, 0.6);
|
||||
[self assert:0.6 equals:CGColorGetAlpha(newclr) message:"new color alpha value"];
|
||||
[self assert:1 equals:CGColorGetAlpha(clr) message:"alpha after copy"];
|
||||
@@ -173,20 +172,20 @@
|
||||
|
||||
[self assert:CGColorSpaceCreateDeviceRGB()
|
||||
equals:newclr.colorspace message:"newclr colorspace failed"];
|
||||
[self assert:[ROUND(0.4*255)/255,ROUND(0.3*255)/255,ROUND(0.2*255)/255,0.6]
|
||||
[self assert:[ROUND(0.4 * 255) / 255, ROUND(0.3 * 255) / 255, ROUND(0.2 * 255) / 255, 0.6]
|
||||
equals:newclr.components message:"newclr components failed"];
|
||||
[self assert:NULL equals:newclr.pattern message:"newclr pattern failed"];
|
||||
|
||||
[self assert:CGColorSpaceCreateDeviceRGB()
|
||||
equals:clr.colorspace message:"orig clr colorspace failed"];
|
||||
[self assert:[ROUND(0.4*255)/255,ROUND(0.3*255)/255,ROUND(0.2*255)/255,0.3]
|
||||
[self assert:[ROUND(0.4 * 255) / 255, ROUND(0.3 * 255) / 255, ROUND(0.2 * 255) / 255, 0.3]
|
||||
equals:clr.components message:"orig clr components failed"];
|
||||
[self assert:NULL equals:clr.pattern message:"orig clr pattern failed"];
|
||||
}
|
||||
|
||||
- (void)testColorCreateCopyWithAlphaWithComponentsNullColor
|
||||
{
|
||||
[self assert:NULL
|
||||
[self assert:NULL
|
||||
equals:CGColorCreateCopyWithAlpha(NULL,0.5)
|
||||
message:"null color failed"];
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
shadowBlur: 0.0,
|
||||
shadowColor: NULL };
|
||||
|
||||
for ( var key in testdata )
|
||||
for (var key in testdata)
|
||||
[self assert:testdata[key] equals:gstate[key] message:"Failed for " + key];
|
||||
|
||||
[self compareSize:CGSizeMakeZero()
|
||||
@@ -64,17 +64,17 @@
|
||||
shadowBlur: 0.0,
|
||||
shadowColor: NULL };
|
||||
|
||||
for ( var key in testdata )
|
||||
for (var key in testdata)
|
||||
[self assert:testdata[key] equals:gstatecopy[key] message:"Failed for " + key];
|
||||
|
||||
// ensure that the size is copied
|
||||
var sizecopy = CGSizeMakeCopy( gstate.shadowOffset );
|
||||
var sizecopy = CGSizeMakeCopy(gstate.shadowOffset);
|
||||
gstate.shadowOffset.width += 1000;
|
||||
gstate.shadowOffset.height += 2000;
|
||||
[self compareSize:sizecopy with:gstatecopy.shadowOffset message:"Failed for shadowOffset"];
|
||||
|
||||
// ensure that the transform is copied
|
||||
var transformcopy = CGAffineTransformMakeCopy( gstate.CTM );
|
||||
var transformcopy = CGAffineTransformMakeCopy(gstate.CTM);
|
||||
gstate.CTM.a += 1000;
|
||||
gstate.CTM.b += 1000;
|
||||
gstate.CTM.c += 1000;
|
||||
|
||||
Reference in New Issue
Block a user