summaryrefslogtreecommitdiff
path: root/Tools/TestWebKitAPI/Tests/WebKit2ObjC
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-12 09:27:39 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-12 09:27:39 +0200
commit3749d61e1f7a59f5ec5067e560af1eb610c82015 (patch)
tree73dc228333948738bbe02976cacca8cd382bc978 /Tools/TestWebKitAPI/Tests/WebKit2ObjC
parentb32b4dcd9a51ab8de6afc53d9e17f8707e1f7a5e (diff)
downloadqtwebkit-3749d61e1f7a59f5ec5067e560af1eb610c82015.tar.gz
Imported WebKit commit a77350243e054f3460d1137301d8b3faee3d2052 (http://svn.webkit.org/repository/webkit/trunk@125365)
New snapshot with build fixes for latest API changes in Qt and all WK1 Win MSVC fixes upstream
Diffstat (limited to 'Tools/TestWebKitAPI/Tests/WebKit2ObjC')
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm105
1 files changed, 98 insertions, 7 deletions
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm b/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm
index f7f175d2e..6cadf0b14 100644
--- a/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm
+++ b/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm
@@ -35,6 +35,8 @@
#import "PlatformUtilities.h"
+namespace {
+
class WKBrowsingContextLoadDelegateTest : public ::testing::Test {
public:
WKProcessGroup *processGroup;
@@ -63,17 +65,32 @@ public:
}
};
-
-static bool simpleLoadDone;
+} // namespace
@interface SimpleLoadDelegate : NSObject <WKBrowsingContextLoadDelegate>
+{
+ bool* _simpleLoadDone;
+}
+
+- (id)initWithFlag:(bool*)flag;
+
@end
@implementation SimpleLoadDelegate
+- (id)initWithFlag:(bool*)flag
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _simpleLoadDone = flag;
+ return self;
+}
+
- (void)browsingContextControllerDidFinishLoad:(WKBrowsingContextController *)sender
{
- simpleLoadDone = true;
+ *_simpleLoadDone = true;
}
@end
@@ -85,8 +102,10 @@ TEST_F(WKBrowsingContextLoadDelegateTest, Empty)
TEST_F(WKBrowsingContextLoadDelegateTest, SimpleLoad)
{
+ bool simpleLoadDone = false;
+
// Add the load delegate.
- SimpleLoadDelegate *loadDelegate = [[SimpleLoadDelegate alloc] init];
+ SimpleLoadDelegate *loadDelegate = [[SimpleLoadDelegate alloc] initWithFlag:&simpleLoadDone];
view.browsingContextController.loadDelegate = loadDelegate;
// Load the file.
@@ -101,28 +120,100 @@ TEST_F(WKBrowsingContextLoadDelegateTest, SimpleLoad)
[loadDelegate release];
}
+TEST_F(WKBrowsingContextLoadDelegateTest, SimpleLoadOfHTMLString)
+{
+ bool simpleLoadDone = false;
+
+ // Add the load delegate.
+ SimpleLoadDelegate *loadDelegate = [[SimpleLoadDelegate alloc] initWithFlag:&simpleLoadDone];
+ view.browsingContextController.loadDelegate = loadDelegate;
+
+ // Load the HTML string.
+ [view.browsingContextController loadHTMLString:@"<html><body>Simple HTML String</body></html>" baseURL:[NSURL URLWithString:@"about:blank"]];
+
+ // Wait for the load to finish.
+ TestWebKitAPI::Util::run(&simpleLoadDone);
+
+ // Tear down the delegate.
+ view.browsingContextController.loadDelegate = nil;
+ [loadDelegate release];
+}
+
+TEST_F(WKBrowsingContextLoadDelegateTest, SimpleLoadOfHTMLString_NilBaseURL)
+{
+ bool simpleLoadDone = false;
+
+ // Add the load delegate.
+ SimpleLoadDelegate *loadDelegate = [[SimpleLoadDelegate alloc] initWithFlag:&simpleLoadDone];
+ view.browsingContextController.loadDelegate = loadDelegate;
+
+ // Load the HTML string, pass nil as the baseURL.
+ [view.browsingContextController loadHTMLString:@"<html><body>Simple HTML String</body></html>" baseURL:nil];
+
+ // Wait for the load to finish.
+ TestWebKitAPI::Util::run(&simpleLoadDone);
+
+ // Tear down the delegate.
+ view.browsingContextController.loadDelegate = nil;
+ [loadDelegate release];
+}
+
+TEST_F(WKBrowsingContextLoadDelegateTest, SimpleLoadOfHTMLString_NilHTMLStringAndBaseURL)
+{
+ bool simpleLoadDone = false;
+
+ // Add the load delegate.
+ SimpleLoadDelegate *loadDelegate = [[SimpleLoadDelegate alloc] initWithFlag:&simpleLoadDone];
+ view.browsingContextController.loadDelegate = loadDelegate;
+
+ // Load the HTML string (as nil).
+ [view.browsingContextController loadHTMLString:nil baseURL:nil];
+
+ // Wait for the load to finish.
+ TestWebKitAPI::Util::run(&simpleLoadDone);
-static bool simpleLoadFailDone;
+ // Tear down the delegate.
+ view.browsingContextController.loadDelegate = nil;
+ [loadDelegate release];
+}
@interface SimpleLoadFailDelegate : NSObject <WKBrowsingContextLoadDelegate>
+{
+ bool* _simpleLoadFailDone;
+}
+
+- (id)initWithFlag:(bool*)flag;
+
@end
@implementation SimpleLoadFailDelegate
+- (id)initWithFlag:(bool*)flag
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _simpleLoadFailDone = flag;
+ return self;
+}
+
- (void)browsingContextControllerDidFailProvisionalLoad:(WKBrowsingContextController *)sender withError:(NSError *)error
{
EXPECT_EQ(-1100, error.code);
EXPECT_WK_STREQ(NSURLErrorDomain, error.domain);
- simpleLoadFailDone = true;
+ *_simpleLoadFailDone = true;
}
@end
TEST_F(WKBrowsingContextLoadDelegateTest, SimpleLoadFail)
{
+ bool simpleLoadFailDone = false;
+
// Add the load delegate.
- SimpleLoadFailDelegate *loadDelegate = [[SimpleLoadFailDelegate alloc] init];
+ SimpleLoadFailDelegate *loadDelegate = [[SimpleLoadFailDelegate alloc] initWithFlag:&simpleLoadFailDone];
view.browsingContextController.loadDelegate = loadDelegate;
// Load a non-existent file.