Set explicit designated requirements to ensure the signing behaves properly on versions of Mac OS X that don't know about Developer ID signing (OS X 10.6)
(transplanted from c5ac17ab998dcf932c5d7e778e153f92263c449a)
/*
* 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.
STAssertNoThrow(attributedString=[NSAttributedStringattributedStringWithLinkLabel:linkLabellinkDestination:linkURLString],@"attributedStringWithLinkLabel:linkDestination: threw an exception");
STAssertNotNil(attributedString,@"attributedStringWithLinkLabel:linkDestination: returned nil");
STAssertEqualObjects([attributedStringstring],linkLabel,@"Attributed string's text is not equal to the original string");
STAssertEquals([attributedStringlength],[linkLabellength],@"Attributed string is not the same length (%lu) as the original string (%lu)",[attributedStringlength],[linkLabellength]);
STAssertEquals(linkRange,attributedStringRange,@"Link range is not the entire range of the attributed string");
//Next, try an NSURL object.
STAssertNoThrow(attributedString=[NSAttributedStringattributedStringWithLinkLabel:linkLabellinkDestination:linkURL],@"attributedStringWithLinkLabel:linkDestination: threw an exception");
STAssertNotNil(attributedString,@"attributedStringWithLinkLabel:linkDestination: returned nil");
STAssertEqualObjects([attributedStringstring],linkLabel,@"Attributed string's text is not equal to the original string");
STAssertEquals([attributedStringlength],[linkLabellength],@"Attributed string is not the same length (%lu) as the original string (%lu)",[attributedStringlength],[linkLabellength]);
STAssertEquals(linkRange,attributedStringRange,@"Link range is not the entire range of the attributed string");
}
-(void)testAttributedStringWithLinkedSubstring
{
NSString*linkLabel=@"Download Adium now!";
NSString*linkURLString=@"http://www.adium.im/";
NSURL*linkURL=[NSURLURLWithString:linkURLString];
NSRangeintendedLinkRange={9UL,5UL};//@"Adium"
NSRangelinkRange={0UL,0UL};
idlinkValue;
NSAttributedString*attributedString=nil;
//First, try a string containing a URL.
STAssertNoThrow(attributedString=[NSAttributedStringattributedStringWithString:linkLabellinkRange:intendedLinkRangelinkDestination:linkURLString],@"attributedStringWithLinkLabel:linkDestination: threw an exception");
STAssertNotNil(attributedString,@"attributedStringWithLinkLabel:linkDestination: returned nil");
STAssertEqualObjects([attributedStringstring],linkLabel,@"Attributed string's text is not equal to the original string");
STAssertEquals([attributedStringlength],[linkLabellength],@"Attributed string is not the same length (%lu) as the original string (%lu)",[attributedStringlength],[linkLabellength]);
STAssertNotNil(linkValue,@"Attributed string does not have a link");
STAssertTrue([linkValueisKindOfClass:[NSURLclass]],@"Link value is not an NSURL");
STAssertEqualObjects(linkValue,linkURL,@"Link value is not equal to the URL we provided");
STAssertEquals(linkRange,intendedLinkRange,@"Link range is not the range we wanted to link");
//Next, try an NSURL object.
STAssertNoThrow(attributedString=[NSAttributedStringattributedStringWithString:linkLabellinkRange:intendedLinkRangelinkDestination:linkURL],@"attributedStringWithLinkLabel:linkDestination: threw an exception");
STAssertNotNil(attributedString,@"attributedStringWithLinkLabel:linkDestination: returned nil");
STAssertEqualObjects([attributedStringstring],linkLabel,@"Attributed string's text is not equal to the original string");
STAssertEquals([attributedStringlength],[linkLabellength],@"Attributed string is not the same length (%lu) as the original string (%lu)",[attributedStringlength],[linkLabellength]);
STAssertNoThrow(attributedString=[NSAttributedStringattributedStringWithString:linkLabellinkRange:intendedLinkRangelinkDestination:linkURLString],@"attributedStringWithLinkLabel:linkDestination: threw an exception");
STAssertNotNil(attributedString,@"attributedStringWithLinkLabel:linkDestination: returned nil");
STAssertEqualObjects([attributedStringstring],linkLabel,@"Attributed string's text is not equal to the original string");
STAssertEquals([attributedStringlength],[linkLabellength],@"Attributed string is not the same length (%lu) as the original string (%lu)",[attributedStringlength],[linkLabellength]);
STAssertEquals(linkRange,attributedStringRange,@"Link range is not the entire range of the attributed string");
//Next, try an NSURL object.
STAssertNoThrow(attributedString=[NSAttributedStringattributedStringWithString:linkLabellinkRange:intendedLinkRangelinkDestination:linkURL],@"attributedStringWithLinkLabel:linkDestination: threw an exception");
STAssertNotNil(attributedString,@"attributedStringWithLinkLabel:linkDestination: returned nil");
STAssertEqualObjects([attributedStringstring],linkLabel,@"Attributed string's text is not equal to the original string");
STAssertEquals([attributedStringlength],[linkLabellength],@"Attributed string is not the same length (%lu) as the original string (%lu)",[attributedStringlength],[linkLabellength]);
STAssertNoThrow(attributedString=[NSAttributedStringattributedStringWithString:linkLabellinkRange:intendedLinkRangelinkDestination:linkURLString],@"attributedStringWithLinkLabel:linkDestination: threw an exception");
STAssertNotNil(attributedString,@"attributedStringWithLinkLabel:linkDestination: returned nil");
STAssertEqualObjects([attributedStringstring],linkLabel,@"Attributed string's text is not equal to the original string");
STAssertEquals([attributedStringlength],[linkLabellength],@"Attributed string is not the same length (%lu) as the original string (%lu)",[attributedStringlength],[linkLabellength]);
STAssertEquals(linkRange,attributedStringRange,@"Non-link range is not the entire string");
//Next, try an NSURL object.
STAssertNoThrow(attributedString=[NSAttributedStringattributedStringWithString:linkLabellinkRange:intendedLinkRangelinkDestination:linkURL],@"attributedStringWithLinkLabel:linkDestination: threw an exception");
STAssertNotNil(attributedString,@"attributedStringWithLinkLabel:linkDestination: returned nil");
STAssertEqualObjects([attributedStringstring],linkLabel,@"Attributed string's text is not equal to the original string");
STAssertEquals([attributedStringlength],[linkLabellength],@"Attributed string is not the same length (%lu) as the original string (%lu)",[attributedStringlength],[linkLabellength]);
STAssertNoThrow(result=[inputattributedStringByConvertingLinksToStrings],@"-attributedStringByConvertingLinksToStrings threw an exception");
STAssertNotNil(result,@"-attributedStringByConvertingLinksToStrings returned nil");
STAssertEqualObjects([resultstring],@"Adium (http://www.adium.im/) requires Growl (http://growl.info/).",@"-attributedStringByConvertingLinksToStrings did not correctly expand the links");
STAssertNoThrow(result=[inputattributedStringByConvertingLinksToURLStrings],@"-attributedStringByConvertingLinksToURLStrings threw an exception");
STAssertNotNil(result,@"-attributedStringByConvertingLinksToURLStrings returned nil");
STAssertEqualObjects([resultstring],@"http://www.adium.im/ requires http://growl.info/.",@"-attributedStringByConvertingLinksToURLStrings did not correctly expand the links");