Как я могу проверить свой класс, который использует UIWebView
Я хочу сделать тест, но я не знаю, как это сделать (я могу использовать GHUnit).
Это класс, который я хочу проверить:
Communicator.h
@interface Communicator : NSObject
-(void)loadURLWithString:(NSString*)urlString withWebView:(UIWebView*)webView;
@end
Communicator.m
#import "Communicator.h"
@implementation Communicator
##### I WANT TO EXCLUDE THE WEBVIEW BELOW #####
-(void)loadURLWithString:(NSString*)urlString withWebView:(UIWebView*)webView
{
NSURL *url = [[NSURL alloc] initWithString:urlString];
NSURLRequest *r = [[NSURLRequest alloc] initWithURL:url];
[webView loadRequest:r];
}
@end
И это ViewController, который управляет классом коммуникатора.
ViewController.h
#import "Communicator.h"
@interface ViewController : UIViewController <UITextFieldDelegate>
{
Communicator *communicator;
}
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIButton *startButton;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
communicator = [[Communicator alloc] init];
[_startButton addTarget:self action:@selector(startButtonPushed) forControlEvents:UIControlEventTouchDown];
}
- (void)startButtonPushed
{
[communicator loadURLWithString:@"http://www.apple.co.jp" withWebView:_webView];
}
@end
Спасибо за помощь.
1 ответ
Что именно вы хотите проверить? Это нажатие на кнопку заставляет веб-просмотр загружать URL-адрес или веб-просмотр на самом деле отображает содержимое URL-адреса?