PageRenderTime 34ms CodeModel.GetById 29ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/Tests/Manual/FF4096Test/AppController.j

http://github.com/cacaodev/cappuccino
Unknown | 47 lines | 32 code | 15 blank | 0 comment | 0 complexity | f8d3c4c13a6788355752c0e8db37e4c0 MD5 | raw file
 1/* 
 2 * AppController.j
 3 * FFTest
 4 *
 5 * Created by C. Blair Duncan on September 22, 2010.
 6
 7This test will verify that the framework is or is not returning truncated data in Firefox.
 8See issue: http://githubissues.heroku.com/#280north/cappuccino/842
 9 */
10
11@import <Foundation/CPObject.j>
12
13
14@implementation AppController : CPObject
15{
16}
17
18- (void)applicationDidFinishLaunching:(CPNotification)aNotification
19{
20    var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
21        contentView = [theWindow contentView];
22
23
24    //due to FireFox x-site and not allowing local file bs, we just read a file from the resourse folder...
25	var aURL = [CPURL URLWithString:[[CPBundle mainBundle] pathForResource:@"sampleXML.data"]];
26
27    // note, normally you should not be using a synchronous request for your work 
28    var data = [CPURLConnection sendSynchronousRequest:[CPURLRequest requestWithURL:aURL] returningResponse:NULL];
29
30    var dict = [CPPropertyListSerialization propertyListFromData:data format:CPPropertyListXMLFormat_v1_0];
31
32    var theData = [dict valueForKey:@"LongString"];
33    alert("Read " + theData.length + " bytes, \(should be 8122\)");
34
35
36    var label = [[CPTextField alloc] initWithFrame:[contentView bounds]];
37    [label setLineBreakMode:CPLineBreakByWordWrapping]; 
38    [label setStringValue:theData];
39    [label setFont:[CPFont systemFontOfSize:14.0]];
40    [label setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
41
42    [contentView addSubview:label];
43    [theWindow orderFront:self];
44}
45
46
47@end