Bug 214188 - Add Gamepad tests that exercise the native frameworks
Summary: Add Gamepad tests that exercise the native frameworks
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brady Eidson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-07-10 09:01 PDT by Brady Eidson
Modified: 2020-07-23 09:36 PDT (History)
9 users (show)

See Also:


Attachments
Patch (37.52 KB, patch)
2020-07-22 14:59 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff
Patch (37.29 KB, patch)
2020-07-22 15:06 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff
Patch (37.30 KB, patch)
2020-07-22 15:16 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff
Patch (36.61 KB, patch)
2020-07-22 15:46 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff
Patch (36.63 KB, patch)
2020-07-22 15:59 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff
Patch (39.74 KB, patch)
2020-07-22 18:33 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff
Patch (39.73 KB, patch)
2020-07-22 18:39 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff
Patch (41.06 KB, patch)
2020-07-22 20:01 PDT, Brady Eidson
thorton: review+
Details | Formatted Diff | Diff
PFL (41.59 KB, patch)
2020-07-22 23:31 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brady Eidson 2020-07-10 09:01:08 PDT
Add Gamepad tests that exercise the native frameworks

We need to directly drive GCF (and probably IOHID) framework functionality to test gamepads.
Comment 1 Radar WebKit Bug Importer 2020-07-10 09:01:25 PDT
<rdar://problem/65343674>
Comment 2 Brady Eidson 2020-07-22 14:59:27 PDT
Created attachment 404972 [details]
Patch
Comment 3 Brady Eidson 2020-07-22 15:06:09 PDT
Created attachment 404976 [details]
Patch
Comment 4 Brady Eidson 2020-07-22 15:16:34 PDT
Created attachment 404979 [details]
Patch
Comment 5 Brady Eidson 2020-07-22 15:46:38 PDT
Created attachment 404987 [details]
Patch
Comment 6 Brady Eidson 2020-07-22 15:59:44 PDT
Created attachment 404991 [details]
Patch
Comment 7 Tim Horton 2020-07-22 16:26:21 PDT
Comment on attachment 404991 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=404991&action=review

> Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.h:60
> +    size_t numberOfConnectedGamepads() { return m_gamepads.size(); }

`const`

> Tools/TestWebKitAPI/mac/VirtualGamepad.mm:29
> +#if PLATFORM(MAC) && USE(APPLE_INTERNAL_SDK)

internal-SDK-only tests are quite unusual. is there any reason a combination of SPI headers + stuff is insufficient?
Comment 8 Brady Eidson 2020-07-22 18:33:50 PDT
Created attachment 405007 [details]
Patch
Comment 9 Brady Eidson 2020-07-22 18:39:38 PDT
Created attachment 405008 [details]
Patch
Comment 10 Brady Eidson 2020-07-22 20:01:34 PDT
Created attachment 405012 [details]
Patch
Comment 11 Brady Eidson 2020-07-22 20:02:38 PDT
(In reply to Tim Horton from comment #7)
> Comment on attachment 404991 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=404991&action=review
> 
> > Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.h:60
> > +    size_t numberOfConnectedGamepads() { return m_gamepads.size(); }
> 
> `const`
> 
> > Tools/TestWebKitAPI/mac/VirtualGamepad.mm:29
> > +#if PLATFORM(MAC) && USE(APPLE_INTERNAL_SDK)
> 
> internal-SDK-only tests are quite unusual. is there any reason a combination
> of SPI headers + stuff is insufficient?

ChangeLog covers it - Need an entitlement we can currently only sign in internal builds.
Comment 12 Tim Horton 2020-07-22 22:54:52 PDT
Comment on attachment 405012 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=405012&action=review

> Tools/TestWebKitAPI/Tests/mac/HIDGamepads.mm:98
> +    [[webView window] resignKeyWindow];
> +    [[webView window] makeKeyWindow];

This could use a comment (also I think it's technically working around a bug? but I'm not sure what component the bug is in?)

> Tools/TestWebKitAPI/mac/VirtualGamepad.h:35
> +@class NSString;
> +@class HIDDevice;
> +@class HIDUserDevice;

Sort it! Also, any chance of this header ending up in C++ code? Maybe OBJC_CLASS? (the rest of it seems C++-clean at a glance).

> Tools/TestWebKitAPI/mac/VirtualGamepad.mm:45
> +const uint8_t NimbusDescriptor[] = {

This all hurts a bit. Are there not constants for this? Also, I think everything inside the {} should be indented.

> Tools/TestWebKitAPI/mac/VirtualGamepad.mm:130
> +    m_dispatchQueue = adoptNS(dispatch_queue_create(0, DISPATCH_QUEUE_SERIAL));

I think this should be OSObjectPtr/adoptOSObject? But not 100%, and it may not matter.

> Tools/TestWebKitAPI/mac/VirtualGamepad.mm:133
> +    auto uuid = adoptNS([[NSUUID alloc] init]);
> +    m_uniqueID = [uuid UUIDString];

I think NSUUID.UUID.UUIDString instead of these two
Comment 13 Brady Eidson 2020-07-22 23:20:16 PDT
(In reply to Tim Horton from comment #12)
> Comment on attachment 405012 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=405012&action=review
> 
> > Tools/TestWebKitAPI/Tests/mac/HIDGamepads.mm:98
> > +    [[webView window] resignKeyWindow];
> > +    [[webView window] makeKeyWindow];
> 
> This could use a comment (also I think it's technically working around a
> bug? but I'm not sure what component the bug is in?)

It's not a bug, but rather a really intentional quirky behavior... comment added.

> > Tools/TestWebKitAPI/mac/VirtualGamepad.h:35
> > +@class NSString;
> > +@class HIDDevice;
> > +@class HIDUserDevice;
> 
> Sort it! Also, any chance of this header ending up in C++ code? Maybe
> OBJC_CLASS? (the rest of it seems C++-clean at a glance).

It probably won't ever be in non-objc code, but I changed it anyways.


> > Tools/TestWebKitAPI/mac/VirtualGamepad.mm:45
> > +const uint8_t NimbusDescriptor[] = {
> 
> This all hurts a bit. Are there not constants for this? Also, I think
> everything inside the {} should be indented.

This (and future descriptors that I'll be adding for testing) are actual raw dumps from devices. Normally you literally just see an unformatted string of hex digits.

This formatting is how HID descriptors are generally denoted as a term of art - In the USB HID spec and whatever tooling you might find to help work with them.

I'll actually add a link to the web-based tool I used to turn the raw descriptor into this "human readable" formatting"

As for the bytes themselves, there certainly are not constants for them. Some are "common and constant" but many are actually bitfield options put together.

Think of the bytes as the machine code, and the "human readable" descriptions as the assembly code.


> > Tools/TestWebKitAPI/mac/VirtualGamepad.mm:130
> > +    m_dispatchQueue = adoptNS(dispatch_queue_create(0, DISPATCH_QUEUE_SERIAL));
> 
> I think this should be OSObjectPtr/adoptOSObject? But not 100%, and it may
> not matter.

Never (that I remember) used those, will take a look!

> > Tools/TestWebKitAPI/mac/VirtualGamepad.mm:133
> > +    auto uuid = adoptNS([[NSUUID alloc] init]);
> > +    m_uniqueID = [uuid UUIDString];
> 
> I think NSUUID.UUID.UUIDString instead of these two

Indeed.
Comment 14 Brady Eidson 2020-07-22 23:31:44 PDT
Created attachment 405018 [details]
PFL
Comment 15 Darin Adler 2020-07-23 09:01:57 PDT
Comment on attachment 405012 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=405012&action=review

>>> Tools/TestWebKitAPI/mac/VirtualGamepad.mm:130
>>> +    m_dispatchQueue = adoptNS(dispatch_queue_create(0, DISPATCH_QUEUE_SERIAL));
>> 
>> I think this should be OSObjectPtr/adoptOSObject? But not 100%, and it may not matter.
> 
> Never (that I remember) used those, will take a look!

I wonder if we can make this subtle mistake a compile-time error.
Comment 16 EWS 2020-07-23 09:36:19 PDT
Committed r264769: <https://trac.webkit.org/changeset/264769>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 405018 [details].