Skip to content

Commit

Permalink
[Fix for issue #14 and tests to work on Xcode 7.0]
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranganath Atreya committed Jan 16, 2016
1 parent c16b049 commit e085fe4
Show file tree
Hide file tree
Showing 32 changed files with 128 additions and 93 deletions.
2 changes: 1 addition & 1 deletion EngineFramework/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>Engine</string>
<key>CFBundleIdentifier</key>
<string>com.daivajnanam.inputmethod.LipikaIME.Engine</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
7 changes: 6 additions & 1 deletion EngineFramework/Sources/DJActiveBufferManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ -(id)init {
if (self == nil) {
return self;
}
engine = [DJInputMethodEngine inputEngineForScheme:[DJLipikaUserSettings schemeName] scriptName:[DJLipikaUserSettings scriptName] type:[DJLipikaUserSettings schemeType]];
if ([DJLipikaUserSettings schemeType] == DJ_GOOGLE) {
engine = [DJInputMethodEngine inputEngineForScheme:[DJLipikaUserSettings customSchemeName] scriptName:nil type:DJ_GOOGLE];
}
else {
engine = [DJInputMethodEngine inputEngineForScheme:[DJLipikaUserSettings schemeName] scriptName:[DJLipikaUserSettings scriptName] type:DJ_LIPIKA];
}
if (engine == nil) {
return nil;
}
Expand Down
3 changes: 2 additions & 1 deletion EngineFramework/Tests/Engine/DJBufferManagerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ @implementation DJGoogleBufferManagerTest

-(void)setUp {
[super setUp];
DJGoogleInputScheme* scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestHappyCase.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestHappyCase.scm"];
DJGoogleInputScheme* scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
DJInputMethodEngine* engine = [[DJInputMethodEngine alloc] initWithScheme:scheme];
manager = [[DJStringBufferManager alloc] initWithEngine:engine];
}
Expand Down
3 changes: 2 additions & 1 deletion EngineFramework/Tests/Engine/DJBufferReplayTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ @implementation DJGoogleBufferReplayTest

-(void)setUp {
[super setUp];
DJGoogleInputScheme* scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestMultipleReplay.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestMultipleReplay.scm"];
DJGoogleInputScheme* scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
DJInputMethodEngine* engine = [[DJInputMethodEngine alloc] initWithScheme:scheme];
manager = [[DJStringBufferManager alloc] initWithEngine:engine];
}
Expand Down
3 changes: 2 additions & 1 deletion EngineFramework/Tests/Google/DJGoogleEngineTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ @implementation DJGoogleEngineTest

- (void)setUp {
[super setUp];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestHappyCase.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestHappyCase.scm"];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
engine = [[DJInputMethodEngine alloc] initWithScheme:scheme];
}

Expand Down
3 changes: 2 additions & 1 deletion EngineFramework/Tests/Google/DJGoogleInputStringText.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ @implementation DJGoogleInputStringText

-(void)setUp {
[super setUp];
DJGoogleInputScheme* scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestMultipleReplay.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestMultipleReplay.scm"];
DJGoogleInputScheme* scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
DJInputMethodEngine* engine = [[DJInputMethodEngine alloc] initWithScheme:scheme];
manager = [[DJStringBufferManager alloc] initWithEngine:engine];
}
Expand Down
3 changes: 2 additions & 1 deletion EngineFramework/Tests/Google/DJGoogleNestedClassTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ @implementation DJGoogleNestedClassTest

- (void)setUp {
[super setUp];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestNestedClass.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestNestedClass.scm"];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
engine = [[DJInputMethodEngine alloc] initWithScheme:scheme];
}

Expand Down
3 changes: 2 additions & 1 deletion EngineFramework/Tests/Google/DJGoogleNestedReverseTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ @implementation DJGoogleNestedReverseTest

- (void)setUp {
[super setUp];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestNestedClass.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestNestedClass.scm"];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
engine = [[DJInputMethodEngine alloc] initWithScheme:scheme];
}

Expand Down
3 changes: 2 additions & 1 deletion EngineFramework/Tests/Google/DJGoogleReverseMapTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ @implementation DJGoogleReverseMapTest

-(void)setUp {
[super setUp];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestHappyCase.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestHappyCase.scm"];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
}

-(void)testHapyCase {
Expand Down
9 changes: 6 additions & 3 deletions EngineFramework/Tests/Google/DJGoogleSchemeTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ @implementation DJGoogleSchemeTest

- (void)setUp {
[super setUp];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestHappyCase.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestHappyCase.scm"];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
}

- (void)testHeaderParsing {
Expand All @@ -53,7 +54,8 @@ - (void)testMappingParsing {
}

-(void)testNonDefaultHeaders {
DJGoogleInputScheme *myScheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestITRANS.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestITRANS.scm"];
DJGoogleInputScheme *myScheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
XCTAssertEqualObjects(@"VowelSigns", [myScheme.forwardMappings classNameForInput:@"u"], @"Unexpected output");
NSString* output = [myScheme.forwardMappings.parseTrie nodeForKey:@"~n"].value;
XCTAssertEqualObjects(output, @"ञ्", @"Unexpected output");
Expand All @@ -62,7 +64,8 @@ -(void)testNonDefaultHeaders {
}

-(void)testPostInputMapping {
DJGoogleInputScheme *myScheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestKsharanam.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestKsharanam.scm"];
DJGoogleInputScheme *myScheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
NSString* output = [myScheme.forwardMappings.parseTrie nodeForKey:@"nj"].value;
XCTAssertEqualObjects(output, @"ञ्", @"Unexpected output");
output = [myScheme.forwardMappings.parseTrie nodeForKey:@"njI"].value;
Expand Down
3 changes: 2 additions & 1 deletion EngineFramework/Tests/Google/DJGoogleSpecialCharsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ @implementation DJGoogleSpecialCharsTest

- (void)setUp {
[super setUp];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./EngineFramework/Tests/Google/Schemes/TestSpecialChars.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"GoogleSchemes/TestSpecialChars.scm"];
scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
}

- (void)testSpecialCharacterParsing {
Expand Down
2 changes: 1 addition & 1 deletion EngineFramework/Tests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.daivajnanam.inputmethod.LipikaIME.Engine.Tests</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
Expand Down
3 changes: 2 additions & 1 deletion EngineFramework/Tests/Lipika/DJLipikaAddendumTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ @implementation DJLipikaAddendumTest

-(void)setUp {
[super setUp];
[DJLipikaSchemeFactory setSchemesDirectory:@"./EngineFramework/Tests/Lipika/Schemes"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"LipikaSchemes"];
[DJLipikaSchemeFactory setSchemesDirectory:filePath];
}

-(void)testHappyCase {
Expand Down
3 changes: 2 additions & 1 deletion EngineFramework/Tests/Lipika/DJLipikaSchemeFactoryTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ @implementation DJLipikaSchemeFactoryTest

-(void)setUp {
[super setUp];
[DJLipikaSchemeFactory setSchemesDirectory:@"./Common/Resources/Schemes"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"Schemes"];
[DJLipikaSchemeFactory setSchemesDirectory:filePath];
}

-(void)testHappyCase {
Expand Down
2 changes: 1 addition & 1 deletion InputSource/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>LipikaIME</string>
<key>CFBundleIdentifier</key>
<string>com.daivajnanam.inputmethod.LipikaIME.InputSource</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
3 changes: 2 additions & 1 deletion InputSource/Sources/Application/DJLipikaClientManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
-(void)onUnFocus;
-(void)onEndSession;
-(void)onCandidateSelected:(NSString *)candidateString;
-(void)changeToSchemeWithName:(NSString *)schemeName forScript:scriptName type:(enum DJSchemeType)type;
-(void)changeToCustomSchemeWithName:(NSString *)schemeName;
-(void)changeToSchemeWithName:(NSString *)schemeName forScript:scriptName;
-(void)commit;

@end
26 changes: 23 additions & 3 deletions InputSource/Sources/Application/DJLipikaClientManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ -(void)onFocus {
}
// Do this in case the user changed the scheme or script on the other window
// This is super cheap because schemes are globally cached
[self changeToSchemeWithName:[DJLipikaUserSettings schemeName] forScript:[DJLipikaUserSettings scriptName] type:[DJLipikaUserSettings schemeType]];
if ([DJLipikaUserSettings schemeType] == DJ_GOOGLE) {
[self changeToCustomSchemeWithName:[DJLipikaUserSettings customSchemeName]];
}
else {
[self changeToSchemeWithName:[DJLipikaUserSettings schemeName] forScript:[DJLipikaUserSettings scriptName]];
}
}

-(void)onUnFocus {
Expand Down Expand Up @@ -155,10 +160,25 @@ -(void)onCandidateSelected:(NSString *)candidateString {
[candidateManager hide];
}

-(void)changeToSchemeWithName:(NSString *)schemeName forScript:scriptName type:(enum DJSchemeType)type {
[self commit];
-(void)changeToCustomSchemeWithName:(NSString *)schemeName {
if (!schemeName) {
[NSException raise:@"Scheme name is nil" format:@"Scheme name is nil"];
}
[self changeToSchemeWithName:schemeName type:DJ_GOOGLE forScript:nil];
}

-(void)changeToSchemeWithName:(NSString *)schemeName forScript:scriptName {
if (!schemeName && !scriptName) {
[NSException raise:@"Both scheme and script names are nil" format:@"Both scheme and script names are nil"];
}
if (!schemeName) schemeName = [DJLipikaUserSettings schemeName];
if (!scriptName) scriptName = [DJLipikaUserSettings scriptName];
[self changeToSchemeWithName:schemeName type:DJ_LIPIKA forScript:scriptName];
}

-(void)changeToSchemeWithName:(NSString *)schemeName type:(enum DJSchemeType)type forScript:scriptName {
[self commit];
logDebug(@"Changing to Scheme: %@ withType: %u forScript: %@", schemeName, type, scriptName);
[bufferManager changeToSchemeWithName:schemeName forScript:scriptName type:type];
// If no exceptions then change the user settings
if (type == DJ_GOOGLE) {
Expand Down
18 changes: 11 additions & 7 deletions InputSource/Sources/Application/DJLipikaInputController.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,24 @@ -(void)clearAllOnStates:(NSMenu *)rootMenu {
}

-(void)changeInputScheme:(NSMenuItem *)menuItem {
BOOL isGoogleItem = [[[[menuItem parentItem] submenu] title] isEqualToString:DJGoogleSubMenu];
BOOL isSchemeItem = [[[[menuItem parentItem] submenu] title] isEqualToString:DJSchemeSubMenu];
BOOL isScriptItem = [[[[menuItem parentItem] submenu] title] isEqualToString:DJScriptSubMenu];
// Try to change to specified script and scheme
NSString *name = [menuItem title];
NSString *subMenuTitle = [[[menuItem parentItem] submenu] title];
BOOL isGoogleItem = [subMenuTitle isEqualToString:DJGoogleSubMenu];
BOOL isSchemeItem = [subMenuTitle isEqualToString:DJSchemeSubMenu];
BOOL isScriptItem = [subMenuTitle isEqualToString:DJScriptSubMenu];
// Try to change to specified script and scheme
@try {
if (isSchemeItem) {
[manager changeToSchemeWithName:name forScript:nil type:DJ_LIPIKA];
[manager changeToSchemeWithName:name forScript:nil];
}
else if (isScriptItem) {
[manager changeToSchemeWithName:nil forScript:name type:DJ_LIPIKA];
[manager changeToSchemeWithName:nil forScript:name];
}
else if (isGoogleItem) {
[manager changeToSchemeWithName:name forScript:nil type:DJ_GOOGLE];
[manager changeToCustomSchemeWithName:name];
}
else {
[NSException raise:@"Unknown sub-menu title" format:@"Unknown sub-menu title: %@", subMenuTitle];
}
}
@catch (NSException *exception) {
Expand Down
File renamed without changes.
7 changes: 3 additions & 4 deletions InputSource/Tests/DJClientManagerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
#import "DJTestClient.h"

@interface DJLipikaSchemeFactory (Test)

+(void)setSchemesDirectory:(NSString *)directory;

@end

@interface DJClientManagerTest : XCTestCase {
Expand All @@ -31,12 +29,13 @@ @implementation DJClientManagerTest

-(void)setUp {
[super setUp];
[DJLipikaSchemeFactory setSchemesDirectory:@"./Common/Resources/Schemes"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"Schemes"];
[DJLipikaSchemeFactory setSchemesDirectory:filePath];
[DJTestHelper setupUserSettings];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"CombineWithPreviousGlyph"];
client = [[DJTestClient alloc] initWithCommittedString:@""];
manager = [[DJLipikaClientManager alloc] initWithClient:[[DJLipikaClientDelegate alloc] initWithClient:client]];
[manager changeToSchemeWithName:@"Barahavat" forScript:@"Devanagari" type:DJ_LIPIKA];
[manager changeToSchemeWithName:@"Barahavat" forScript:@"Devanagari"];
}

-(void)testHappyCase {
Expand Down
32 changes: 25 additions & 7 deletions InputSource/Tests/DJFileConversionTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@

#import <XCTest/XCTest.h>
#import "DJConversionController.h"
#import "DJLipikaSchemeFactory.h"
#import "DJGoogleSchemeFactory.h"

@interface DJLipikaSchemeFactory (Test)
+(void)setSchemesDirectory:(NSString *)directory;
@end

@interface DJConversionController (test)
-(void)convertFileFromPath:(NSString *)fromPath toPath:(NSString *)toPath withEngine:(DJStringBufferManager *)engine isReverseMapping:(BOOL)isReverseMapping;
@end
Expand All @@ -29,12 +34,19 @@ @interface DJFileConversionTest : XCTestCase

@implementation DJFileConversionTest

-(void)setUp {
[super setUp];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"Schemes"];
[DJLipikaSchemeFactory setSchemesDirectory:filePath];
}

- (void)testLipikaForwardConversion {
NSString *outputFile = @"/tmp/DhatupaaTaSvara.itrans.out";
DJStringBufferManager *engine = [[DJStringBufferManager alloc] init];
[engine changeToSchemeWithName:@"ITRANS" forScript:@"Devanagari" type:DJ_LIPIKA];
DJConversionController *controller = [[DJConversionController alloc] init];
[controller convertFileFromPath:@"./InputSource/Tests/Control/DhatupaaTaSvara.itrans" toPath:outputFile withEngine:engine isReverseMapping:NO];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"Control/DhatupaaTaSvara.itrans"];
[controller convertFileFromPath:filePath toPath:outputFile withEngine:engine isReverseMapping:NO];
XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:outputFile isDirectory:NO]);
NSString *contents = [NSString stringWithContentsOfFile:outputFile encoding:NSUTF8StringEncoding error:nil];
NSArray *lines = [contents componentsSeparatedByString:@"\r"];
Expand All @@ -47,7 +59,8 @@ -(void)testLipikaReverseConversion {
DJStringBufferManager *engine = [[DJStringBufferManager alloc] init];
[engine changeToSchemeWithName:@"ITRANS" forScript:@"Devanagari" type:DJ_LIPIKA];
DJConversionController *controller = [[DJConversionController alloc] init];
[controller convertFileFromPath:@"./InputSource/Tests/Control/DhatupaaTaSvara.txt" toPath:outputFile withEngine:engine isReverseMapping:YES];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"Control/DhatupaaTaSvara.txt"];
[controller convertFileFromPath:filePath toPath:outputFile withEngine:engine isReverseMapping:YES];
XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:outputFile isDirectory:NO]);
NSString *contents = [NSString stringWithContentsOfFile:outputFile encoding:NSUTF8StringEncoding error:nil];
NSArray *lines = [contents componentsSeparatedByString:@"\r"];
Expand All @@ -56,11 +69,13 @@ -(void)testLipikaReverseConversion {
}

-(void)testGoogleForwardConversion {
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"CustomSchemes/SA_ITRANS.scm"];
NSString *outputFile = @"/tmp/DhatupaaTaSvara.itrans.out";
DJGoogleInputScheme *scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./InputSource/Tests/Schemes/SA_ITRANS.scm"];
DJGoogleInputScheme *scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
DJStringBufferManager *engine = [[DJStringBufferManager alloc] initWithEngine:[[DJInputMethodEngine alloc] initWithScheme:scheme]];
DJConversionController *controller = [[DJConversionController alloc] init];
[controller convertFileFromPath:@"./InputSource/Tests/Control/DhatupaaTaSvara.itrans" toPath:outputFile withEngine:engine isReverseMapping:NO];
filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"Control/DhatupaaTaSvara.itrans"];
[controller convertFileFromPath:filePath toPath:outputFile withEngine:engine isReverseMapping:NO];
XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:outputFile isDirectory:NO]);
NSString *contents = [NSString stringWithContentsOfFile:outputFile encoding:NSUTF8StringEncoding error:nil];
NSArray *lines = [contents componentsSeparatedByString:@"\r"];
Expand All @@ -69,11 +84,13 @@ -(void)testGoogleForwardConversion {
}

-(void)testGoogleReverseConversion {
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"CustomSchemes/SA_ITRANS.scm"];
NSString *outputFile = @"/tmp/DhatupaaTaSvara.itrans";
DJGoogleInputScheme *scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./InputSource/Tests/Schemes/SA_ITRANS.scm"];
DJGoogleInputScheme *scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
DJStringBufferManager *engine = [[DJStringBufferManager alloc] initWithEngine:[[DJInputMethodEngine alloc] initWithScheme:scheme]];
DJConversionController *controller = [[DJConversionController alloc] init];
[controller convertFileFromPath:@"./InputSource/Tests/Control/DhatupaaTaSvara.txt" toPath:outputFile withEngine:engine isReverseMapping:YES];
filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"Control/DhatupaaTaSvara.txt"];
[controller convertFileFromPath:filePath toPath:outputFile withEngine:engine isReverseMapping:YES];
XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:outputFile isDirectory:NO]);
NSString *contents = [NSString stringWithContentsOfFile:outputFile encoding:NSUTF8StringEncoding error:nil];
NSArray *lines = [contents componentsSeparatedByString:@"\r"];
Expand All @@ -82,7 +99,8 @@ -(void)testGoogleReverseConversion {
}

-(void)testReverseMappingOverrite {
DJGoogleInputScheme *scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:@"./InputSource/Tests/Schemes/SA_ITRANS.scm"];
NSString *filePath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"CustomSchemes/SA_ITRANS.scm"];
DJGoogleInputScheme *scheme = [DJGoogleSchemeFactory inputSchemeForSchemeFile:filePath];
DJStringBufferManager *engine = [[DJStringBufferManager alloc] initWithEngine:[[DJInputMethodEngine alloc] initWithScheme:scheme]];
DJSimpleReverseMapping *mappings = [engine reverseMappings];
DJParseOutput *output = [mappings inputForOutput:@"हर्षे"];
Expand Down
Loading

0 comments on commit e085fe4

Please sign in to comment.