|
|
DescriptionVrShell: Add test for fullscreen transitions.
BUG=661762
Patch Set 1 #Patch Set 2 : oops, forgot to rebase #
Total comments: 6
Patch Set 3 : fix a missed method renaming and add full color check #
Total comments: 6
Patch Set 4 : rebase #Patch Set 5 : switch to using scene methods instead of via manager friend internals #Patch Set 6 : rebase #
Total comments: 5
Patch Set 7 : Add enum names and update tests to use those instead #Patch Set 8 : missed a scoped enum #Patch Set 9 : rebase to use debug id enum instead of name one I created #
Total comments: 11
Messages
Total messages: 24 (6 generated)
The CQ bit was checked by amp@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...
amp@chromium.org changed reviewers: + cjgrant@chromium.org
This required adding a macro to the ui scene manager to allow for friend access from the tests. Let me know if there is a better way to go about writing tests like this.
On 2017/05/09 21:19:03, amp wrote: > This required adding a macro to the ui scene manager to allow for friend access > from the tests. > > Let me know if there is a better way to go about writing tests like this. And make sure to look at patch set 2 as I forgot to rebase. :P
bsheedy@chromium.org changed reviewers: + bsheedy@chromium.org
https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:105: // TODO(amp): Check more than just the red value. This seems like a simple thing to add in this CL - do now and get rid of TODO? https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:114: // TODO(amp): Check more than just the red value. Ditto.
https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:105: // TODO(amp): Check more than just the red value. On 2017/05/09 21:27:09, bsheedy wrote: > This seems like a simple thing to add in this CL - do now and get rid of TODO? The reason for the TODO is that I really just want to write: EXPECT_NE(initialBackground, scene_->GetBackgroundColor()); but that doesn't work because it's a struct without an overridden equality operator. So instead I would have to write: EXPECT_NE(initialBackground.r, scene_->GetBackgroundColor().r); EXPECT_NE(initialBackground.g, scene_->GetBackgroundColor().g); EXPECT_NE(initialBackground.b, scene_->GetBackgroundColor().b); EXPECT_NE(initialBackground.a, scene_->GetBackgroundColor().a); Not a huge difference, but it's kind of ugly (especially to do multiple times) and I was hoping someone might point out a better way. Any ideas?
https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:105: // TODO(amp): Check more than just the red value. On 2017/05/09 21:36:24, amp wrote: > On 2017/05/09 21:27:09, bsheedy wrote: > > This seems like a simple thing to add in this CL - do now and get rid of TODO? > > The reason for the TODO is that I really just want to write: > EXPECT_NE(initialBackground, scene_->GetBackgroundColor()); > > but that doesn't work because it's a struct without an overridden equality > operator. > > So instead I would have to write: > EXPECT_NE(initialBackground.r, scene_->GetBackgroundColor().r); > EXPECT_NE(initialBackground.g, scene_->GetBackgroundColor().g); > EXPECT_NE(initialBackground.b, scene_->GetBackgroundColor().b); > EXPECT_NE(initialBackground.a, scene_->GetBackgroundColor().a); > > > Not a huge difference, but it's kind of ugly (especially to do multiple times) > and I was hoping someone might point out a better way. Any ideas? Decided to go ahead and just add it. One thing is that the alpha is the same for both variants, so it doesn't really work as straightforwardly as it could.
https://codereview.chromium.org/2873043002/diff/40001/chrome/browser/android/... File chrome/browser/android/vr_shell/ui_scene_manager.h (right): https://codereview.chromium.org/2873043002/diff/40001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager.h:79: FRIEND_TEST_ALL_PREFIXES(UiSceneManagerTest, UiUpdatesForFullscreen); See other comments on how we could potentially avoid this. https://codereview.chromium.org/2873043002/diff/40001/chrome/browser/android/... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/40001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:83: InSequence s; Not needed - it's only required to ensure that mock calls are seen in order. https://codereview.chromium.org/2873043002/diff/40001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:90: for (UiElement* element : manager_->browser_ui_elements_) { browser_ui_elements_ is an internal convenience that I don't think a test should depend on. What about inspecting the scene instead? It already exposes the set of elements, so maybe you can check that all elements that aren't fill NONE or CONTENT are hidden? Alternatively, we had previously attached descriptive strings to elements, but removed them to keep them out of the binary. What if we made an enum of elements instead, assigning values to elements that tests care about? Then tests can identify elements in cases like this. Thoughts?
https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:105: // TODO(amp): Check more than just the red value. On 2017/05/09 22:47:37, amp wrote: > On 2017/05/09 21:36:24, amp wrote: > > On 2017/05/09 21:27:09, bsheedy wrote: > > > This seems like a simple thing to add in this CL - do now and get rid of > TODO? > > > > The reason for the TODO is that I really just want to write: > > EXPECT_NE(initialBackground, scene_->GetBackgroundColor()); > > > > but that doesn't work because it's a struct without an overridden equality > > operator. > > > > So instead I would have to write: > > EXPECT_NE(initialBackground.r, scene_->GetBackgroundColor().r); > > EXPECT_NE(initialBackground.g, scene_->GetBackgroundColor().g); > > EXPECT_NE(initialBackground.b, scene_->GetBackgroundColor().b); > > EXPECT_NE(initialBackground.a, scene_->GetBackgroundColor().a); > > > > > > Not a huge difference, but it's kind of ugly (especially to do multiple times) > > and I was hoping someone might point out a better way. Any ideas? > > Decided to go ahead and just add it. One thing is that the alpha is the same > for both variants, so it doesn't really work as straightforwardly as it could. I feel your pain on this one. :) Wrapper functions around multiple expects aren't good here because a test failure won't print the exact location. I've used macros successfully before (see the scene unit test), but in that case, you'd lose the readout of exactly which value was wrong. Another option here would be to add a pair of helpers to this module that convert the 4 floats to a 32-bit ARGV value, and the 3 floats to an RGV value, and run your EXPECTs on the results of those. That could cause a false pass if the expected color change is tiny, but that's unlikely.
Thanks for the suggestions. I'll take another pass and update the tests to see what works well. https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/20001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:105: // TODO(amp): Check more than just the red value. On 2017/05/10 14:08:36, cjgrant wrote: > On 2017/05/09 22:47:37, amp wrote: > > On 2017/05/09 21:36:24, amp wrote: > > > On 2017/05/09 21:27:09, bsheedy wrote: > > > > This seems like a simple thing to add in this CL - do now and get rid of > > TODO? > > > > > > The reason for the TODO is that I really just want to write: > > > EXPECT_NE(initialBackground, scene_->GetBackgroundColor()); > > > > > > but that doesn't work because it's a struct without an overridden equality > > > operator. > > > > > > So instead I would have to write: > > > EXPECT_NE(initialBackground.r, scene_->GetBackgroundColor().r); > > > EXPECT_NE(initialBackground.g, scene_->GetBackgroundColor().g); > > > EXPECT_NE(initialBackground.b, scene_->GetBackgroundColor().b); > > > EXPECT_NE(initialBackground.a, scene_->GetBackgroundColor().a); > > > > > > > > > Not a huge difference, but it's kind of ugly (especially to do multiple > times) > > > and I was hoping someone might point out a better way. Any ideas? > > > > Decided to go ahead and just add it. One thing is that the alpha is the same > > for both variants, so it doesn't really work as straightforwardly as it could. > > I feel your pain on this one. :) Wrapper functions around multiple expects > aren't good here because a test failure won't print the exact location. I've > used macros successfully before (see the scene unit test), but in that case, > you'd lose the readout of exactly which value was wrong. > > Another option here would be to add a pair of helpers to this module that > convert the 4 floats to a 32-bit ARGV value, and the 3 floats to an RGV value, > and run your EXPECTs on the results of those. That could cause a false pass if > the expected color change is tiny, but that's unlikely. I'll leave it as is for now since we only care that the values changed at this point and they are not small differences, but setting up some helpers sounds like it could be useful if we want to get more specific about color variations. https://codereview.chromium.org/2873043002/diff/40001/chrome/browser/android/... File chrome/browser/android/vr_shell/ui_scene_manager.h (right): https://codereview.chromium.org/2873043002/diff/40001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager.h:79: FRIEND_TEST_ALL_PREFIXES(UiSceneManagerTest, UiUpdatesForFullscreen); On 2017/05/10 02:45:00, cjgrant wrote: > See other comments on how we could potentially avoid this. Acknowledged. It was useful to figure out how this works, though, as I imagine there will be some cases where we have to dig into the private members of a class for tests at some point. https://codereview.chromium.org/2873043002/diff/40001/chrome/browser/android/... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/40001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:83: InSequence s; On 2017/05/10 02:45:00, cjgrant wrote: > Not needed - it's only required to ensure that mock calls are seen in order. Done. https://codereview.chromium.org/2873043002/diff/40001/chrome/browser/android/... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:90: for (UiElement* element : manager_->browser_ui_elements_) { On 2017/05/10 02:45:00, cjgrant wrote: > browser_ui_elements_ is an internal convenience that I don't think a test should > depend on. What about inspecting the scene instead? It already exposes the set > of elements, so maybe you can check that all elements that aren't fill NONE or > CONTENT are hidden? Thanks for the suggestion. I had tried this at first, but the only method I saw then was the GetWorldElements method which does a check on calculated opacity and didn't return anything so I gave up and went the internal route. After reading your comment I went back and checked and realized that there was GetUiElements that returns all of them. Your suggestion of checking the fill type sounds like it should work. > > Alternatively, we had previously attached descriptive strings to elements, but > removed them to keep them out of the binary. What if we made an enum of > elements instead, assigning values to elements that tests care about? Then > tests can identify elements in cases like this. Thoughts? We might end up going that route eventually, but I think I can make it work with just checking the fill types for now (as the CONTENT type is the main one I care about). Once we start checking for other things we may need to have add some mapping via enum's etc.
PTAL. Latest patch doesn't require friend access to manager internals.
Description was changed from ========== VrShell: Add test for fullscreen transitions. BUG=None ========== to ========== VrShell: Add test for fullscreen transitions. BUG=None ==========
https://codereview.chromium.org/2873043002/diff/100001/chrome/browser/android... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/100001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:77: InSequence s; I think you said removing this was Done. :) https://codereview.chromium.org/2873043002/diff/100001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:84: for (const auto& element : scene_->GetUiElements()) { Thinking about this more. This should be tripping on the invisible HTTP warnings, but it doesn't, because in tests, nobody initializes the GL-based textures for elements, and hence the elements aren't updated to Fill::SELF. So with this method, it seems the test would be falsely working. Sorry to have kibosh'ed the original approach. I still don't think it was better, but maybe it can be adapted to have scene manager offer a GetElementsVisibleInBrowserMode(), usable here. You wouldn't need the friend accessibility, but just as before, we're taking advantage of an implementation detail of scene manager to test scene manager. I think the enum approach might be best, so we can have a test that's like: for element : elements { should_be_visible = set({URL_BAR, PROGRESS_INDICATOR,. ...).has(element.name); EXPECT_EQ(should_be_visible, element.IsVisible() } Feel free to message offline about this... I could be crazy.
https://codereview.chromium.org/2873043002/diff/100001/chrome/browser/android... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/100001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:77: InSequence s; On 2017/05/10 18:50:22, cjgrant wrote: > I think you said removing this was Done. :) Oops, must of slipped through the cracks as I was switching branches. I thought I had removed it... https://codereview.chromium.org/2873043002/diff/100001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:84: for (const auto& element : scene_->GetUiElements()) { On 2017/05/10 18:50:22, cjgrant wrote: > Thinking about this more. This should be tripping on the invisible HTTP > warnings, but it doesn't, because in tests, nobody initializes the GL-based > textures for elements, and hence the elements aren't updated to Fill::SELF. So > with this method, it seems the test would be falsely working. > > Sorry to have kibosh'ed the original approach. I still don't think it was > better, but maybe it can be adapted to have scene manager offer a > GetElementsVisibleInBrowserMode(), usable here. You wouldn't need the friend > accessibility, but just as before, we're taking advantage of an implementation > detail of scene manager to test scene manager. I think the enum approach might > be best, so we can have a test that's like: > > for element : elements { > should_be_visible = set({URL_BAR, PROGRESS_INDICATOR,. ...).has(element.name); > EXPECT_EQ(should_be_visible, element.IsVisible() > } > > Feel free to message offline about this... I could be crazy. Per offline discussion I'll go with something like the proposed enums. Stay tuned!
https://codereview.chromium.org/2873043002/diff/100001/chrome/browser/android... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/100001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:118: EXPECT_EQ(initialBackground.r, scene_->GetBackgroundColor().r); Revisiting the helper method approach here, see gtest's SCOPED_TRACE() - it looks helpful.
Ran out of time to get this working before I have to shut off my dev machine for the move, but take a look at the enums and let me know what you think of this direction.
PTAL. This should be ready to go in now. I added a few more elements to the debug list in preparation for the changes coming to full screen (where floor and ceiling are visible). I can pull those out and put them in the next change if preferred. Also the SCOPED_TRACE calls works great, even in loops and produce output that looks like this (where that last 5 tells you it's the 5th enum that failed [this was when I was accidently checking for the floor ceiling grid visibility which aren't visible yet): C 56.160s Main ******************************************************************************** C 56.160s Main Detailed Logs C 56.160s Main ******************************************************************************** C 56.161s Main [FAIL] UiSceneManagerTest.UiUpdatesForFullscreenChanges: C 56.161s Main [ RUN ] UiSceneManagerTest.UiUpdatesForFullscreenChanges C 56.161s Main ../../chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:182: Failure C 56.161s Main Expected: should_be_visible C 56.161s Main Which is: true C 56.161s Main To be equal to: element->visible() C 56.161s Main Which is: false C 56.161s Main Google Test trace: C 56.161s Main ../../chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:177: 5
Description was changed from ========== VrShell: Add test for fullscreen transitions. BUG=None ========== to ========== VrShell: Add test for fullscreen transitions. BUG=661762 ==========
https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... File chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h (right): https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h:19: kGrid, Maybe kFloorGrid just to be clear? https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h:20: kBrowserBar, This is called the URL bar everywhere else. kUrlBar? https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:159: vr::Colorf initialBackground = scene_->GetBackgroundColor(); initial_background https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:174: // All elements should be hidden except for main content. Did we say the floor would stay visible in fullscreen? https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:179: // Ignore elements not in the set. Since this test is focused on fullscreen, why ignore some elements? Why not assert that nothing other than the content quad is visible? If someone adds another element to fullscreen, they should update this test. This would also kill the need for "hidden_in_fullscreen". Thoughts?
Fixes are in latest patch set of https://codereview.chromium.org/2887773008/ https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... File chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h (right): https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h:19: kGrid, On 2017/05/23 18:58:11, cjgrant wrote: > Maybe kFloorGrid just to be clear? Done. I think I actually refered to it as FloorGrid somewhere else too. https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h:20: kBrowserBar, On 2017/05/23 18:58:11, cjgrant wrote: > This is called the URL bar everywhere else. kUrlBar? Done. https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:159: vr::Colorf initialBackground = scene_->GetBackgroundColor(); On 2017/05/23 18:58:11, cjgrant wrote: > initial_background Done. https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:174: // All elements should be hidden except for main content. On 2017/05/23 18:58:11, cjgrant wrote: > Did we say the floor would stay visible in fullscreen? Yes, at the point this test was written it wasn't though. I'll update the comment in the latest cl where it is. https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:179: // Ignore elements not in the set. On 2017/05/23 18:58:11, cjgrant wrote: > Since this test is focused on fullscreen, why ignore some elements? Why not > assert that nothing other than the content quad is visible? If someone adds > another element to fullscreen, they should update this test. This would also > kill the need for "hidden_in_fullscreen". Thoughts? I went this way because not every element has a debug id. Multiple elements could be under kNone and unless they are all supposed to be hidden it could be a pain to enumerate them all (not to mention the tests won't be helpful in explaining which element caused the problem). I've updated the comments to better explain this, but let me know if you want to fully enumerate all the elements so we don't need a check like this.
https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:179: // Ignore elements not in the set. On 2017/05/23 20:56:02, amp wrote: > On 2017/05/23 18:58:11, cjgrant wrote: > > Since this test is focused on fullscreen, why ignore some elements? Why not > > assert that nothing other than the content quad is visible? If someone adds > > another element to fullscreen, they should update this test. This would also > > kill the need for "hidden_in_fullscreen". Thoughts? > > I went this way because not every element has a debug id. Multiple elements > could be under kNone and unless they are all supposed to be hidden it could be a > pain to enumerate them all (not to mention the tests won't be helpful in > explaining which element caused the problem). > > I've updated the comments to better explain this, but let me know if you want to > fully enumerate all the elements so we don't need a check like this. But in fullscreen, there are only a few things visible - the quad, floor, ceiling and grid, right? And, you've just assigned ids to each of those. It seems totally reasonable that if an element is going to be visible, that it have a debug id. Also, part of this test is making sure that stuff you don't want showing, doesn't show. If another element comes along, is accidentally visible in fullscreen, but doesn't get added to the "hidden in fullscreen" set, this test won't catch it, right?
On 2017/05/23 21:27:31, cjgrant wrote: > https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... > File chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc (right): > > https://codereview.chromium.org/2873043002/diff/160001/chrome/browser/android... > chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc:179: // Ignore > elements not in the set. > On 2017/05/23 20:56:02, amp wrote: > > On 2017/05/23 18:58:11, cjgrant wrote: > > > Since this test is focused on fullscreen, why ignore some elements? Why not > > > assert that nothing other than the content quad is visible? If someone adds > > > another element to fullscreen, they should update this test. This would > also > > > kill the need for "hidden_in_fullscreen". Thoughts? > > > > I went this way because not every element has a debug id. Multiple elements > > could be under kNone and unless they are all supposed to be hidden it could be > a > > pain to enumerate them all (not to mention the tests won't be helpful in > > explaining which element caused the problem). > > > > I've updated the comments to better explain this, but let me know if you want > to > > fully enumerate all the elements so we don't need a check like this. > > But in fullscreen, there are only a few things visible - the quad, floor, > ceiling and grid, right? And, you've just assigned ids to each of those. It > seems totally reasonable that if an element is going to be visible, that it have > a debug id. > > Also, part of this test is making sure that stuff you don't want showing, > doesn't show. If another element comes along, is accidentally visible in > fullscreen, but doesn't get added to the "hidden in fullscreen" set, this test > won't catch it, right? Updated in other patchset to make sure we are listing all the expected visible elements (I was missing the backplane) and this way a new element added in the future will have to update this test. |