Title: [232766] trunk/Tools
Revision
232766
Author
timothy_hor...@apple.com
Date
2018-06-12 11:53:30 -0700 (Tue, 12 Jun 2018)

Log Message

Add a API test for r232601
https://bugs.webkit.org/show_bug.cgi?id=186417

Reviewed by Wenson Hsieh.

* TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm:
(immediateSubviewOfClass):
(TEST):
Ensure that we put the view hierarchy back together (move WKContentView
out of the animated resize view) and unhide WKContentView after a
resize-with-hidden-content.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (232765 => 232766)


--- trunk/Tools/ChangeLog	2018-06-12 18:40:50 UTC (rev 232765)
+++ trunk/Tools/ChangeLog	2018-06-12 18:53:30 UTC (rev 232766)
@@ -1,3 +1,17 @@
+2018-06-12  Tim Horton  <timothy_hor...@apple.com>
+
+        Add a API test for r232601
+        https://bugs.webkit.org/show_bug.cgi?id=186417
+
+        Reviewed by Wenson Hsieh.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm:
+        (immediateSubviewOfClass):
+        (TEST):
+        Ensure that we put the view hierarchy back together (move WKContentView
+        out of the animated resize view) and unhide WKContentView after a
+        resize-with-hidden-content.
+
 2018-06-12  Valerie R Young  <vale...@bocoup.com>
 
         test262/Runner.pm: add unit tests

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm (232765 => 232766)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm	2018-06-12 18:40:50 UTC (rev 232765)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm	2018-06-12 18:53:30 UTC (rev 232766)
@@ -26,6 +26,7 @@
 #include "config.h"
 
 #import "PlatformUtilities.h"
+#import "Test.h"
 #import "TestNavigationDelegate.h"
 #import <WebKit/WKPreferences.h>
 #import <WebKit/WKProcessPoolPrivate.h>
@@ -288,4 +289,62 @@
     TestWebKitAPI::Util::run(&didReadLayoutSize);
 }
 
+static UIView *immediateSubviewOfClass(UIView *view, Class cls)
+{
+    UIView *foundSubview = nil;
+    
+    for (UIView *subview in view.subviews) {
+        if ([subview isKindOfClass:cls]) {
+            // Make it harder to write a bad test; if there's more than one subview
+            // of the given class, fail the test!
+            ASSERT(!foundSubview);
+
+            foundSubview = subview;
+        }
+    }
+
+    return foundSubview;
+}
+
+TEST(WebKit, ResizeWithContentHiddenCompletes)
+{
+    auto webView = createAnimatedResizeWebView();
+    [webView setUIDelegate:webView.get()];
+    
+    [webView loadHTMLString:@"<head><meta name='viewport' content='initial-scale=1'></head>" baseURL:nil];
+    auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]);
+    webView.get().navigationDelegate = navigationDelegate.get();
+    [navigationDelegate waitForDidFinishNavigation];
+    
+    auto window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
+    [window addSubview:webView.get()];
+    [window setHidden:NO];
+    
+    [webView _resizeWhileHidingContentWithUpdates:^{
+        [webView setFrame:CGRectMake(0, 0, 100, 200)];
+    }];
+    
+    __block bool didReadLayoutSize = false;
+    [webView _doAfterNextPresentationUpdate:^{
+        [webView evaluateJavaScript:@"[window.innerWidth, window.innerHeight]" completionHandler:^(id value, NSError *error) {
+            CGFloat innerWidth = [[value objectAtIndex:0] floatValue];
+            CGFloat innerHeight = [[value objectAtIndex:1] floatValue];
+            
+            EXPECT_EQ(innerWidth, 100);
+            EXPECT_EQ(innerHeight, 200);
+            
+            didReadLayoutSize = true;
+        }];
+    }];
+    TestWebKitAPI::Util::run(&didReadLayoutSize);
+    
+    UIView *scrollView = immediateSubviewOfClass(webView.get(), NSClassFromString(@"WKScrollView"));
+    UIView *contentView = immediateSubviewOfClass(scrollView, NSClassFromString(@"WKContentView"));
+    
+    // Make sure that we've put the view hierarchy back together after the resize completed.
+    EXPECT_NOT_NULL(scrollView);
+    EXPECT_NOT_NULL(contentView);
+    EXPECT_FALSE(contentView.hidden);
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to