test: check rendered gold pull-down caption pixels
这个提交包含在:
1 父节点
64ebd20d54
当前提交
da03d16c7e
1 个文件已更改
+5
@@ -26,6 +26,11 @@
|
||||
DYSetThemeIndex(5);auto luminance=[](NSColor *color){NSColor *c=[color colorUsingColorSpace:NSColorSpace.sRGBColorSpace];auto linear=[](double x){return x<=.04045?x/12.92:pow((x+.055)/1.055,2.4);};return .2126*linear(c.redComponent)+.7152*linear(c.greenComponent)+.0722*linear(c.blueComponent);};
|
||||
double minimum=100;for(NSString *text in @[@"text",@"secondary"])for(NSString *surface in @[@"background",@"backgroundEnd",@"card",@"cardEnd",@"field",@"headerTop"])minimum=std::min(minimum,(luminance(DYThemePalette()[text])+.05)/(luminance(DYThemePalette()[surface])+.05));
|
||||
run.record(@"compact-gold-labels-have-readable-contrast",minimum>=4.5,@{@"minimumContrast":@(minimum)});
|
||||
DYThemePopUpButton *pullDown=[[[DYThemePopUpButton alloc]initWithFrame:NSMakeRect(0,0,240,28) pullsDown:YES]autorelease];[pullDown addItemWithTitle:@"+ 添加模块"];pullDown.font=[NSFont systemFontOfSize:11];
|
||||
NSBitmapImageRep *bitmap=[[[NSBitmapImageRep alloc]initWithBitmapDataPlanes:NULL pixelsWide:240 pixelsHigh:28 bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace bytesPerRow:0 bitsPerPixel:0]autorelease];
|
||||
[NSGraphicsContext saveGraphicsState];[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:bitmap]];[pullDown drawRect:pullDown.bounds];[NSGraphicsContext restoreGraphicsState];NSUInteger glyphPixels=0;
|
||||
for(int y=6;y<23;y++)for(int x=9;x<90;x++){NSColor *c=[bitmap colorAtX:x y:y];if(c.redComponent>.55&&c.greenComponent>.35)glyphPixels++;}
|
||||
run.record(@"compact-gold-pull-down-draws-readable-caption",glyphPixels>30,@{@"brightCaptionPixels":@(glyphPixels)});
|
||||
BOOL reduced=NSWorkspace.sharedWorkspace.accessibilityDisplayShouldIncreaseContrast||NSWorkspace.sharedWorkspace.accessibilityDisplayShouldReduceTransparency;
|
||||
run.record(@"compact-gold-glow-respects-system-display-options",reduced?DYThemeTextShadow()==nil:DYThemeTextShadow().shadowBlurRadius<=2);
|
||||
}@finally{DYSetThemeIndex(previous);}
|
||||
|
||||
在新工单中引用
屏蔽一个用户