|
|
Chromium Code Reviews|
Created:
4 years, 4 months ago by Yuwei Modified:
4 years, 4 months ago Reviewers:
Sergey Ulanov CC:
chromium-reviews, chromoting-reviews_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
Description[Chromoting] Unit Tests for GlRenderer
This CL separates the OpenGL drawing logic from GlRenderer and adds unit tests
for delegate callback and redraw scheduling logic.
BUG=385924
Committed: https://crrev.com/e4c0f786357df0eea6b5688b40d6a088aef28580
Cr-Commit-Position: refs/heads/master@{#411152}
Patch Set 1 : Add unittest #
Total comments: 7
Patch Set 2 : Try using default GL on desktop platforms #Patch Set 3 : Remove RendererCore #Patch Set 4 : Add TODO #Patch Set 5 : Maybe use libANGLE in unittests for all platforms #Patch Set 6 : Fix negative int->uint32_t conversion #Patch Set 7 : Only test in Linux with default OpenGL #Patch Set 8 : Only define opengl_renderer in supported platforms #Patch Set 9 : Make RequestRender private and declare the test as friend #
Total comments: 1
Patch Set 10 : Revert GlDesktop changes #Patch Set 11 : Merge ToT #Patch Set 12 : Merge ToT #
Total comments: 12
Patch Set 13 : Reviewer's Feedback #Patch Set 14 : Always include khronos header #Patch Set 15 : Don't draw when canvas is not set #
Messages
Total messages: 62 (45 generated)
Patchset #1 (id:1) has been deleted
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
yuweih@chromium.org changed reviewers: + sergeyu@chromium.org
ptal https://codereview.chromium.org/2196493002/diff/20001/remoting/client/gl_desk... File remoting/client/gl_desktop.h (right): https://codereview.chromium.org/2196493002/diff/20001/remoting/client/gl_desk... remoting/client/gl_desktop.h:29: void SetVideoFrame(const webrtc::DesktopFrame& frame); Changed this to const ref since GlDesktop no longer needs to store the previous desktop frame...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.webrtc.org/2196493002/diff/20001/remoting/client/BUILD.gn File remoting/client/BUILD.gn (right): https://codereview.webrtc.org/2196493002/diff/20001/remoting/client/BUILD.gn#... remoting/client/BUILD.gn:90: "gl_renderer.cc", This would meant that gl_renderer.cc is compiled twice, which we need to avoid. Instead you should add dependency on opengl_renderer. This list shouldn't include any files beside *unittest.cc Also I think you want to add gl_renderer_unittest.cc only on platforms that it supports. Potentially it should be possible to make it work on linux, and mac as well - that would make it easier to debug these tests. https://codereview.webrtc.org/2196493002/diff/20001/remoting/client/gl_render... File remoting/client/gl_renderer_core.h (right): https://codereview.webrtc.org/2196493002/diff/20001/remoting/client/gl_render... remoting/client/gl_renderer_core.h:22: class GlRendererCore { With this change GlRenderer becomes just a think wrapper for GlRendererCore and then you supply fake GlRendererCore implementation for the test. This means that the tests only run the code in GlRenderer and so they are not very useful. I think it would be better to run the actual renderer and execute code from the other Gl* classes. Then the test could render everything to a framebuffer, read it back and verify that everything is rendered properly. https://codereview.webrtc.org/2196493002/diff/20001/remoting/client/gl_render... remoting/client/gl_renderer_core.h:24: static std::unique_ptr<GlRendererCore> CreateCore(); We use static interface constructors like this for platform-specific code, but not to mock interfaces for testing. If you need to mock a layer under the class being tested then the class should be getting a pointer to the lower layer implementation somehow explicitly, instead of calling a static constructor. But see my previous comment, I don't think we actually need to mock anything under GlRenderer.
https://codereview.chromium.org/2196493002/diff/20001/remoting/client/gl_rend... File remoting/client/gl_renderer_core.h (right): https://codereview.chromium.org/2196493002/diff/20001/remoting/client/gl_rend... remoting/client/gl_renderer_core.h:22: class GlRendererCore { On 2016/08/01 21:33:05, Sergey Ulanov wrote: > With this change GlRenderer becomes just a think wrapper for GlRendererCore and > then you supply fake GlRendererCore implementation for the test. This means that > the tests only run the code in GlRenderer and so they are not very useful. I > think it would be better to run the actual renderer and execute code from the > other Gl* classes. Then the test could render everything to a framebuffer, read > it back and verify that everything is rendered properly. My initial thought was to test the delegate calls and render scheduling. Testing the actual rendering output sounds like an integration test and would be more complex. I can still manage to use Mesa OpenGL or something to get the code compile in different platforms. I can spend some time making tests for the render result if you think that's useful.
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2016/08/01 22:04:40, Yuwei wrote: > https://codereview.chromium.org/2196493002/diff/20001/remoting/client/gl_rend... > File remoting/client/gl_renderer_core.h (right): > > https://codereview.chromium.org/2196493002/diff/20001/remoting/client/gl_rend... > remoting/client/gl_renderer_core.h:22: class GlRendererCore { > On 2016/08/01 21:33:05, Sergey Ulanov wrote: > > With this change GlRenderer becomes just a think wrapper for GlRendererCore > and > > then you supply fake GlRendererCore implementation for the test. This means > that > > the tests only run the code in GlRenderer and so they are not very useful. I > > think it would be better to run the actual renderer and execute code from the > > other Gl* classes. Then the test could render everything to a framebuffer, > read > > it back and verify that everything is rendered properly. > > My initial thought was to test the delegate calls and render scheduling. Testing > the actual rendering output sounds like an integration test and would be more > complex. Whether that is a integration test or unittest depends on how you define a "unit" :-). There is no rule that says that each class is a separate "unit". In practice it rarely makes sense to test a single class in isolation mocking all underlying layers. Most of our unittests execute code in more than one class and verify that they work together correctly. Some random examples: 1. SSL sockets unittests (see net/socket/ssl_client_socket_unittest.cc) use real TCP sockets (they are connected to a separate test server process). 2. Codec unittests in remoting/codec run real libvpx encoder/decoder. In this case I think it's best to look at GlRenderer together with all Gl* classes as a single unit and test them together. And the approach I suggested should allow to test them without adding any artificial glue code like you do in this CL. Also verifying the output of the test is not super important (i.e. that everything is rendered correctly) - it can be added later. Even without that the test runs the whole renderer together would be useful, it would ensure that the renderer doesn't crash and you can still verify some conditions, e.g. that the frames are scheduled correctly. > > I can still manage to use Mesa OpenGL or something to get the code compile in > different platforms. I can spend some time making tests for the render result if > you think that's useful. I believe there should be existing tests in chromium that use OpenGL (e.g. in ui/gl/ and in cc/). It looks like they use system OpenGL on linux and mesa on windows, see https://codesearch.chromium.org/chromium/src/ui/gl/BUILD.gn?rcl=0&l=239 . It should be possible to apply the same approach in our unittests. I think it would be useful (e.g. it would make it easier for you to develop the tests), but don't waste much time on it if it turns out to be non-trivial change.
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_arm64_dbg_recipe on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_arm6...) win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
PTAL On 2016/08/01 23:46:01, Sergey Ulanov wrote: > On 2016/08/01 22:04:40, Yuwei wrote: > > > https://codereview.chromium.org/2196493002/diff/20001/remoting/client/gl_rend... > > File remoting/client/gl_renderer_core.h (right): > > > > > https://codereview.chromium.org/2196493002/diff/20001/remoting/client/gl_rend... > > remoting/client/gl_renderer_core.h:22: class GlRendererCore { > > On 2016/08/01 21:33:05, Sergey Ulanov wrote: > > > With this change GlRenderer becomes just a think wrapper for GlRendererCore > > and > > > then you supply fake GlRendererCore implementation for the test. This means > > that > > > the tests only run the code in GlRenderer and so they are not very useful. I > > > think it would be better to run the actual renderer and execute code from > the > > > other Gl* classes. Then the test could render everything to a framebuffer, > > read > > > it back and verify that everything is rendered properly. > > > > My initial thought was to test the delegate calls and render scheduling. > Testing > > the actual rendering output sounds like an integration test and would be more > > complex. > > Whether that is a integration test or unittest depends on how you define a > "unit" :-). There is no rule that says that each class is a separate "unit". In > practice it rarely makes sense to test a single class in isolation mocking all > underlying layers. Most of our unittests execute code in more than one class and > verify that they work together correctly. Some random examples: > 1. SSL sockets unittests (see net/socket/ssl_client_socket_unittest.cc) use > real TCP sockets (they are connected to a separate test server process). > 2. Codec unittests in remoting/codec run real libvpx encoder/decoder. Acknowledged. > In this case I think it's best to look at GlRenderer together with all Gl* > classes as a single unit and test them together. And the approach I suggested > should allow to test them without adding any artificial glue code like you do in > this CL. Also verifying the output of the test is not super important (i.e. that > everything is rendered correctly) - it can be added later. Even without that the > test runs the whole renderer together would be useful, it would ensure that the > renderer doesn't crash and you can still verify some conditions, e.g. that the > frames are scheduled correctly. SGTM. Looks like using system OpenGL doesn't crash. I think there should be OpenGL errors for not having an OpenGL context but they just do nothing other than setting the error flag. So maybe for now I just write tests for delegate calls and render scheduling and leave a TODO for adding tests for rendering in the future? > > > > I can still manage to use Mesa OpenGL or something to get the code compile in > > different platforms. I can spend some time making tests for the render result > if > > you think that's useful. > > I believe there should be existing tests in chromium that use OpenGL (e.g. in > ui/gl/ and in cc/). It looks like they use system OpenGL on linux and mesa on > windows, see > https://codesearch.chromium.org/chromium/src/ui/gl/BUILD.gn?rcl=0&l=239 . It > should be possible to apply the same approach in our unittests. I think it would > be useful (e.g. it would make it easier for you to develop the tests), but don't > waste much time on it if it turns out to be non-trivial change. The Windows OpenGL lib doesn't quite work the same way as those in POSIX system... I'll take a look to see if there is any change I need to make for Windows. We will need to establish OpenGL context if we want to test rendering, which will be platform specific. https://codereview.chromium.org/2196493002/diff/20001/remoting/client/BUILD.gn File remoting/client/BUILD.gn (right): https://codereview.chromium.org/2196493002/diff/20001/remoting/client/BUILD.g... remoting/client/BUILD.gn:90: "gl_renderer.cc", On 2016/08/01 21:33:05, Sergey Ulanov wrote: > This would meant that gl_renderer.cc is compiled twice, which we need to avoid. > Instead you should add dependency on opengl_renderer. This list shouldn't > include any files beside *unittest.cc > Also I think you want to add gl_renderer_unittest.cc only on platforms that it > supports. Potentially it should be possible to make it work on linux, and mac as > well - that would make it easier to debug these tests. Obsolete. https://codereview.chromium.org/2196493002/diff/20001/remoting/client/gl_rend... File remoting/client/gl_renderer_core.h (right): https://codereview.chromium.org/2196493002/diff/20001/remoting/client/gl_rend... remoting/client/gl_renderer_core.h:24: static std::unique_ptr<GlRendererCore> CreateCore(); On 2016/08/01 21:33:05, Sergey Ulanov wrote: > We use static interface constructors like this for platform-specific code, but > not to mock interfaces for testing. If you need to mock a layer under the class > being tested then the class should be getting a pointer to the lower layer > implementation somehow explicitly, instead of calling a static constructor. > But see my previous comment, I don't think we actually need to mock anything > under GlRenderer. Obsolete.
If you just make the unittests run on linux that's already great. I wouldn't worry much about windows.
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2016/08/02 00:28:15, Sergey Ulanov wrote: > If you just make the unittests run on linux that's already great. I wouldn't > worry much about windows. Acknowledged. Looks like there is something called libANGLE that can translate OpenGL ES API's to the native API's. Should we just use this in the test? Just not sure whether it will break iOS builder since there is no usage of OS_IOS...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
On 2016/08/02 00:52:30, Yuwei wrote: > On 2016/08/02 00:28:15, Sergey Ulanov wrote: > > If you just make the unittests run on linux that's already great. I wouldn't > > worry much about windows. > > Acknowledged. > > Looks like there is something called libANGLE that can translate OpenGL ES API's > to the native API's. Should we just use this in the test? Just not sure whether > it will break iOS builder since there is no usage of OS_IOS... NVM... I still get linking error when trying libANGLE... I will just use the system OpenGL in Linux.
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #7 (id:140001) has been deleted
Dry run: Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...) ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...)
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2016/08/02 00:28:15, Sergey Ulanov wrote: > If you just make the unittests run on linux that's already great. I wouldn't > worry much about windows. Done.
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2196493002/diff/200001/remoting/client/gl_des... File remoting/client/gl_desktop.h (right): https://codereview.chromium.org/2196493002/diff/200001/remoting/client/gl_des... remoting/client/gl_desktop.h:29: void SetVideoFrame(const webrtc::DesktopFrame& frame); I'll hold this change for the multi-texture desktop CL.
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Any update for this CL?
https://codereview.chromium.org/2196493002/diff/260001/remoting/client/BUILD.gn File remoting/client/BUILD.gn (right): https://codereview.chromium.org/2196493002/diff/260001/remoting/client/BUILD.... remoting/client/BUILD.gn:115: if (is_linux) { Can we run this test on android? If not then it should be explained in the comments. Also it's better to always compile the test, but skip it if it doesn't work on the current platform. I.e. replace this condition in the build file with an #ifdef in the test source. https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_cur... File remoting/client/gl_cursor.h (right): https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_cur... remoting/client/gl_cursor.h:8: #include <stdint.h> cstdint https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_ren... File remoting/client/gl_renderer_unittest.cc (right): https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_ren... remoting/client/gl_renderer_unittest.cc:55: int canvas_height_ = 0; make these private and add methods to access them https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_ren... remoting/client/gl_renderer_unittest.cc:56: private: empty line before private: https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_ren... remoting/client/gl_renderer_unittest.cc:76: base::MessageLoop message_loop_; move this above renderer_ so it's destroyed last. https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_ren... remoting/client/gl_renderer_unittest.cc:191: // TODO(yuweih): Add tests for the rendering process. Not clear what you mean by "rendering process". Did you mean that we need tests that would validate rendered screen content?
lgtm when my comments are addressed
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by yuweih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2196493002/diff/260001/remoting/client/BUILD.gn File remoting/client/BUILD.gn (right): https://codereview.chromium.org/2196493002/diff/260001/remoting/client/BUILD.... remoting/client/BUILD.gn:115: if (is_linux) { On 2016/08/10 15:35:06, Sergey Ulanov wrote: > Can we run this test on android? If not then it should be explained in the > comments. Also it's better to always compile the test, but skip it if it doesn't > work on the current platform. I.e. replace this condition in the build file with > an #ifdef in the test source. Managed to get it compiled on all platforms. It is safe as long as it compiles and no OpenGL function calls happen during the test. https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_cur... File remoting/client/gl_cursor.h (right): https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_cur... remoting/client/gl_cursor.h:8: #include <stdint.h> On 2016/08/10 15:35:06, Sergey Ulanov wrote: > cstdint Done. https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_ren... File remoting/client/gl_renderer_unittest.cc (right): https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_ren... remoting/client/gl_renderer_unittest.cc:55: int canvas_height_ = 0; On 2016/08/10 15:35:06, Sergey Ulanov wrote: > make these private and add methods to access them Done. https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_ren... remoting/client/gl_renderer_unittest.cc:56: private: On 2016/08/10 15:35:06, Sergey Ulanov wrote: > empty line before private: Done. https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_ren... remoting/client/gl_renderer_unittest.cc:76: base::MessageLoop message_loop_; On 2016/08/10 15:35:06, Sergey Ulanov wrote: > move this above renderer_ so it's destroyed last. Done. https://codereview.chromium.org/2196493002/diff/260001/remoting/client/gl_ren... remoting/client/gl_renderer_unittest.cc:191: // TODO(yuweih): Add tests for the rendering process. On 2016/08/10 15:35:06, Sergey Ulanov wrote: > Not clear what you mean by "rendering process". Did you mean that we need tests > that would validate rendered screen content? Yes. Changed the comment.
The CQ bit was checked by yuweih@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from sergeyu@chromium.org Link to the patchset: https://codereview.chromium.org/2196493002/#ps320001 (title: "Don't draw when canvas is not set")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Committed patchset #15 (id:320001)
Message was sent while issue was closed.
Description was changed from ========== [Chromoting] Unit Tests for GlRenderer This CL separates the OpenGL drawing logic from GlRenderer and adds unit tests for delegate callback and redraw scheduling logic. BUG=385924 ========== to ========== [Chromoting] Unit Tests for GlRenderer This CL separates the OpenGL drawing logic from GlRenderer and adds unit tests for delegate callback and redraw scheduling logic. BUG=385924 Committed: https://crrev.com/e4c0f786357df0eea6b5688b40d6a088aef28580 Cr-Commit-Position: refs/heads/master@{#411152} ==========
Message was sent while issue was closed.
Patchset 15 (id:??) landed as https://crrev.com/e4c0f786357df0eea6b5688b40d6a088aef28580 Cr-Commit-Position: refs/heads/master@{#411152} |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
