⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 277209 in webkit


Ignore:
Timestamp:
May 7, 2021, 4:03:43 PM (5 years ago)
Author:
Brent Fulgham
Message:

[iOS] Make AccessibilityReduceMotion test case work on iOS
​https://bugs.webkit.org/show_bug.cgi?id=225244
<rdar://problem/77589455>

Reviewed by Per Arne Vollan.

New tests for Accessibility-related features were added in Bug 215664, but only for macOS.
We support these same features on iOS, and should have test coverage.

Source/WebKit:

Tested by AccessibilityReduceMotion.mm.

  • Platform/spi/Cocoa/AccessibilitySupportSPI.h:

Tools:

  • TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm:

(notificationCallback):
(TEST):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r277208 r277209  
     12021-05-07  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [iOS] Make AccessibilityReduceMotion test case work on iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=225244
     5        <rdar://problem/77589455>
     6
     7        Reviewed by Per Arne Vollan.
     8
     9        New tests for Accessibility-related features were added in Bug 215664, but only for macOS.
     10        We support these same features on iOS, and should have test coverage.
     11
     12        Tested by AccessibilityReduceMotion.mm.
     13
     14        * Platform/spi/Cocoa/AccessibilitySupportSPI.h:
     15
    1162021-05-07  Brent Fulgham  <bfulgham@apple.com>
    217
  • trunk/Source/WebKit/Platform/spi/Cocoa/AccessibilitySupportSPI.h

    r277206 r277209  
    4141#endif
    4242
     43#if PLATFORM(IOS_FAMILY)
     44extern CFStringRef kAXSReduceMotionPreference;
     45extern CFStringRef kAXSReduceMotionChangedNotification;
     46#endif
     47
    4348#if PLATFORM(IOS_FAMILY) && ENABLE(FULL_KEYBOARD_ACCESS)
    4449extern CFStringRef kAXSFullKeyboardAccessEnabledNotification;
  • trunk/Tools/ChangeLog

    r277206 r277209  
     12021-05-07  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [iOS] Make AccessibilityReduceMotion test case work on iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=225244
     5        <rdar://problem/77589455>
     6
     7        Reviewed by Per Arne Vollan.
     8
     9        New tests for Accessibility-related features were added in Bug 215664, but only for macOS.
     10        We support these same features on iOS, and should have test coverage.
     11
     12        * TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm:
     13        (notificationCallback):
     14        (TEST):
     15
    1162021-05-07  Commit Queue  <commit-queue@webkit.org>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/AccessibilityReduceMotion.mm

    r277206 r277209  
    2626#import "config.h"
    2727
    28 #if WK_HAVE_C_SPI && ENABLE(CFPREFS_DIRECT_MODE)
     28#if ENABLE(CFPREFS_DIRECT_MODE)
    2929
    3030#import "PlatformUtilities.h"
    3131#import "TestWKWebView.h"
     32#import "WKWebViewConfigurationExtras.h"
    3233#import <WebKit/PreferenceObserver.h>
    3334#import <WebKit/WKProcessPoolPrivate.h>
    3435#import <WebKit/_WKProcessPoolConfiguration.h>
    3536
     37#if PLATFORM(MAC)
    3638#import <pal/spi/mac/HIServicesSPI.h>
     39#endif
     40
     41#if PLATFORM(IOS_FAMILY)
     42#include <pal/spi/cocoa/AccessibilitySupportSPI.h>
     43#include <wtf/SoftLinking.h>
     44
     45SOFT_LINK_LIBRARY(libAccessibility)
     46SOFT_LINK_CONSTANT(libAccessibility, kAXSReduceMotionPreference, CFStringRef);
     47SOFT_LINK_CONSTANT(libAccessibility, kAXSReduceMotionChangedNotification, CFStringRef);
     48
     49#define NOTIFICATION_CENTER CFNotificationCenterGetDarwinNotifyCenter()
     50#define REDUCED_MOTION_PREFERENCE getkAXSReduceMotionPreference()
     51#define REDUCED_MOTION_CHANGED_NOTIFICATION getkAXSReduceMotionChangedNotification()
     52#define ACCESSIBILITY_DOMAIN CFSTR("com.apple.Accessibility")
     53#else
     54#define NOTIFICATION_CENTER CFNotificationCenterGetDistributedCenter()
     55#define REDUCED_MOTION_PREFERENCE kAXInterfaceReduceMotionKey
     56#define REDUCED_MOTION_CHANGED_NOTIFICATION kAXInterfaceReduceMotionStatusDidChangeNotification
     57#define ACCESSIBILITY_DOMAIN CFSTR("com.apple.universalaccess")
     58#endif
    3759
    3860static bool reduceMotionNotificationReceived = false;
    … …  
    5173@end
    5274
     75static void notificationCallback(CFNotificationCenterRef center, void *observer, CFNotificationName name, const void *object, CFDictionaryRef userInfo)
     76{
     77    reduceMotionNotificationReceived = true;
     78}
     79
    5380TEST(WebKit, AccessibilityReduceMotion)
    5481{
    55     RetainPtr<NSObject> accessibilityObserver = [[NSDistributedNotificationCenter defaultCenter] addObserverForName:(__bridge id)kAXInterfaceReduceMotionStatusDidChangeNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) {
    56         reduceMotionNotificationReceived = true;
    57     }];
     82    CFNotificationCenterAddObserver(NOTIFICATION_CENTER, nullptr, &notificationCallback, REDUCED_MOTION_CHANGED_NOTIFICATION, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately);
    5883
    59     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
    60     WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
    61     configuration.get().processPool = (WKProcessPool *)context.get();
    62     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
     84    WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES];
     85    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration addToWindow:YES]);
    6386
    64     CFPreferencesSetAppValue(kAXInterfaceReduceMotionKey, kCFBooleanFalse, CFSTR("com.apple.universalaccess"));
     87    CFPreferencesSetAppValue(REDUCED_MOTION_PREFERENCE, kCFBooleanFalse, ACCESSIBILITY_DOMAIN);
    6588
    6689    auto observer = adoptNS([[WKPreferenceObserverForTesting alloc] init]);
    … …  
    6891    [webView synchronouslyLoadTestPageNamed:@"simple"];
    6992
    70     CFPreferencesSetAppValue(kAXInterfaceReduceMotionKey, kCFBooleanTrue, CFSTR("com.apple.universalaccess"));
    71 
    72     TestWebKitAPI::Util::run(&receivedPreferenceNotification);
    73 
    7493    auto reduceMotion = [&] {
    7594        return [webView stringByEvaluatingJavaScript:@"window.internals.userPrefersReducedMotion()"].boolValue;
    7695    };
    77    
     96
     97    ASSERT_FALSE(reduceMotion());
     98
     99    reduceMotionNotificationReceived = false;
     100
     101    CFPreferencesSetAppValue(REDUCED_MOTION_PREFERENCE, kCFBooleanTrue, ACCESSIBILITY_DOMAIN);
     102
     103    TestWebKitAPI::Util::run(&receivedPreferenceNotification);
     104    TestWebKitAPI::Util::run(&reduceMotionNotificationReceived);
     105
    78106    [webView synchronouslyLoadTestPageNamed:@"simple"];
    79 
    80     TestWebKitAPI::Util::run(&reduceMotionNotificationReceived);
    81107
    82108    ASSERT_TRUE(reduceMotion());
    83109
    84     CFPreferencesSetAppValue(kAXInterfaceReduceMotionKey, nullptr, CFSTR("com.apple.universalaccess"));
     110    CFPreferencesSetAppValue(REDUCED_MOTION_PREFERENCE, nullptr, ACCESSIBILITY_DOMAIN);
    85111
    86     [[NSNotificationCenter defaultCenter] removeObserver:accessibilityObserver.get()];
     112    CFNotificationCenterRemoveObserver(NOTIFICATION_CENTER, nullptr, REDUCED_MOTION_CHANGED_NOTIFICATION, nullptr);
    87113}
    88114
Note: See TracChangeset for help on using the changeset viewer.