mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 00:02:28 +00:00
Extendend color test
Some experiments on the segmented toolbar button Updated keepasskit submodule
This commit is contained in:
Submodule KeePassKit updated: 802eac2871...8894b319ad
@@ -11,5 +11,4 @@
|
||||
@interface MPContextToolbarButton : NSSegmentedControl
|
||||
|
||||
- (void)setImage:(NSImage *)image;
|
||||
|
||||
@end
|
||||
|
||||
@@ -14,19 +14,11 @@
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self setFocusRingType:NSFocusRingTypeNone];
|
||||
[self setSegmentCount:1];
|
||||
[self setSegmentCount:2];
|
||||
[[self cell] setTrackingMode:NSSegmentSwitchTrackingMomentary];
|
||||
[self setSegmentStyle:NSSegmentStyleTexturedSquare];
|
||||
|
||||
// NSMutableData *data = [[NSMutableData alloc] init];
|
||||
// NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
|
||||
// [[self cell] encodeWithCoder:archiver];
|
||||
// [archiver finishEncoding];
|
||||
//
|
||||
// NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
|
||||
// HNHContextButtonSegmentedCell *cell = [[HNHContextButtonSegmentedCell alloc] initWithCoder:unarchiver];
|
||||
// [unarchiver finishDecoding];
|
||||
// [self setCell:cell];
|
||||
[[self cell] setWidth:32 forSegment:0];
|
||||
[[self cell] setWidth:20 forSegment:1];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -41,7 +33,7 @@
|
||||
}
|
||||
|
||||
- (void)setSegmentCount:(NSInteger)count {
|
||||
if(count == 1) {
|
||||
if(count == 2) {
|
||||
[super setSegmentCount:count];
|
||||
}
|
||||
}
|
||||
@@ -50,4 +42,20 @@
|
||||
[self setImage:image forSegment:0];
|
||||
}
|
||||
|
||||
- (SEL)action {
|
||||
NSLog(@"actionSegment:%ld", [[self cell] selectedSegment]);
|
||||
if([self selectedSegment] == 1) {
|
||||
return @selector(showContextMenu:);
|
||||
}
|
||||
return [super action];
|
||||
}
|
||||
|
||||
- (id)target {
|
||||
NSLog(@"targetSegment:%ld", [[self cell] selectedSegment]);
|
||||
if([self selectedSegment] == 1) {
|
||||
return self;
|
||||
}
|
||||
return [super target];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -13,25 +13,25 @@
|
||||
@implementation KPKTestHexColor
|
||||
|
||||
- (void)testHexToColor {
|
||||
NSString *redHex = @"00ff0000";
|
||||
NSString *blueHex = @"000000ff";
|
||||
NSString *greeHex = @"0000ff00";
|
||||
NSString *redHex = @"FF000000";
|
||||
NSString *greeHex = @"00FF0000";
|
||||
NSString *blueHex = @"0000FF00";
|
||||
|
||||
NSColor *red = [NSColor colorWithHexString:redHex];
|
||||
NSColor *blue = [NSColor colorWithHexString:blueHex];
|
||||
NSColor *green = [NSColor colorWithHexString:greeHex];
|
||||
NSColor *blue = [NSColor colorWithHexString:blueHex];
|
||||
|
||||
STAssertEquals([red redComponent], 1.0, @"Red color should have 100% red");
|
||||
STAssertEquals([red blueComponent], 0.0, @"Red color should have 0% blue");
|
||||
STAssertEquals([red greenComponent], 0.0, @"Red color should have 0% green");
|
||||
|
||||
STAssertEquals([blue redComponent], 0.0, @"Blue color should have 0% red");
|
||||
STAssertEquals([blue blueComponent], 1.0, @"Blue color should have 100% blue");
|
||||
STAssertEquals([blue greenComponent], 0.0, @"Blue color should have 0% green");
|
||||
|
||||
STAssertEquals([green redComponent], 0.0, @"Green color should have 0% red");
|
||||
STAssertEquals([green blueComponent], 0.0, @"Green color should have 0% blue");
|
||||
STAssertEquals([green greenComponent], 1.0, @"Green color should have 100% green");
|
||||
STAssertEquals([green blueComponent], 0.0, @"Green color should have 0% blue");
|
||||
|
||||
STAssertEquals([blue redComponent], 0.0, @"Blue color should have 0% red");
|
||||
STAssertEquals([blue greenComponent], 0.0, @"Blue color should have 0% green");
|
||||
STAssertEquals([blue blueComponent], 1.0, @"Blue color should have 100% blue");
|
||||
}
|
||||
|
||||
- (void)testColorRefReading {
|
||||
@@ -43,4 +43,12 @@
|
||||
STAssertEquals([color blueComponent], 0.0, @"Blue 100%");
|
||||
}
|
||||
|
||||
- (void)testColorRefWriting {
|
||||
uint32_t colorBytes = 0x000000FF;
|
||||
NSData *colorData = [NSData dataWithBytesNoCopy:&colorBytes length:4 freeWhenDone:NO];
|
||||
NSColor *color = [NSColor colorWithData:colorData];
|
||||
NSData *newData = [color colorData];
|
||||
STAssertEqualObjects(colorData, newData, @"Convertion should result in same data");
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user