Skip to content

Commit

Permalink
Upgraded project to Xcode 6 and fixed the unit tests that broke due t…
Browse files Browse the repository at this point in the history
…o this.
  • Loading branch information
rickardp committed Jun 12, 2015
1 parent e5b2785 commit ae77e84
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 194 deletions.
181 changes: 100 additions & 81 deletions IQWidgets.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
<string>IQWidgets</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>CE7897B3-DE2C-4816-B1C4-6E4EF97E9473</key>
<string>ssh://github.com/evolvIQ/iqwidgets.git</string>
<key>CFFAB4387BA1905C70B372BFCF1608FCF3A76E84</key>
<string>github.com:evolvIQ/iqwidgets.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>IQWidgets.xcodeproj/project.xcworkspace</string>
<string>IQWidgets.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>CE7897B3-DE2C-4816-B1C4-6E4EF97E9473</key>
<key>CFFAB4387BA1905C70B372BFCF1608FCF3A76E84</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/evolvIQ/iqwidgets.git</string>
<string>github.com:evolvIQ/iqwidgets.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>CE7897B3-DE2C-4816-B1C4-6E4EF97E9473</string>
<string>CFFAB4387BA1905C70B372BFCF1608FCF3A76E84</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>CE7897B3-DE2C-4816-B1C4-6E4EF97E9473</string>
<string>CFFAB4387BA1905C70B372BFCF1608FCF3A76E84</string>
<key>IDESourceControlWCCName</key>
<string>iqwidgets</string>
</dict>
Expand Down
28 changes: 0 additions & 28 deletions Tests/CalendarTests.h

This file was deleted.

31 changes: 18 additions & 13 deletions Tests/CalendarTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,53 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <XCTest/XCTest.h>
#import <UIKit/UIKit.h>
#import "TestUtil.h"
#import "IQWidgets.h"

#import "CalendarTests.h"
@interface CalendarTests : XCTestCase {

}
@end

@implementation CalendarTests

- (void)testMonthLogic
{
NEED_UI
IQCalendarView* cv = [[[IQCalendarView alloc] initWithFrame:CGRectMake(0,0,0,0)] autorelease];
IQCalendarView* cv = [[IQCalendarView alloc] initWithFrame:CGRectMake(0,0,0,0)];
[cv setCurrentDay:D(@"2011-03-06 00:00") display:YES animated:NO];

BOOL isSwedish = [[[NSLocale currentLocale] localeIdentifier] isEqualToString:@"SV_se"];

STAssertEqualObjects(cv.firstDayInDisplayMonth, D(@"2011-03-01 00:00"), @"Invalid start date");
STAssertEqualObjects(cv.firstDisplayedDay, isSwedish ? D(@"2011-02-28 00:00") : D(@"2011-02-27 00:00"), @"Invalid start date");
STAssertEqualObjects(cv.lastDayInDisplayMonth, D(@"2011-03-31 00:00"), @"Invalid start date");
STAssertEqualObjects(cv.lastDisplayedDay, isSwedish ? D(@"2011-04-03 00:00") : D(@"2011-04-02 00:00"), @"Invalid start date");
XCTAssertEqualObjects(cv.firstDayInDisplayMonth, D(@"2011-03-01 00:00"), @"Invalid start date");
XCTAssertEqualObjects(cv.firstDisplayedDay, isSwedish ? D(@"2011-02-28 00:00") : D(@"2011-02-27 00:00"), @"Invalid start date");
XCTAssertEqualObjects(cv.lastDayInDisplayMonth, D(@"2011-03-31 00:00"), @"Invalid start date");
XCTAssertEqualObjects(cv.lastDisplayedDay, isSwedish ? D(@"2011-04-03 00:00") : D(@"2011-04-02 00:00"), @"Invalid start date");
}

- (void)testBasicDateLogic
{
NEED_UI
IQCalendarView* cv = [[[IQCalendarView alloc] initWithFrame:CGRectMake(0,0,0,0)] autorelease];
STAssertEqualObjects([cv dayForDate:D(@"2011-03-06 13:24")], D(@"2011-03-06 00:00"), @"Failed start-of-day");
IQCalendarView* cv = [[IQCalendarView alloc] initWithFrame:CGRectMake(0,0,0,0)];
XCTAssertEqualObjects([cv dayForDate:D(@"2011-03-06 13:24")], D(@"2011-03-06 00:00"), @"Failed start-of-day");
NSMutableSet* s = [NSMutableSet set];
[s addObject:[cv dayForDate:D(@"2011-03-06 13:24")]];
STAssertTrue([s containsObject:D(@"2011-03-06 00:00")], @"Date not suitable in set");
XCTAssertTrue([s containsObject:D(@"2011-03-06 00:00")], @"Date not suitable in set");
}

@end



NSDate* __D(SenTestCase* self, NSString* str)
NSDate* __D(XCTestCase* self, NSString* str)
{
static NSDateFormatter* df = nil;
if(df == nil) {
df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm"];
}
NSDate* date = [df dateFromString:str];
STAssertNotNil(date, @"Bad date format");
XCTAssertNotNil(date, @"Bad date format");
return date;
}

Expand Down
31 changes: 0 additions & 31 deletions Tests/ScheduleTests.h

This file was deleted.

54 changes: 30 additions & 24 deletions Tests/ScheduleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,54 @@
// limitations under the License.
//

#import "ScheduleTests.h"
#import <XCTest/XCTest.h>
#import <UIKit/UIKit.h>
#import "TestUtil.h"
#import "IQWidgets.h"


@interface ScheduleTests : XCTestCase {
}
@end

@implementation ScheduleTests

- (void)testDateAssignment
{
NEED_UI
IQScheduleView* cv = [[[IQScheduleView alloc] initWithFrame:CGRectMake(0,0,0,0)] autorelease];
IQScheduleView* cv = [[IQScheduleView alloc] initWithFrame:CGRectMake(0,0,0,0)];

[cv setStartDate:D(@"2010-01-13 05:43") endDate:D(@"2010-01-15 05:43") animated:NO];
STAssertEquals(cv.numberOfDays, 3, @"Incorrect number of days");
STAssertEqualObjects(cv.startDate, D(@"2010-01-13 00:00"), @"Invalid start date");
STAssertEqualObjects(cv.endDate, D(@"2010-01-15 00:00"), @"Invalid end date");
XCTAssertEqual(cv.numberOfDays, 3, @"Incorrect number of days");
XCTAssertEqualObjects(cv.startDate, D(@"2010-01-13 00:00"), @"Invalid start date");
XCTAssertEqualObjects(cv.endDate, D(@"2010-01-15 00:00"), @"Invalid end date");

cv = [[[IQScheduleView alloc] initWithFrame:CGRectMake(0,0,0,0)] autorelease];
cv = [[IQScheduleView alloc] initWithFrame:CGRectMake(0,0,0,0)];

[cv setStartDate:D(@"2010-01-13 05:43") endDate:D(@"2010-01-15 05:43") animated:NO];
STAssertNotNil(cv.startDate, @"startDate is nil");
STAssertNotNil(cv.endDate, @"endDate is nil");
XCTAssertNotNil(cv.startDate, @"startDate is nil");
XCTAssertNotNil(cv.endDate, @"endDate is nil");
}

- (void)testWeekAssignment
{
NEED_UI
IQScheduleView* cv = [[[IQScheduleView alloc] initWithFrame:CGRectMake(0,0,0,0)] autorelease];
[cv.calendar setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"sv-SE"] autorelease]];
STAssertEquals(cv.calendar.firstWeekday, 2U, @"First weekday should be Monday");
IQScheduleView* cv = [[IQScheduleView alloc] initWithFrame:CGRectMake(0,0,0,0)];
[cv.calendar setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"sv-SE"]];
XCTAssertEqual(cv.calendar.firstWeekday, 2U, @"First weekday should be Monday");
[cv setWeekWithDate:D(@"2011-02-16 23:59") workdays:NO animated:NO];
STAssertEquals(cv.numberOfDays, 7, @"Should be a whole week");
STAssertEqualObjects(cv.startDate, D(@"2011-02-14 00:00"), @"Invalid start date");
STAssertEqualObjects(cv.endDate, D(@"2011-02-20 00:00"), @"Invalid end date");
[cv.calendar setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en-US"] autorelease]];
STAssertEquals(cv.calendar.firstWeekday, 1U, @"First weekday should be Sunday");
XCTAssertEqual(cv.numberOfDays, 7, @"Should be a whole week");
XCTAssertEqualObjects(cv.startDate, D(@"2011-02-14 00:00"), @"Invalid start date");
XCTAssertEqualObjects(cv.endDate, D(@"2011-02-20 00:00"), @"Invalid end date");
[cv.calendar setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en-US"]];
XCTAssertEqual(cv.calendar.firstWeekday, 1U, @"First weekday should be Sunday");
[cv setWeekWithDate:D(@"2011-02-16 23:59") workdays:NO animated:NO];
STAssertEquals(cv.numberOfDays, 7, @"Should be a whole week");
STAssertEqualObjects(cv.startDate, D(@"2011-02-13 00:00"), @"Invalid start date");
STAssertEqualObjects(cv.endDate, D(@"2011-02-19 00:00"), @"Invalid end date");
XCTAssertEqual(cv.numberOfDays, 7, @"Should be a whole week");
XCTAssertEqualObjects(cv.startDate, D(@"2011-02-13 00:00"), @"Invalid start date");
XCTAssertEqualObjects(cv.endDate, D(@"2011-02-19 00:00"), @"Invalid end date");

[cv setWeekWithDate:D(@"2011-02-16 23:59") workdays:YES animated:NO];
STAssertEquals(cv.numberOfDays, 5, @"Should be a working week");
STAssertEqualObjects(cv.startDate, D(@"2011-02-14 00:00"), @"Invalid start date");
STAssertEqualObjects(cv.endDate, D(@"2011-02-18 00:00"), @"Invalid end date");
XCTAssertEqual(cv.numberOfDays, 5, @"Should be a working week");
XCTAssertEqualObjects(cv.startDate, D(@"2011-02-14 00:00"), @"Invalid start date");
XCTAssertEqualObjects(cv.endDate, D(@"2011-02-18 00:00"), @"Invalid end date");

NSLog(@"Dates: %@, %@", cv.startDate, cv.endDate);

Expand Down
6 changes: 1 addition & 5 deletions Tests/TestUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
// limitations under the License.
//

@class SenTestCase;

extern NSDate* __D(SenTestCase* self, NSString* str);
extern NSDate* __D(XCTestCase* self, NSString* str);
extern void __NEED_UI();

#define D(x) __D(self, x)

#define NEED_UI __NEED_UI();
1 change: 1 addition & 0 deletions Views/IQCalendarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ - (void) setupCalendarView
dayFormatter = [[NSDateFormatter alloc] init];
[dayFormatter setDateFormat:@"d"];
[self displayDay:currentDay animated:NO];
displayDate = nil;
}

- (void)layoutSubviews
Expand Down
8 changes: 4 additions & 4 deletions Views/IQGanttView.m
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
UIFont* textFont = [UIFont systemFontOfSize:8];
NSCalendar* calendar = [cal copy];
if(scaleWindow.windowEnd > scaleWindow.windowStart) {
int fwd = [calendar firstWeekday];
NSUInteger fwd = [calendar firstWeekday];
NSDate* d = [NSDate dateWithTimeIntervalSinceReferenceDate:t0];
// Days
NSDateComponents* cmpnts = [calendar components:NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit fromDate:d];
Expand All @@ -333,9 +333,9 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
CGContextSetTextDrawingMode(ctx, kCGTextFill);
while (t <= t1) {
NSDateComponents* c2 = [calendar components:NSWeekdayCalendarUnit|NSDayCalendarUnit|NSWeekCalendarUnit fromDate:d];
int wd = c2.weekday;
int md = c2.day;
int wk = c2.week;
NSInteger wd = c2.weekday;
NSInteger md = c2.day;
NSInteger wk = c2.week;
CGFloat scale = 0.6;
if(wd == fwd && displayCalendarUnits & NSWeekCalendarUnit) {
scale = 0.4;
Expand Down

0 comments on commit ae77e84

Please sign in to comment.