mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-29 09:52:03 +00:00
System images defined by a theme failed to propagate into built theme blends. Because the blend task archives each themed object and records the decoded copy, CPImage's coder—which omitted theme values—stripped them during serialization, leaving the compiled Aristo3 theme without image attributes. CPImage now encodes its theme values when present and decodes them when available in the archive, matching the behavior of CPColor and CPFont. Images without theme values serialize unchanged, preserving backward compatibility with existing archives.
47 lines
1.4 KiB
Plaintext
47 lines
1.4 KiB
Plaintext
@import <AppKit/CPImage.j>
|
|
|
|
@implementation CPImageTest : OJTestCase
|
|
{
|
|
}
|
|
|
|
- (void)setUp
|
|
{
|
|
// This will init the global var CPApp which are used internally in the AppKit
|
|
[[CPApplication alloc] init];
|
|
}
|
|
|
|
- (void)testInitWithContentsOfFile_nil
|
|
{
|
|
var image = [[CPImage alloc] initWithContentsOfFile:nil];
|
|
|
|
[self assert:nil equals:image message:@"- CPImage initWithContentsOfFile:nil should return nil"];
|
|
}
|
|
|
|
// MARK: Archiving
|
|
|
|
/*
|
|
A theme records its system images on a CPImage, and the blend task archives that image
|
|
before it records it. The theme values therefore survive archiving.
|
|
*/
|
|
- (void)testAnImageKeepsItsThemeValuesThroughArchiving
|
|
{
|
|
var image = [[CPImage alloc] init],
|
|
value = [CPImage imageWithCSSDictionary:@{ "background-color": "red" } size:CGSizeMake(24.0, 24.0)];
|
|
|
|
[image setValue:value forThemeAttribute:@"font-panel"];
|
|
|
|
var decoded = [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:image]];
|
|
|
|
[self assert:[value cssDictionary] equals:[[decoded valueForThemeAttribute:@"font-panel"] cssDictionary]];
|
|
}
|
|
|
|
- (void)testAnImageWithoutThemeValuesArchivesNoThemeObjects
|
|
{
|
|
var image = [CPImage imageWithCSSDictionary:@{ "background-color": "red" } size:CGSizeMake(24.0, 24.0)],
|
|
data = [CPKeyedArchiver archivedDataWithRootObject:image];
|
|
|
|
[self assertFalse:[[data rawString] containsString:@"CPViewThemeClassKey"]];
|
|
}
|
|
|
|
@end
|