//
//  Test1.m
//  TeXDist
//
//  Created by iTeXMac2 on 17/03/09.
//  Copyright 2009 Laurens'Tribune. All rights reserved.
//

#import "Test1.h"
#import "TeXDistributionUtils.h"


@implementation Test1
- (void)testCase1;
{
	NSLog(@"==== testCase1");
	// load the pref pane bundle
	// test things inside
	NSString * BUILD_DIR = [[[NSProcessInfo processInfo] environment] objectForKey:@"BUILD_DIR"];
	NSString * bundlePath = [BUILD_DIR stringByAppendingPathComponent:@"TeXDistPrefPane.prefPane"];
	BOOL isDirectory = NO;
	NSFileManager * DFM = [NSFileManager defaultManager];
	STAssertTrue([DFM fileExistsAtPath:bundlePath isDirectory:&isDirectory],@"Missing bundle at %@", bundlePath);
	STAssertTrue(isDirectory,@"Missing directory at %@", bundlePath);
	NSBundle * B = [NSBundle bundleWithPath:bundlePath];
	[B load];
	STAssertTrue([B isLoaded],@"Could not load bundle at %@",bundlePath);
	Class TeXDistUtils = [B classNamed:@"TeXDistUtils"];
	STAssertTrue((TeXDistUtils!=Nil),@"Missing class named TeXDistUtils");
	NSArray * expectedPrograms = [TeXDistUtils performSelector:@selector(expectedPrograms)];
	STAssertTrue(([expectedPrograms count]>0),@"Missing expected programs");
	NSArray * CPUNames = [TeXDistUtils performSelector:@selector(CPUNames)];
	STAssertTrue(([CPUNames count]>0),@"Missing expected CPU Names");
	NSLog(@"CPUNames:%@",CPUNames);
	Class TeXDistributionBridge = [B classNamed:@"TeXDistributionBridge"];
	STAssertTrue((TeXDistributionBridge!=Nil),@"Missing class named TeXDistributionBridge");
	NSArray * __TeXDistributions = [TeXDistributionBridge performSelector:@selector(__TeXDistributions)];
	STAssertTrue(([__TeXDistributions count]>0),@"No __TeXDistributions available");
	NSString * output = [TeXDistUtils performSelector:@selector(texdistExtension)];
	NSLog(@"texdistExtension:%@",output);
	output = [TeXDistUtils performSelector:@selector(programsRelativePath)];
	NSLog(@"programsRelativePath:%@",output);
	output = [TeXDistUtils performSelector:@selector(rootRelativePath)];
	NSLog(@"rootRelativePath:%@",output);
	output = [TeXDistUtils performSelector:@selector(activeDistributionPath)];
	NSLog(@"activeDistributionPath:%@",output);
	output = [TeXDistUtils performSelector:@selector(CPUNames)];
	NSLog(@"CPUNames:%@",output);
	output = [TeXDistUtils performSelector:@selector(TeXDistributionsPath)];
	NSLog(@"TeXDistributionsPath:%@",output);
}
@end
