Islet/tests/prefstest.m
astar76 c88455c759 Islet 0.7.6: a Dynamic Island for notched iPhones
SpringBoard tweak for the iPhone XR on iOS 18.7.1 (Dopamine rootless),
built without Theos using the swift.org clang and linked on the phone.

The island shows music with Apple's audio analyzer and live lyrics, timers,
calls, flashlight, screen recording, accessories and their batteries, calendar,
notifications with actions, and system popups, in portrait and landscape.
Includes a Settings page, a Watch ping hook, an offscreen self test and the
tools that capture the showcase video.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 19:03:58 -06:00

35 lines
2.1 KiB
Objective-C

// Drives the Settings bundle's list controller in a throwaway process: class, plist loading, read and write.
// Env ISLET_PREFS_BUNDLE points at the unpacked bundle, ISLET_PREFS_FILE at a scratch plist. Build arm64 (uses literals).
#import <Foundation/Foundation.h>
#import <objc/message.h>
#import <dlfcn.h>
int main(int argc, char **argv) { @autoreleasepool {
void *h = dlopen(argv[1], RTLD_NOW);
printf("dlopen: %s\n", h ? "ok" : dlerror());
Class c = NSClassFromString(@"IsletRootListController");
printf("class: %s\n", c ? "ok" : "MISSING");
if (!c) return 1;
id lc = [[c alloc] init];
NSBundle *b = [lc performSelector:@selector(bundle)];
printf("bundle: %s\n", b.bundlePath.UTF8String);
NSArray *specs = [lc performSelector:@selector(specifiers)];
printf("specifiers: %lu\n", (unsigned long)specs.count);
int switches = 0, sliders = 0, withKey = 0; id target = nil;
for (id s in specs) {
id key = [s performSelector:@selector(propertyForKey:) withObject:@"key"];
if (key) withKey++;
if ([[key description] isEqual:@"hideSeconds"]) target = s;
NSString *cell = [s description]; (void)cell;
id def = [s performSelector:@selector(propertyForKey:) withObject:@"default"];
if ([def isKindOfClass:NSClassFromString(@"__NSCFBoolean")]) switches++; else if (def) sliders++;
}
printf("keys=%d switches=%d sliders=%d\n", withKey, switches, sliders);
id before = [lc performSelector:@selector(readPreferenceValue:) withObject:target];
[lc performSelector:@selector(setPreferenceValue:specifier:) withObject:@33 withObject:target];
id after = [lc performSelector:@selector(readPreferenceValue:) withObject:target];
printf("read default=%s after write=%s\n", [before description].UTF8String, [after description].UTF8String);
[lc performSelector:@selector(resetNow)];
id reset = [lc performSelector:@selector(readPreferenceValue:) withObject:target];
printf("after reset=%s\n", [reset description].UTF8String);
printf("%s\n", [after intValue] == 33 && [reset isEqual:before] && specs.count > 30 ? "PASS" : "FAIL");
} return 0; }