Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit b1b8bb6

Browse files
TextAutosizingBoost.ChangeAutosizingBoostAtRuntime fails on iPad Simulator
https://bugs.webkit.org/show_bug.cgi?id=200402 <rdar://problem/53823368> Reviewed by Tim Horton. Make it possible to run this test using the iPad simulator. * TestWebKitAPI/Tests/ios/TextAutosizingBoost.mm: Two adjustments: (1) override the screen size to be 320 by 568 (so that the legacy text autosizing heuristic doesn't avoid boosting this text), and (2) force text autosizing on, but disable idempotent text autosizing, since this would result in differently sized text. (mainScreenReferenceBoundsOverride): * TestWebKitAPI/ios/UIKitSPI.h: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@248186 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent b2f0d28 commit b1b8bb6

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

Tools/ChangeLog

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2019-08-02 Wenson Hsieh <[email protected]>
2+
3+
TextAutosizingBoost.ChangeAutosizingBoostAtRuntime fails on iPad Simulator
4+
https://bugs.webkit.org/show_bug.cgi?id=200402
5+
<rdar://problem/53823368>
6+
7+
Reviewed by Tim Horton.
8+
9+
Make it possible to run this test using the iPad simulator.
10+
11+
* TestWebKitAPI/Tests/ios/TextAutosizingBoost.mm:
12+
13+
Two adjustments: (1) override the screen size to be 320 by 568 (so that the legacy text autosizing heuristic
14+
doesn't avoid boosting this text), and (2) force text autosizing on, but disable idempotent text autosizing,
15+
since this would result in differently sized text.
16+
17+
(mainScreenReferenceBoundsOverride):
18+
* TestWebKitAPI/ios/UIKitSPI.h:
19+
120
2019-08-02 Sihui Liu <[email protected]>
221

322
API tests using permanent credentials should clear credentials left by previous tests

Tools/TestWebKitAPI/Tests/ios/TextAutosizingBoost.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,28 @@
2525

2626
#include "config.h"
2727

28+
#import "InstanceMethodSwizzler.h"
2829
#import "TestWKWebView.h"
30+
#import "UIKitSPI.h"
2931
#import <WebKit/WKPreferencesPrivate.h>
32+
#import <WebKit/WKPreferencesRef.h>
3033

3134
#if PLATFORM(IOS_FAMILY)
3235

36+
static CGRect mainScreenReferenceBoundsOverride(id, SEL)
37+
{
38+
return CGRectMake(0, 0, 320, 568);
39+
}
40+
3341
TEST(TextAutosizingBoost, ChangeAutosizingBoostAtRuntime)
3442
{
3543
static NSString *testMarkup = @"<meta name='viewport' content='width=device-width'><body style='margin: 0'><span id='top'>Hello world</span><br><span id='bottom'>Goodbye world</span></body>";
3644

45+
InstanceMethodSwizzler screenSizeSwizzler(UIScreen.class, @selector(_referenceBounds), reinterpret_cast<IMP>(mainScreenReferenceBoundsOverride));
46+
3747
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 960, 360)]);
48+
WKPreferencesSetTextAutosizingEnabled((__bridge WKPreferencesRef)[webView configuration].preferences, true);
49+
WKPreferencesSetTextAutosizingUsesIdempotentMode((__bridge WKPreferencesRef)[webView configuration].preferences, false);
3850
[webView synchronouslyLoadHTMLString:testMarkup];
3951
CGSize regularSize {
4052
roundf([[webView objectByEvaluatingJavaScript:@"document.getElementById('top').getBoundingClientRect().width"] floatValue]),

Tools/TestWebKitAPI/ios/UIKitSPI.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#import <UIKit/UIKeyboardImpl.h>
3636
#import <UIKit/UIKeyboard_Private.h>
3737
#import <UIKit/UIResponder_Private.h>
38+
#import <UIKit/UIScreen_Private.h>
3839
#import <UIKit/UITextInputMultiDocument.h>
3940
#import <UIKit/UITextInputTraits_Private.h>
4041
#import <UIKit/UITextInput_Private.h>
@@ -175,6 +176,10 @@ IGNORE_WARNINGS_BEGIN("deprecated-implementations")
175176

176177
IGNORE_WARNINGS_END
177178

179+
@interface UIScreen ()
180+
@property (nonatomic, readonly) CGRect _referenceBounds;
181+
@end
182+
178183
#endif
179184

180185
#if __has_include(<UIKit/UITextAutofillSuggestion.h>)

0 commit comments

Comments
 (0)