-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMPWSiteMap.m
74 lines (60 loc) · 2.03 KB
/
MPWSiteMap.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// MPWSiteMap.m
// ObjectiveHTTPD
//
// Created by Marcel Weiher on 7/4/07.
// Copyright 2007 Marcel Weiher. All rights reserved.
//
#import "MPWSiteMap.h"
#import "WAHtmlRenderer.h"
#import "MPWHtmlPage.h"
#import "MPWTemplater.h"
#import "MPWHTMLRenderScheme.h"
@implementation MPWSiteMap
+sharedSite
{
static id site=nil;
if ( !site ) {
site=[self alloc];
site=[site init];
}
return site;
}
@end
@implementation MPWSiteMap(testing)
+_configuredSite
{
id site=[[[self alloc] init] autorelease];
MPWTemplater* templater=[[[MPWTemplater alloc] init] autorelease];
MPWHtmlPage* template = [[[MPWHtmlPage alloc] init] autorelease];
[templater setTemplate:template];
[templater setSourceScheme:site];
id renderer = [[[MPWHTMLRenderScheme alloc] init] autorelease];
[renderer setSourceScheme:templater];
return renderer;
}
+(void)testPlainPageIsSameBothTimes
{
MPWAbstractStore *templater=[self _configuredSite];
NSLog(@"will get page");
id page = [templater get:@"index.html"];
NSLog(@"did get page: %@",page);
id result = [page stringValue];
NSLog(@"got result (page stringValue): %@",result);
IDEXPECT( result, @"<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"></meta><title></title></head><body></body></html>", @"html for index.html");
result = [[templater get:@"index.html"] stringValue];
IDEXPECT( result, @"<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"></meta><title></title></head><body></body></html>", @"html for index.html second time");
}
+(void)testPlainPageWithTitle
{
id templater=[self _configuredSite];
[templater setTitle:@"My great title"];
id result = [[templater get:@"index.html"] stringValue];
IDEXPECT( result, @"<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"></meta><title></title></head><body></body></html>", @"html for index.html");
}
+testSelectors {
return [NSArray arrayWithObjects:
@"testPlainPageIsSameBothTimes",
nil];
}
@end