Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Issue 368903003: Provide gtest printers for ui/gfx geometry types (Closed)

Created:
6 years, 5 months ago by jamesr
Modified:
6 years, 5 months ago
CC:
chromium-reviews
Project:
chromium
Visibility:
Public.

Description

Provide gtest printers for ui/gfx geometry types This provides PrintTo(..) functions for the geometric types in ui/gfx/ so that failing gtest assertions pretty-print the values instead of dumping the bytes of the objects. This way gtest assertions on these types can be written in the form: EXPECT_EQ(a, b); instead of EXPECT_EQ(a.ToString(), b.ToString()); which is currently used (inconsistently) to provide more readable failure messages. This is a bit tricky since gtest uses streams and somewhat complicated template expansion magic to pretty print values and we don't want to link the stream-based code into production code paths. This declares the PrintTo() functions in the headers defining each of the geometry types, using the <iosfwd> header to keep stream bloat to a minimum, and defines the formatters in gfx_test_support. This way every test that instantiates these printers has to declare a dependency on gfx_test_support or it fails to link, but a test does not have to #include any particular header to see the correct printer declaration and thus expand the template correctly. If we were to declare the PrintTo() functions in a test only header such a gfx_util.h then the pretty printers would work reliably only if *every* target in a translation unit that instantiated the comparison saw this declaration. If some unit tests in a target #included the header and some did not then it would be intederminate whether the template instantiation linked in to the test binary was the pretty printed one or the hex dump one (and in practice this appears to be inconsistent across clang and gcc for whatever reason). Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=282270

Patch Set 1 #

Patch Set 2 : declaration in type headers, definition in gfx_test_support #

Patch Set 3 : Add missing gfx_test_support deps #

Total comments: 10

Patch Set 4 : more deps for android, linux-gn, and ios #

Patch Set 5 : #

Patch Set 6 : fix gfx_unittests on ios #

Patch Set 7 : typo #

Patch Set 8 : add gfx_test_support dep to video_encode_accelerator_unittest #

Unified diffs Side-by-side diffs Delta from patch set Stats (+256 lines, -78 lines) Patch
M components/components_tests.gyp View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M content/content_tests.gypi View 1 2 3 4 5 6 7 3 chunks +4 lines, -1 line 0 comments Download
M gpu/BUILD.gn View 1 2 3 2 chunks +2 lines, -0 lines 0 comments Download
M gpu/gpu.gyp View 1 2 3 2 chunks +2 lines, -0 lines 0 comments Download
M media/media.gyp View 1 2 3 4 2 chunks +2 lines, -0 lines 0 comments Download
M mojo/mojo_services.gypi View 1 2 2 chunks +3 lines, -0 lines 0 comments Download
M printing/BUILD.gn View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M printing/printing.gyp View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M ui/events/events.gyp View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M ui/gfx/BUILD.gn View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M ui/gfx/geometry/box_f.h View 1 2 chunks +8 lines, -0 lines 0 comments Download
M ui/gfx/geometry/point.h View 1 2 chunks +8 lines, -0 lines 0 comments Download
M ui/gfx/geometry/point3_f.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M ui/gfx/geometry/point_f.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M ui/gfx/geometry/quad_f.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M ui/gfx/geometry/quad_unittest.cc View 1 6 chunks +25 lines, -26 lines 0 comments Download
M ui/gfx/geometry/rect.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M ui/gfx/geometry/rect_f.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M ui/gfx/geometry/rect_unittest.cc View 1 9 chunks +39 lines, -41 lines 0 comments Download
M ui/gfx/geometry/size.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M ui/gfx/geometry/size_f.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M ui/gfx/geometry/vector2d.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M ui/gfx/geometry/vector2d_f.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M ui/gfx/geometry/vector3d_f.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M ui/gfx/gfx.gyp View 1 2 3 4 5 6 2 chunks +2 lines, -9 lines 0 comments Download
M ui/gfx/test/gfx_util.h View 1 2 3 2 chunks +9 lines, -1 line 0 comments Download
M ui/gfx/test/gfx_util.cc View 1 2 3 4 3 chunks +81 lines, -0 lines 0 comments Download
M ui/gfx/transform.h View 1 2 chunks +6 lines, -0 lines 0 comments Download

Messages

Total messages: 21 (0 generated)
jamesr
This adds the printers and converts rect_unittest + quad_unittest to stop using .ToString() in assertions. ...
6 years, 5 months ago (2014-07-02 21:58:59 UTC) #1
jamesr
One side effect is this shows every place that is doing EXPECT_... on these types ...
6 years, 5 months ago (2014-07-02 22:32:08 UTC) #2
danakj
https://codereview.chromium.org/368903003/diff/40001/ui/events/events.gyp File ui/events/events.gyp (right): https://codereview.chromium.org/368903003/diff/40001/ui/events/events.gyp#newcode277 ui/events/events.gyp:277: '../gfx/gfx.gyp:gfx', why this? does everyone have to include gfx ...
6 years, 5 months ago (2014-07-07 18:52:27 UTC) #3
jamesr
Looks like I'm still missing some deps in the android, ios and linux-GN builds. Will ...
6 years, 5 months ago (2014-07-07 19:37:25 UTC) #4
danakj
LGTM https://codereview.chromium.org/368903003/diff/40001/ui/events/events.gyp File ui/events/events.gyp (right): https://codereview.chromium.org/368903003/diff/40001/ui/events/events.gyp#newcode277 ui/events/events.gyp:277: '../gfx/gfx.gyp:gfx', On 2014/07/07 19:37:24, jamesr wrote: > On ...
6 years, 5 months ago (2014-07-07 19:40:05 UTC) #5
darin (slow to review)
LGTM
6 years, 5 months ago (2014-07-07 20:56:07 UTC) #6
jamesr
The CQ bit was checked by jamesr@chromium.org
6 years, 5 months ago (2014-07-08 06:18:08 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/368903003/80001
6 years, 5 months ago (2014-07-08 06:18:53 UTC) #8
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: ios_dbg_simulator on tryserver.chromium ...
6 years, 5 months ago (2014-07-08 10:02:35 UTC) #9
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 5 months ago (2014-07-08 10:05:40 UTC) #10
commit-bot: I haz the power
Try jobs failed on following builders: ios_rel_device_ninja on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/ios_rel_device_ninja/builds/26824)
6 years, 5 months ago (2014-07-08 10:05:41 UTC) #11
jamesr
The CQ bit was checked by jamesr@chromium.org
6 years, 5 months ago (2014-07-09 01:37:21 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/368903003/100001
6 years, 5 months ago (2014-07-09 01:39:22 UTC) #13
jamesr
The CQ bit was checked by jamesr@chromium.org
6 years, 5 months ago (2014-07-09 01:39:38 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/368903003/120001
6 years, 5 months ago (2014-07-09 01:41:19 UTC) #15
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: linux_chromium_chromeos_clang_dbg on tryserver.chromium ...
6 years, 5 months ago (2014-07-09 04:52:04 UTC) #16
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 5 months ago (2014-07-09 05:06:57 UTC) #17
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chromeos_clang_dbg/builds/28535) linux_chromium_chromeos_rel on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chromeos_rel/builds/45736)
6 years, 5 months ago (2014-07-09 05:06:58 UTC) #18
jamesr
The CQ bit was checked by jamesr@chromium.org
6 years, 5 months ago (2014-07-10 00:45:14 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/368903003/140001
6 years, 5 months ago (2014-07-10 00:48:26 UTC) #20
commit-bot: I haz the power
6 years, 5 months ago (2014-07-10 07:42:00 UTC) #21
Message was sent while issue was closed.
Change committed as 282270

Powered by Google App Engine
This is Rietveld 408576698