flowkey / UIKit-cross-platform

Cross-platform Swift implementation of UIKit, mostly for Android
MIT License
598 stars 40 forks source link

GLRenderer -> UIScreen #268

Closed michaelknoch closed 5 years ago

michaelknoch commented 5 years ago

Type of change:

Motivation (current vs expected behavior)

tbd

Please check if the PR fulfills these requirements

michaelknoch commented 5 years ago

Also tests are broken for a very interesting reason. (ButtonContentAlignmentTests.swift)

screenshot 2018-10-27 at 18 32 41

It makes sense that this is currently breaking here because UIApplication never inits the main window when running tests. It's very interesting that iOS seems to handle this case. Maybe UIScreen.main should always return a screen?

ephemer commented 5 years ago

@michaelknoch I have made provisions for this in UIScreen.swift but not yet updated the tests.

It’s possible to init a dummy screen in the tests (there is an internal initialiser in that file that we can use with @testable import). I think this is better than the old solution

michaelknoch commented 5 years ago

So we always have to manually init a UIScreen as soon as we are writing tests for UIView or something that depends on it? Sounds like an easy fix but also sounds kind of verbose and iOS seems to handle it different because the buttons tests are passing on iOS. @ephemer

ephemer commented 5 years ago

@michaelknoch there are “global” setup / tear downs. I’d init the screen in there in the UIKit Test target. In practice it should be clean and also explicit, which is better than the kind of random implicit behaviour we used to have

michaelknoch commented 5 years ago

Like the solution! Didn't know that we have this global testing hooks, very useful. I allowed myself to commit some changes @ephemer

Tests are still failing due to some font tests, its working on my machine :ok_woman: