Updated Sparkle to 1.17.0, to fix a problem when copying broken symlinks.
/*
* Adium is the legal property of its developers, whose names are listed in the copyright file included
* with this source distribution.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import "TestColorAdditions.h"
#import <AIUtilities/AIColorAdditions.h>
//Test strings chosen by hand from output of dissociated-press on the Adium blog as of 2008-03-02.
#define TEST_STRING_1 @"We've fixes failure code IS want to videopletely unable to downly hope."
#define TEST_STRING_2 @"Adium hase. It's it wildbot. This a reality of Adium. You add both acheFly!"
#define TEST_STRING_3 @"We're proud to a misperception his blog. Now your patience, so include That means you!"
#define TEST_STRING_4 @"Great fort this is powerful numberted, but and thuse everyone has no way to a closedish, Russiate it!"
#define TEST_STRING_5 @"You capacith this by having testing: there's sting AV coming from other Skype?"
#define TEST_STRING_6 @"To can rience lawyers involvement in the most from the publicant progres is not running and tell you what we did pas alway or may not be submits IP. If the IP hunt down bugs will beta iterat yet."
#define TEST_STRING_7 @"What about stransfers, bettelephoo!"
STAssertFalse([colorAequalToRGBColor:colorB],@"Two colors with inequal A must compare equal");
}
#pragma mark -colorIsDark
-(void)testWhiteColorIsDark
{
STAssertFalse([[NSColorwhiteColor]colorIsDark],@"White is not dark");
}
-(void)testBlackColorIsDark
{
STAssertTrue([[NSColorblackColor]colorIsDark],@"Black is dark");
}
#pragma mark -colorIsMedium
-(void)testWhiteColorIsMedium
{
STAssertFalse([[NSColorwhiteColor]colorIsMedium],@"White is not medium");
}
-(void)testGrayColorIsMedium
{
STAssertTrue([[NSColorgrayColor]colorIsMedium],@"Gray is medium");
}
-(void)testBlackColorIsMedium
{
STAssertFalse([[NSColorblackColor]colorIsMedium],@"Black is not medium");
}
#pragma mark -darkenBy:
-(void)testDarkenRed
{
NSColor*red=[NSColorredColor];
STAssertEquals([redredComponent],(CGFloat)1.0f,@"Expected red's red component to be 1.0f");
NSColor*redDarkened=[reddarkenBy:0.5f];
STAssertEquals([redDarkenedredComponent],(CGFloat)0.5f,@"Darkening red by 0.5 should result in 0.5, 0, 0");
STAssertEquals([redDarkenedgreenComponent],[redgreenComponent],@"Darkening red by 0.5 should not change its green");
STAssertEquals([redDarkenedblueComponent],[redblueComponent],@"Darkening red by 0.5 should not change its blue");
}
#pragma mark -darkenAndAdjustSaturationBy:
//Pure red already has 1.0 saturation, so this method has the same effect on it as darkenBy:.
-(void)testDarkenAndSaturateRed
{
NSColor*red=[NSColorredColor];
STAssertEquals([redredComponent],(CGFloat)1.0f,@"Expected red's red component to be 1.0");
NSColor*redDarkened=[reddarkenBy:0.5f];
STAssertEquals([redDarkenedredComponent],(CGFloat)0.5f,@"Darkening and saturating red by 0.5 should result in 0.5, 0, 0");
STAssertEquals([redDarkenedgreenComponent],[redgreenComponent],@"Darkening and saturating red by 0.5 should not change its green");
STAssertEquals([redDarkenedblueComponent],[redblueComponent],@"Darkening and saturating red by 0.5 should not change its blue");
}
-(void)testDarkenAndSaturatePink
{
NSColor*pink=[NSColorcolorWithCalibratedHue:0.0f
saturation:0.5f//This is what makes it pink, rather than red.
brightness:1.0f
alpha:1.0f];
STAssertEquals([pinkredComponent],(CGFloat)1.0f,@"Expected pink's red component to be 1.0");
STAssertEquals([pinkgreenComponent],(CGFloat)0.5f,@"Expected pink's green component to be 0.5");
STAssertEquals([pinkblueComponent],(CGFloat)0.5f,@"Expected pink's blue component to be 0.5");
NSColor*pinkDarkened=[pinkdarkenBy:0.5f];
STAssertEquals([pinkDarkenedredComponent],(CGFloat)0.5f,@"Darkening and saturating pink by 0.5 should result in 0.5, 0.25, 0.25");
STAssertEquals([pinkDarkenedgreenComponent],(CGFloat)0.25f,@"Darkening and saturating pink by 0.5 should result in 0.5, 0.25, 0.25");
STAssertEquals([pinkDarkenedblueComponent],(CGFloat)0.25f,@"Darkening and saturating pink by 0.5 should result in 0.5, 0.25, 0.25");
}
#pragma mark -colorWithInvertedLuminance
-(void)testInvertLuminanceOfWhite
{
NSColor*white=[NSColorwhiteColor];
NSColor*black=[whitecolorWithInvertedLuminance];
STAssertEquals([blackredComponent],(CGFloat)1.0f-[whitewhiteComponent],@"White, luminance-inverted, should be black (red component should be %f",(CGFloat)1.0f-[whitewhiteComponent]);
STAssertEquals([blackgreenComponent],(CGFloat)1.0f-[whitewhiteComponent],@"White, luminance-inverted, should be black (green component should be %f",(CGFloat)1.0f-[whitewhiteComponent]);
STAssertEquals([blackblueComponent],(CGFloat)1.0f-[whitewhiteComponent],@"White, luminance-inverted, should be black (blue component should be %f",(CGFloat)1.0f-[whitewhiteComponent]);
}
-(void)testInvertLuminanceOfBlack
{
NSColor*black=[NSColorblackColor];
NSColor*white=[blackcolorWithInvertedLuminance];
STAssertEquals([whiteredComponent],(CGFloat)1.0f-[blackwhiteComponent],@"Black, luminance-inverted, should be white (red component should be %f",(CGFloat)1.0f-[whitewhiteComponent]);
STAssertEquals([whitegreenComponent],(CGFloat)1.0f-[blackwhiteComponent],@"Black, luminance-inverted, should be white (green component should be %f",(CGFloat)1.0f-[whitewhiteComponent]);
STAssertEquals([whiteblueComponent],(CGFloat)1.0f-[blackwhiteComponent],@"Black, luminance-inverted, should be white (blue component should be %f",(CGFloat)1.0f-[whitewhiteComponent]);
}
-(void)testInvertLuminanceOfRed
{
NSColor*red=[NSColorredColor];
NSColor*black=[redcolorWithInvertedLuminance];
STAssertEquals([blackredComponent],(CGFloat)0.0f,@"Red, luminance-inverted, should be black");
STAssertEquals([blackgreenComponent],(CGFloat)0.0f,@"Red, luminance-inverted, should not have any green");
STAssertEquals([blackblueComponent],(CGFloat)0.0f,@"Red, luminance-inverted, should not have any blue");
}
#pragma mark -contrastingColor
-(void)testContrastingColorForWhite
{
NSColor*white=[NSColorwhiteColor];
NSColor*contrastingColor=[whitecontrastingColor];
//contrastingColor inverts the R, G, and B components if the receiver is not medium, so its result will be in an RGB color space. This is why we compare its RGB components rather than its white component (it has no white component).
STAssertEquals([contrastingColorredComponent],(CGFloat)0.0f,@"White's contrasting color should be black (its red component should be 0)");
STAssertEquals([contrastingColorgreenComponent],(CGFloat)0.0f,@"White's contrasting color should be black (its green component should be 0)");
STAssertEquals([contrastingColorblueComponent],(CGFloat)0.0f,@"White's contrasting color should be black (its blue component should be 0)");
}
-(void)testContrastingColorForBlack
{
NSColor*black=[NSColorblackColor];
NSColor*contrastingColor=[blackcontrastingColor];
//contrastingColor inverts the R, G, and B components if the receiver is not medium, so its result will be in an RGB color space. This is why we compare its RGB components rather than its white component (it has no white component).
STAssertEquals([contrastingColorredComponent],(CGFloat)1.0f,@"Black's contrasting color should be white (its red component should be 1)");
STAssertEquals([contrastingColorgreenComponent],(CGFloat)1.0f,@"Black's contrasting color should be white (its green component should be 1)");
STAssertEquals([contrastingColorblueComponent],(CGFloat)1.0f,@"Black's contrasting color should be white (its blue component should be 1)");
}
-(void)testContrastingColorForGray
{
NSColor*gray=[NSColorgrayColor];
//Gray's whiteComponent is 0.5. This is medium, but not dark. As such, its contrasting color should be black.
NSColor*contrastingColor=[graycontrastingColor];
STAssertEquals([contrastingColorwhiteComponent],(CGFloat)0.0f,@"Gray's contrasting color should be black");
STAssertEquals(noColor,(NSColor*)nil,@"Color represented by three commas (with alpha forced to 0.5) should be nil");
}
#pragma mark -randomColor
-(void)testRandomColorHasAlpha1
{
NSColor*color=[NSColorrandomColor];
STAssertEquals([coloralphaComponent],(CGFloat)1.0f,@"Alpha component of color from +randomColor should be 1");
}
#pragma mark +colorWithHTMLString:
//These methods are automatically generated! If you want to change them, please change the program in the Utilities folder instead. Otherwise, your changes may be clobbered by the next person.
STAssertEquals(color,(NSColor*)nil,@"colorWithHTMLString:defaultColor:, when passed nil (string) and nil (default color), should return nil (default color)");