39 行
7.7 KiB
C
39 行
7.7 KiB
C
// Shared author identity and disposable render bindings must stay separate.
|
|
{
|
|
NSMutableDictionary *doc=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);
|
|
NSMutableDictionary *shared=(id)DYAddSharedMask(doc,DYMaskRectangle);NSString *maskID=shared[@"id"];
|
|
run.need(@"shared-mask-can-be-authored-before-any-module-assignment",shared&&DYValidToolDocument(doc)&&DYSharedMasks(doc).count==1&&DYMasksForTool(doc,@"shared").firstObject==shared&&DYMasksForTool(doc,@"base:hsl").count==0);
|
|
NSDictionary *layer=DYInsertTool(doc,@"curve",@"base:curve");NSString *layerID=layer[@"id"];
|
|
BOOL assigned=DYSetSharedMaskAssigned(doc,maskID,@"base:hsl",YES)&&DYSetSharedMaskAssigned(doc,maskID,layerID,YES);
|
|
run.record(@"shared-mask-two-module-bindings-retain-one-author-object",assigned&&DYValidToolDocument(doc)&&DYSharedMasks(doc).count==1&&DYMasksForTool(doc,@"base:hsl").firstObject==DYMasksForTool(doc,layerID).firstObject&&DYToolIDsForSharedMask(doc,maskID).count==2&&[doc[@"baseMasks"][@"hsl"][0][@"sharedID"]isEqual:maskID]&&[doc[@"schema"]isEqual:@3]);
|
|
DYMaskParameters p=DYMaskAtTime(shared,kCMTimeZero);p.centerX=.31;shared[@"parameters"]=[NSData dataWithBytes:&p length:sizeof(p)];DYMaskParameters q=DYMaskAtTime(DYMasksForTool(doc,layerID).firstObject,kCMTimeZero);
|
|
run.record(@"editing-one-shared-mask-updates-all-linked-modules",fabs(q.centerX-.31)<1e-6&&DYSharedMasks(doc).count==1);
|
|
DYMaskParameters moved=p;moved.centerX=.71;DYMergeTracking(shared,@[DYMaskKey(kCMTimeZero,p,YES,1),DYMaskKey(CMTimeMake(2,24),moved,NO,.9)]);
|
|
q=DYMaskAtTime(DYMasksForTool(doc,layerID).firstObject,CMTimeMake(1,24));
|
|
run.record(@"shared-tracking-is-single-timeline-for-every-module",fabs(q.centerX-.51)<1e-6&&[DYMasksForTool(doc,@"base:hsl").firstObject[@"keys"]count]==2);
|
|
DYToolDocument *author=[[[DYToolDocument alloc]init]autorelease];author.document=doc;NSData *encoded=[NSKeyedArchiver archivedDataWithRootObject:author requiringSecureCoding:YES error:&error];DYToolDocument *decoded=[NSKeyedUnarchiver unarchivedObjectOfClass:DYToolDocument.class fromData:encoded error:&error];
|
|
run.record(@"shared-mask-archive-roundtrip-keeps-unique-object-and-links",[decoded isEqual:author]&&DYSharedMasks(decoded.document).count==1&&DYToolIDsForSharedMask(decoded.document,maskID).count==2);
|
|
NSDictionary *snapshot=DYToolRenderSnapshot(doc,CMTimeMake(1,24)),*again=DYToolRenderSnapshot(doc,CMTimeMake(1,24));NSDictionary *base=DYMasksForTool(snapshot,@"base:hsl").firstObject,*extra=DYMasksForTool(snapshot,layerID).firstObject;
|
|
run.record(@"shared-render-snapshot-freezes-all-bindings-with-stable-private-identities",DYValidToolDocument(snapshot)&&[snapshot isEqual:again]&&![base[@"id"]isEqual:extra[@"id"]]&&[base[@"sourceSharedID"]isEqual:maskID]&&[extra[@"sourceSharedID"]isEqual:maskID]&&[base[@"keys"]count]==0&&[extra[@"keys"]count]==0&&fabs(DYMaskAtTime(base,kCMTimeZero).centerX-.51)<1e-6&&[shared[@"keys"]count]==2);
|
|
NSMutableDictionary *bad=DYMutablePlist(doc);bad[@"baseMasks"][@"hsl"]=[NSMutableArray arrayWithObjects:@{@"sharedID":maskID},@{@"sharedID":maskID},nil];run.record(@"shared-mask-rejects-duplicate-binding-in-one-module",!DYValidToolDocument(bad));
|
|
bad=DYMutablePlist(doc);bad[@"baseMasks"][@"hsl"]=[NSMutableArray arrayWithObject:@{@"sharedID":NSUUID.UUID.UUIDString}];run.record(@"shared-mask-rejects-dangling-reference",!DYValidToolDocument(bad));
|
|
bad=DYMutablePlist(doc);bad[@"baseMasks"][@"hsl"]=[NSMutableArray arrayWithObject:DYMutablePlist(shared)];run.record(@"shared-mask-rejects-copied-author-object-with-same-identity",!DYValidToolDocument(bad));
|
|
bad=DYMutablePlist(doc);bad[@"schema"]=@2;run.record(@"legacy-document-cannot-silently-contain-shared-references",!DYValidToolDocument(bad));
|
|
BOOL detached=DYSetSharedMaskAssigned(doc,maskID,@"base:hsl",NO);run.record(@"unlinking-one-module-keeps-shared-mask-and-other-module",detached&&DYMasksForTool(doc,@"base:hsl").count==0&&DYMasksForTool(doc,layerID).count==1&&DYSharedMasks(doc).count==1&&DYValidToolDocument(doc));
|
|
BOOL removed=DYRemoveSharedMask(doc,maskID);run.record(@"deleting-shared-mask-removes-all-references-without-deleting-modules",removed&&DYSharedMasks(doc).count==0&&DYMasksForTool(doc,layerID).count==0&&DYToolWithID(doc,layerID)&&DYValidToolDocument(doc));
|
|
NSMutableDictionary *legacy=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);NSDictionary *old=DYNewMask(DYMaskEllipse);legacy[@"baseMasks"][@"curve"]=[NSMutableArray arrayWithObject:old];NSDictionary *promoted=DYShareToolMask(legacy,@"base:curve",old[@"id"]);
|
|
run.record(@"sharing-legacy-mask-moves-one-object-without-changing-geometry-or-identity",promoted&&[promoted isEqual:old]&&DYSharedMasks(legacy).count==1&&DYMasksForTool(legacy,@"base:curve").firstObject==promoted&&DYValidToolDocument(legacy));
|
|
BOOL removedBase=DYSetBaseToolRemoved(legacy,@"curve",YES);run.record(@"removing-base-module-detaches-reference-and-preserves-shared-object",removedBase&&DYValidToolDocument(legacy)&&DYSharedMasks(legacy).count==1&&DYToolIDsForSharedMask(legacy,old[@"id"]).count==0);
|
|
NSMutableDictionary *limits=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);BOOL sixteen=YES;for(int i=0;i<DYSharedMaskLimit;i++){NSDictionary *item=DYAddSharedMask(limits,DYMaskEllipse);if(i<DYToolMaskLimit)sixteen&=DYSetSharedMaskAssigned(limits,item[@"id"],@"base:hsl",YES);}NSDictionary *seventeenth=DYSharedMasks(limits)[DYToolMaskLimit];
|
|
run.record(@"shared-library-and-per-module-reference-limits-remain-independent",sixteen&&DYSharedMasks(limits).count==DYSharedMaskLimit&&DYMasksForTool(limits,@"base:hsl").count==DYToolMaskLimit&&!DYAddSharedMask(limits,DYMaskRectangle)&&!DYSetSharedMaskAssigned(limits,seventeenth[@"id"],@"base:hsl",YES)&&DYValidToolDocument(limits));
|
|
// More than 65,536 referenced keys, but only 7,000 uniquely authored keys.
|
|
NSMutableDictionary *many=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);NSMutableDictionary *timeline=(id)DYAddSharedMask(many,DYMaskRectangle);NSMutableArray *keys=[NSMutableArray arrayWithCapacity:7000];for(int i=0;i<7000;i++)[keys addObject:DYMaskKey(CMTimeMake(i,24),p,NO,.9)];timeline[@"keys"]=keys;BOOL allBindings=YES;for(NSString *type in [DYToolTypes()subarrayWithRange:NSMakeRange(0,10)])allBindings&=DYSetSharedMaskAssigned(many,timeline[@"id"],[@"base:" stringByAppendingString:type],YES);
|
|
run.record(@"shared-key-budget-counts-author-object-once-regardless-of-bindings",allBindings&&DYValidToolDocument(many)&&DYValidToolDocument(DYToolRenderSnapshot(many,CMTimeMake(50,24)))&&DYValidToolDocument(DYResolvedToolDocument(many)));
|
|
BOOL compactFits=YES,compactRows=YES;
|
|
for(int kind=0;kind<6;kind++){
|
|
NSMutableDictionary *state=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);NSDictionary *mask=DYAddSharedMask(state,kind);NSView<DYWorkspaceMaskEditing> *editor=DYCreateWorkspaceMaskEditor(manager,@"shared");[editor refreshWithDocument:state time:kCMTimeZero];[editor selectMaskID:mask[@"id"]];
|
|
for(NSNumber *width in @[@377,@600,@860,@1200]){[editor setFrameSize:NSMakeSize(width.doubleValue,500)];[editor setFrameSize:NSMakeSize(width.doubleValue,editor.contentHeight)];[editor layoutSubtreeIfNeeded];for(NSView *view in editor.subviews)if(!view.hidden)compactFits&=NSContainsRect(editor.bounds,view.frame)&&view.frame.size.width>0&&view.frame.size.height>0;for(NSDictionary *row in [editor valueForKey:@"_rows"]){NSView *label=row[@"label"],*field=row[@"field"],*slider=row[@"slider"];if(label.hidden)continue;compactRows&=!NSIntersectsRect(label.frame,field.frame)&&!NSIntersectsRect(label.frame,slider.frame)&&!NSIntersectsRect(field.frame,slider.frame)&&field.frame.size.width>=70&&slider.frame.size.width>=140;}}
|
|
}
|
|
run.record(@"workspace-six-mask-editors-fit-377-600-860-1200-point-widths",compactFits&&compactRows);
|
|
}
|