起動後にアプリデリゲートの作成ウィンドウをキーウィンドウとしてテストしたいと思います。そこで、以下のテストを書きます。
- (void)setUp
{
window = [[UIWindow alloc] init];
appDelegate = [[FGAppDelegate alloc] init];
appDelegate.window = window;
appDidFinishLaunchingReturn = [appDelegate application: nil didFinishLaunchingWithOptions:nil];
}
- (void)tearDown
{
window = nil;
appDelegate = nil;
}
- (void)testWindowIsKeyAfterApplicationLaunch
{
STAssertTrue(window.keyWindow, @"App delegate's window should be key.");
}
私のアプリでは、メソッド applicaton:didFinishLaunchingWithOptions: をデリゲートします。
...
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
テストは失敗し、window.keyWindow は true である必要があると言われました。何か間違っていることでも?どうすればテストを修正できますか?