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
Added unit tests for display.toggle_fullscreen and display.get_active #1927
Conversation
Follow up: it looks like one of the reasons for the unsuccessful build is because of the bullet point number 1. Guidance on how I should address this would be appreciated! I will address the other errors soon! |
Since this is happening locally and nor just on CI it sounds like a bug with get_active(). One of the issues we are trying to solve with getting unit tests for everything is finding actual bugs lurking in the code. I will have a poke at this tomorrow. Sometimes the Continuous Integration builds behave differently to local builds.
Interesting, I guess it can't really make a full screen display with 0 pixels to play with so picking a reasonable default seems OK to me? |
Thank you for the response. In the meantime, I will fix some of the other errors that popped up with the CI. I will keep it on my local branch until I hear back about get_active(). Thanks again! |
I'm using this MOR from the old bug:
Last time @illume reported that it worked on mac and @nthykier reported that it worked on his machine, which I'm guessing is probably linux of some flavour? |
Tried that same code on Raspberry Pi OS (which is basically Debian) and it works fine. So it's looking like it is probably a windows issue. |
Poked at the C code some, it looks like on windows Perhaps you could change the appropriate lines of
And see if it makes your tests work locally at least? Not sure how comfortable you are with editing C code and compiling pygame. |
Hi @MyreMylar , I am actually using Ubuntu 16.04. I tried the MOR a few posts above, and my command line is being flooded with False so it seems like it's working. In terms of the change to the C code, I applied it and then did the following: I still got the output where get_active would return true after a call to iconify, although I'm not entirely sure that I am rebuilding/recompiling it properly after changing the C code. Update: curiously, I am also getting a get_active error from the Travis CI from python 3.5 where line 73 assert fails. Basically this assert is right after a pygame.display.quit() to check that we get a false initially. It seems like all other fails are from the iconify issue mentioned above. Also please ignore the third commit below as it was a mistake that I made and fixed. |
63d0b64
to
5013aeb
Compare
Not looked over what you've done yet, but I wonder if a couple of calls to pygame.event.get() or pygame.event.pump() after calling iconify() will sort out the issue for the unit tests, at least locally. I suspect that it might be the sort of SDL instruction where it sends a request to the OS and then waits for an event to come back to know if it worked. On the CI you may always have a problem with the 'dummy' video driver they use there, that causes many display related test problems. |
Follow up: |
I guess an iconify() test case would be useful to check that. Modifying the code above:
For me, on windows & Rasperry Pi, that makes pressing any key minimize the window just as if I'd pressed the minimize button on the menu bar. It doesn't print False when minimized on dev10, but it does if I rebuild pygame adding the C code change mentioned above. If |
Just tried the above code using |
I tried the above code and it looks like it’s working! To test the code without manually pressing a key, I used pygame.event to post a keydown event. I will make a commit once I factor this in to the unit test and make sure everything’s working locally |
… into display-test-branch
Update my fork
Update: the previous commits were my attempts to fix get_active. However, the CI builds are all terminating because of a lack of output for 10 + minutes. I thought this might have been because of an infinite loop, but when I commented out the loop, the CI builds are still terminating. |
I would expect this test to fail if the user is using a tiling window manager. |
OK, I investigated this a bit.
On windows and so long as you have also added the C code change above it will pass locally.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes as indicated above.
Update fork
update fork
update my branch
Hi I made the changes requested above, but I am still getting the issue where my CI builds are terminating because of a lack of output for 10 minutes. The previous 3 commits were to make sure everything is updated with my fork/branch, but I don't know where the issue stems from. |
From what I can tell Travis is failing on the SDL1 build on line 74. It looks to me it like there is an arguable bug in SDL 1 there. It appears that:
is returning True before a window has even been created. I think we could make the case for changing SDL 1's get_active to something like:
to fit better with how the docs describe the function working only after set_mode has been called. That's not tested code, that's just me quickly eyeballing it to guess what I think might work. Both of these new tests passed on travis on SDL2 so if there is something else up with the Travis builds it is almost certainly not your fault. It looks like a whole bunch of new pull requests were merged so perhaps one of them has sewed chaos. Appveyor hasn't caught up with this PR yet either, but if it passes on there it is probably just Travis having a bad day which happens occasionally. I would try to fix the SDL1 problem either by changing the display.c code (better) or skipping that part of the test on SDL1 (OK). You should be able to test on SDL1 locally by changing the build config and then doing a clean and rebuild, something like:
Or however you do that process on your platform/build environment. You can switch back to sdl2 by doing the same thing but with sdl2 in place of sdl1 on the first line. |
I think probably the toggle fullscreen problems are why this is causing the CI to lock up. |
I expect there may still be some edge cases where the REMINDER: Raise issue to update toggle_fullscreen() docs for pygame 2. It definitely runs on more platforms than just X11 now. |
Checked the current commit on windows under SDL1 & SDL2 and all the tests pass (with the windows get_active() change for SDL2). I'll submit the change to SDL2's version of get_active() (the one from above that makes it work on windows) as a separate PR, unless you want to roll it into here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I don't mind if you submit the SDL2 changes as a separate PR! Thank you for all the help @MyreMylar ! |
Added issue about updating the |
Just holding off merging this until the windows fix can get merged at the same time. |
Hello, this pull request addresses #1743 and #1755.
The unit tests created for display.toggle_fullscreen() and display.get_active() were created with stipulations from the documentation and from my understanding of the code. I used pylint to check my code.
Two things I noticed when testing locally:
The documentation for display.get_active() states that it will return false when an image is iconified. However, iconify returned true, but get_active returned true still.
When running display.set_mode() with width/height of (0,0) and then display.toggle_fullscreen(), the resulting width/height becomes (800, 600) with a display.toggle_fullscreen() return value that is not 1. However for all other width/heights I tried, the resulting width/height is the same as the original with a display.toggle_fullscreen() return value that is not 1.
Please let me know if I should make any changes!