facebookarchive / ios-snapshot-test-case

Snapshot view unit tests for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tvOS: screenshot generated before focus processing?

dcordero opened this issue · comments

Hi, I am trying to make use of this awesome library in a tvOS project. As result of which I am getting a really weird result.

It seems that the screenshots that I am getting from the tests are being generated right before the focus manager assign the focus to one of the views on the screen.

I created this simple project as an example with a couple of previews on the README to make it easier to understand and reproduce the problem:
https://github.com/dcordero/tvOS-SnapshotTesting

Attending to the fact, that assigning the focus to a specific view also implies a sort of animation, this issue would be related with #52

I tried to workaround this issue adding the following code to my test...

let date = Date(timeIntervalSinceNow: 1.0)
RunLoop.current.run(until: date)

... but no success at all, I got exactly the same result.

@dcordero You could try to disable animation on start of your tests:

override class func setUp() {
    super.setUp()
    UIView.setAnimationsEnabled(false)
}

Remember to enable back again after you finish.

If problem still occur drop me a line, and I'll try to check your sample.

@Grubas7 thanks for the feedback, that was a really great idea to disable the animation. On the other hand I gave it a try and it did not work. Still getting the same result.

I wonder if it could be an issue more related to the Focus Manager itself, which might be assigning the focus to the button after the screenshot is generated.

testviewcontroller