Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Watch Support #14

Open
coolbnjmn opened this issue Jul 18, 2021 · 3 comments
Open

Question: Watch Support #14

coolbnjmn opened this issue Jul 18, 2021 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@coolbnjmn
Copy link

Hi! Thanks for putting together this library, more ways to avoid scenario tests but still tap around are great! :D

Question here more than an issue: currently, this can only be used with UIKit views (it seems), but this could be extended to WatchKit, right? Is that something that you've attempted before? Thanks!

@gabriellanata
Copy link
Contributor

Hello! I tried to run it once and got a bunch of errors because UIScreen and UIWindow are not available on Apple Watch. I'm not even sure if it uses all the same private methods behind the scenes either. I'd be happy to support it but I'm not sure I'll have the time to do that soon. If you're open to trying to add it yourself feel free to contribute!

@gabriellanata gabriellanata added enhancement New feature or request help wanted Extra attention is needed labels Jul 19, 2021
@coolbnjmn
Copy link
Author

Gotcha! Yea I'd imagine you'd get lots of errors when checking that checkbox lol

At a high level, this is currently swizzling all touch methods, and then generating events by grabbing the UIWindow and then adding wrapped, tracked UIViews within that window, is that about right?

I don't believe WatchOS uses a UIWindow, so a lot may not work, but the general concepts should 🤔
I may be interested in putting that effort, but will need to play with this more for iOS unit tests testing UI first!

@gabriellanata
Copy link
Contributor

Kinda, I would describe the process as follows:

  1. Find the touch point in window coordinates
  2. Create an IOHID event object
  3. Get the contextID from the UIWindow
  4. Enqueue the event in UIApplication
  5. Create a "marker" event and send it through the same thing as the previous one
  6. Swizzle handleEvent in UIApplication to detect when the marker event is received, meaning that both 1 and 2 have been completed.

All methods and types mentioned there are private. Once the event is sent through the standard UIApplication piping, it behaves as a real touch on a view without any modifications. I'm guessing this would work the same in a watch application.

Things we'd need to figure out:

  • Does watch use IOHID behind the scenes too?
  • Do the watch equivalents of UIWindow and UIApplication support the stuff we need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants