New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 771620 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Oct 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

LayerAnimationElementTest.ToString fails in single process tests mode

Project Member Reported by smcgruer@chromium.org, Oct 4 2017

Issue description

$ ./out/Release/compositor_unittests --single-process-tests --gtest_filter=LayerAnimationElementTest.*
...
[ RUN      ] LayerAnimationElementTest.ToString
../../ui/compositor/layer_animation_element_unittest.cc:436: Failure
      Expected: "LayerAnimationElement{name=ThreadedOpacityTransition, id=1, group=42, " "last_progressed_fraction=0.00, start_frame_number=0}"
      Which is: "LayerAnimationElement{name=ThreadedOpacityTransition, id=1, group=42, last_progressed_fraction=0.00, start_frame_number=0}"
To be equal to: element->ToString()
      Which is: "LayerAnimationElement{name=ThreadedOpacityTransition, id=12, group=42, last_progressed_fraction=0.00, start_frame_number=0}"
[  FAILED  ] LayerAnimationElementTest.ToString (0 ms)


The reason is that the test checks the animation_id_, which is set from a global counter that is incremented each time an animation is created. If the tests are running in the same process, this will increment from earlier tests and be wrong for LayerAnimationElementTest.ToString.

Low priority since I believe tests are usually run in multiple-process mode, but I don't think tests should fail in single process mode either :).

More generally I don't understand why we have tests explicitly checking ToString? Walking the callers of LayerAnimationElement::ToString() in codesearch, it looks like this (and LayerAnimationSequence::ElementsToString()) are only used in tests - shouldn't the tests be explicitly checking variable values rather than doing string comparison?
 
Ah, sorry about this. I will put together a patch to fix. The test should either create the animation_id_ with a known id rather than variably-incremented one, or expect that the string contents match the animation_id_ that it has.

ToString is only called by test code, and so looks like dead code, because it is intended for debugging use.

The test could check that the string produced contains each individual variable value in the instance, rather than having a hard coded string representing the values we expect en masse. The tests are not that precise today mainly due to the time investment required to write that weighed vs the value it would provide, since ToString is debug-only. If you think further rework is warranted I'd support that as a P3 cleanup type of item.
I'm fine with the tests with just the flake fixed if the ToString methods are just for debugging. I'm not even sure you would need tests, but if you want them then that's fine!
Status: Fixed (was: Assigned)

Sign in to add a comment