diff options
Diffstat (limited to 'AppKit')
-rw-r--r-- | AppKit/GTMLinearRGBShading.m | 16 | ||||
-rw-r--r-- | AppKit/GTMLinearRGBShadingTest.m | 32 | ||||
-rw-r--r-- | AppKit/GTMLoginItems.m | 16 | ||||
-rw-r--r-- | AppKit/GTMLoginItemsTest.m | 2 | ||||
-rw-r--r-- | AppKit/GTMNSBezierPath+CGPathTest.m | 7 | ||||
-rw-r--r-- | AppKit/GTMNSBezierPath+RoundRectTest.m | 6 | ||||
-rw-r--r-- | AppKit/GTMNSBezierPath+Shading.m | 4 | ||||
-rw-r--r-- | AppKit/GTMNSBezierPath+ShadingTest.m | 7 | ||||
-rw-r--r-- | AppKit/GTMNSWorkspace+ScreenSaver.m | 8 | ||||
-rw-r--r-- | AppKit/GTMNSWorkspace+ScreenSaverTest.m | 4 |
10 files changed, 54 insertions, 48 deletions
diff --git a/AppKit/GTMLinearRGBShading.m b/AppKit/GTMLinearRGBShading.m index 18af0e0..ef13986 100644 --- a/AppKit/GTMLinearRGBShading.m +++ b/AppKit/GTMLinearRGBShading.m @@ -88,28 +88,28 @@ static void cShadeFunction(void *info, const CGFloat *inPos, CGFloat *outVals); // Calculate a linear value based on our stops - (id)valueAtPosition:(CGFloat)position { - NSUInteger index = 0; + NSUInteger positionIndex = 0; NSUInteger colorCount = [self stopCount]; CGFloat stop1Position = 0.0; - NSColor *stop1Color = [self stopAtIndex:index position:&stop1Position]; - index += 1; + NSColor *stop1Color = [self stopAtIndex:positionIndex position:&stop1Position]; + positionIndex += 1; CGFloat stop2Position = 0.0; NSColor *stop2Color = nil; NSColor *theColor = nil; if (colorCount > 1) { - stop2Color = [self stopAtIndex:index position:&stop2Position]; - index += 1; + stop2Color = [self stopAtIndex:positionIndex position:&stop2Position]; + positionIndex += 1; } else { // if we only have one value, that's what we return stop2Position = stop1Position; stop2Color = stop1Color; } - while (index < colorCount && stop2Position < position) { + while (positionIndex < colorCount && stop2Position < position) { stop1Color = stop2Color; stop1Position = stop2Position; - stop2Color = [self stopAtIndex:index position:&stop2Position]; - index += 1; + stop2Color = [self stopAtIndex:positionIndex position:&stop2Position]; + positionIndex += 1; } if (position <= stop1Position) { diff --git a/AppKit/GTMLinearRGBShadingTest.m b/AppKit/GTMLinearRGBShadingTest.m index 119fa79..cb65572 100644 --- a/AppKit/GTMLinearRGBShadingTest.m +++ b/AppKit/GTMLinearRGBShadingTest.m @@ -20,7 +20,7 @@ #import "GTMSenTestCase.h" #import "GTMLinearRGBShading.h" -@interface GTMLinearRGBShadingTest : SenTestCase +@interface GTMLinearRGBShadingTest : GTMTestCase @end @implementation GTMLinearRGBShadingTest @@ -36,10 +36,10 @@ STAssertNotNil(theShading,nil); STAssertEquals([theShading stopCount], (NSUInteger)2, nil); CGFloat *theColor = (CGFloat*)[theShading valueAtPosition: 0.5]; - STAssertTrue(theColor[0] == [purple redComponent] && - theColor[1] == [purple greenComponent] && - theColor[2] == [purple blueComponent] && - theColor[3] == [purple alphaComponent], nil); + STAssertEqualsWithAccuracy(theColor[0], [purple redComponent], 0.001, nil); + STAssertEqualsWithAccuracy(theColor[1], [purple greenComponent], 0.001, nil); + STAssertEqualsWithAccuracy(theColor[2], [purple blueComponent], 0.001, nil); + STAssertEqualsWithAccuracy(theColor[3], [purple alphaComponent], 0.001, nil); } - (void)testShadingWith { @@ -49,11 +49,12 @@ CGFloat thePositions[kColorCount]; const CGFloat kColorIncrement = 1.0 / kColorCount; for (NSUInteger i = 0; i < kColorCount; i++) { - thePositions[i] = kColorIncrement * i; - theColors[i] = [NSColor colorWithCalibratedRed:kColorIncrement * i - green:kColorIncrement * i - blue:kColorIncrement * i - alpha:kColorIncrement * i]; + CGFloat newValue = kColorIncrement * i; + thePositions[i] = newValue; + theColors[i] = [NSColor colorWithCalibratedRed:newValue + green:newValue + blue:newValue + alpha:newValue]; } GTMLinearRGBShading *theShading = [GTMLinearRGBShading shadingWithColors:theColors @@ -61,11 +62,12 @@ atPositions:thePositions count:kColorCount]; for (NSUInteger i = 0; i < kColorCount; i++) { - CGFloat *theColor = (CGFloat*)[theShading valueAtPosition: kColorIncrement * i]; - STAssertTrue(theColor[0] == kColorIncrement * i && - theColor[1] == kColorIncrement * i && - theColor[2] == kColorIncrement * i && - theColor[3] == kColorIncrement * i, nil); + CGFloat newValue = kColorIncrement * i; + CGFloat *theColor = (CGFloat*)[theShading valueAtPosition:newValue]; + STAssertEqualsWithAccuracy(theColor[0], newValue, 0.001, nil); + STAssertEqualsWithAccuracy(theColor[1], newValue, 0.001, nil); + STAssertEqualsWithAccuracy(theColor[2], newValue, 0.001, nil); + STAssertEqualsWithAccuracy(theColor[3], newValue, 0.001, nil); } } diff --git a/AppKit/GTMLoginItems.m b/AppKit/GTMLoginItems.m index cc34c11..61a2120 100644 --- a/AppKit/GTMLoginItems.m +++ b/AppKit/GTMLoginItems.m @@ -136,18 +136,18 @@ NSString * const kGTMLoginItemsHiddenKey = @"Hide"; + (BOOL)pathInLoginItems:(NSString *)path { NSArray *loginItems = [self loginItems:nil]; - NSInteger index = [self indexOfLoginItemWithValue:path - forKey:kGTMLoginItemsPathKey - loginItems:loginItems]; - return (index != NSNotFound) ? YES : NO; + NSInteger itemIndex = [self indexOfLoginItemWithValue:path + forKey:kGTMLoginItemsPathKey + loginItems:loginItems]; + return (itemIndex != NSNotFound) ? YES : NO; } + (BOOL)itemWithNameInLoginItems:(NSString *)name { NSArray *loginItems = [self loginItems:nil]; - NSInteger index = [self indexOfLoginItemWithValue:name - forKey:kGTMLoginItemsNameKey - loginItems:loginItems]; - return (index != NSNotFound) ? YES : NO; + NSInteger itemIndex = [self indexOfLoginItemWithValue:name + forKey:kGTMLoginItemsNameKey + loginItems:loginItems]; + return (itemIndex != NSNotFound) ? YES : NO; } + (void)addPathToLoginItems:(NSString*)path hide:(BOOL)hide { diff --git a/AppKit/GTMLoginItemsTest.m b/AppKit/GTMLoginItemsTest.m index 05a93a1..ec08a85 100644 --- a/AppKit/GTMLoginItemsTest.m +++ b/AppKit/GTMLoginItemsTest.m @@ -26,7 +26,7 @@ #define TESTS_ENABLED 0 -@interface GTMLoginItemsTest : SenTestCase +@interface GTMLoginItemsTest : GTMTestCase @end #if TESTS_ENABLED diff --git a/AppKit/GTMNSBezierPath+CGPathTest.m b/AppKit/GTMNSBezierPath+CGPathTest.m index e22ee07..eb86353 100644 --- a/AppKit/GTMNSBezierPath+CGPathTest.m +++ b/AppKit/GTMNSBezierPath+CGPathTest.m @@ -23,13 +23,16 @@ #import "GTMAppKit+UnitTesting.h" #import "GTMSenTestCase.h" -@interface GTMNSBezierPath_CGPathTest : SenTestCase<GTMUnitTestViewDrawer> +@interface GTMNSBezierPath_CGPathTest : GTMTestCase<GTMUnitTestViewDrawer> @end @implementation GTMNSBezierPath_CGPathTest - (void)testCreateCGPath { - GTMAssertDrawingEqualToFile(self, NSMakeSize(100, 100), @"GTMNSBezierPath+CGPathTest", nil, nil); + GTMAssertDrawingEqualToImageNamed(self, + NSMakeSize(100, 100), + @"GTMNSBezierPath+CGPathTest", + nil, nil); } diff --git a/AppKit/GTMNSBezierPath+RoundRectTest.m b/AppKit/GTMNSBezierPath+RoundRectTest.m index c67c4b3..ad64fd4 100644 --- a/AppKit/GTMNSBezierPath+RoundRectTest.m +++ b/AppKit/GTMNSBezierPath+RoundRectTest.m @@ -22,14 +22,14 @@ #import "GTMNSBezierPath+RoundRect.h" #import "GTMAppKit+UnitTesting.h" -@interface GTMNSBezierPath_RoundRectTest : SenTestCase<GTMUnitTestViewDrawer> +@interface GTMNSBezierPath_RoundRectTest : GTMTestCase<GTMUnitTestViewDrawer> @end @implementation GTMNSBezierPath_RoundRectTest - (void)testRoundRects { - GTMAssertDrawingEqualToFile(self, NSMakeSize(330, 430), - @"GTMNSBezierPath+RoundRectTest", nil, nil); + GTMAssertDrawingEqualToImageNamed(self, NSMakeSize(330, 430), + @"GTMNSBezierPath+RoundRectTest", nil, nil); } // Draws all of our tests so that we can compare this to our stored TIFF file. diff --git a/AppKit/GTMNSBezierPath+Shading.m b/AppKit/GTMNSBezierPath+Shading.m index 4ab9ee3..eff8dfb 100644 --- a/AppKit/GTMNSBezierPath+Shading.m +++ b/AppKit/GTMNSBezierPath+Shading.m @@ -132,9 +132,9 @@ NSPoint newPoint = pointB; CGFloat x = (pointB.x - pointA.x); CGFloat y = (pointB.y - pointA.y); - if (x == 0.0) { + if (fpclassify(x) == FP_ZERO) { newPoint.y += length; - } else if (y == 0.0) { + } else if (fpclassify(y) == FP_ZERO) { newPoint.x += length; } else { #if CGFLOAT_IS_DOUBLE diff --git a/AppKit/GTMNSBezierPath+ShadingTest.m b/AppKit/GTMNSBezierPath+ShadingTest.m index 9fa7a8f..5634cf3 100644 --- a/AppKit/GTMNSBezierPath+ShadingTest.m +++ b/AppKit/GTMNSBezierPath+ShadingTest.m @@ -24,16 +24,17 @@ #import "GTMAppKit+UnitTesting.h" #import "GTMNSBezierPath+Shading.h" -@interface GTMNSBezierPath_ShadingTest : SenTestCase<GTMUnitTestViewDrawer> +@interface GTMNSBezierPath_ShadingTest : GTMTestCase<GTMUnitTestViewDrawer> @end @implementation GTMNSBezierPath_ShadingTest - (void)testShadings { - GTMAssertDrawingEqualToFile(self, NSMakeSize(200, 200), @"GTMNSBezierPath+ShadingTest", nil, nil); + GTMAssertDrawingEqualToImageNamed(self, + NSMakeSize(200, 200), + @"GTMNSBezierPath+ShadingTest", nil, nil); } - - (void)gtm_unitTestViewDrawRect:(NSRect)rect contextInfo:(void*)contextInfo { NSColor *theColorArray[] = { [NSColor blueColor], diff --git a/AppKit/GTMNSWorkspace+ScreenSaver.m b/AppKit/GTMNSWorkspace+ScreenSaver.m index 9e1eb6a..7ca5d70 100644 --- a/AppKit/GTMNSWorkspace+ScreenSaver.m +++ b/AppKit/GTMNSWorkspace+ScreenSaver.m @@ -20,6 +20,7 @@ #import <ScreenSaver/ScreenSaver.h> #import "GTMNSWorkspace+ScreenSaver.h" #import "GTMDefines.h" +#import "GTMGarbageCollection.h" // Interesting class descriptions extracted from ScreenSaver.framework using // class-dump. Note that these are "not documented". @@ -114,15 +115,14 @@ kProcessDictionaryIncludeAllInformationMask); require(cfProcessInfo, CantGetFrontProcess); - - NSString *bundlePath = [(NSDictionary*)cfProcessInfo objectForKey:@"BundlePath"]; - + NSDictionary *processInfo = [GTMNSMakeCollectable(cfProcessInfo) autorelease]; + NSString *bundlePath = [processInfo objectForKey:@"BundlePath"]; + // ScreenSaverEngine is the frontmost app if the screen saver is actually // running Security Agent is the frontmost app if the "enter password" // dialog is showing answer = [bundlePath hasSuffix:@"ScreenSaverEngine.app"] || [bundlePath hasSuffix:@"SecurityAgent.app"]; - CFRelease(cfProcessInfo); // COV_NF_END } CantGetFrontProcess: diff --git a/AppKit/GTMNSWorkspace+ScreenSaverTest.m b/AppKit/GTMNSWorkspace+ScreenSaverTest.m index 2dfcbb9..923efe9 100644 --- a/AppKit/GTMNSWorkspace+ScreenSaverTest.m +++ b/AppKit/GTMNSWorkspace+ScreenSaverTest.m @@ -15,10 +15,10 @@ // License for the specific language governing permissions and limitations under // the License. // -#import <SenTestingKit/SenTestingKit.h> +#import "GTMSenTestCase.h" #import "GTMNSWorkspace+ScreenSaver.h" -@interface GTMNSWorkspace_ScreenSaverTest : SenTestCase +@interface GTMNSWorkspace_ScreenSaverTest : GTMTestCase @end |