diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 04:10:49 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 04:10:49 +0000 |
commit | 9f86ec0740f2a2e5be556fa0e9ab5bb01a4ad484 (patch) | |
tree | 149e575f748d4de41c590d3ef5a54517fe487a37 | |
parent | 6d9804ad08908d16b9b2db091416a8194b430f77 (diff) | |
download | chromium_src-9f86ec0740f2a2e5be556fa0e9ab5bb01a4ad484.zip chromium_src-9f86ec0740f2a2e5be556fa0e9ab5bb01a4ad484.tar.gz chromium_src-9f86ec0740f2a2e5be556fa0e9ab5bb01a4ad484.tar.bz2 |
Reland "Move a good set of gfx unit tests into gfx_unittests target."
It was reverted in r270600 because it broke compilation:
lib/libgfx.so:error: undefined reference to 'XCreateRegion'
lib/libgfx.so:error: undefined reference to 'XUnionRectWithRegion'
lib/libgfx.so:error: undefined reference to 'XPolygonRegion'
Original description:
This requires to major changes:
1- It requires the introduction of GfxTestSuite to allow us to
initialize the ResourceBundle which is required for some of these tests
to pass.
2- It requires to split gfx_unittests target out of gfx.gyp, into
gfx_tests.gyp. This is necessary because otherwise a circular dependency
between ui_base.gyp and gfx.gyp would arise.
The circular dependency is the form of:
gfx.gyp -> ui_base.gyp -> gfx.gyp
And is created because gfx_unittests now requires ResourceBundle to link
which is in ui_base target.
BUG=331829
TEST=ui_unittests,gfx_unittests
R=sadrul@chromium.org, danakj@chromium.org
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/291753002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272088 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | build/all.gyp | 20 | ||||
-rw-r--r-- | ui/gfx/gfx.gyp | 107 | ||||
-rw-r--r-- | ui/gfx/gfx_tests.gyp | 136 | ||||
-rw-r--r-- | ui/gfx/test/DEPS | 6 | ||||
-rw-r--r-- | ui/gfx/test/run_all_unittests.cc | 49 | ||||
-rw-r--r-- | ui/ui_unittests.gyp | 12 |
6 files changed, 203 insertions, 127 deletions
diff --git a/build/all.gyp b/build/all.gyp index e2ac306..202ae59 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -38,7 +38,7 @@ ['OS=="ios"', { 'dependencies': [ '../ios/ios.gyp:*', - '../ui/gfx/gfx.gyp:gfx_unittests', + '../ui/gfx/gfx_tests.gyp:gfx_unittests', '../ui/ui_unittests.gyp:ui_unittests', ], }], @@ -256,7 +256,7 @@ '../net/net.gyp:net_unittests', '../sql/sql.gyp:sql_unittests', '../sync/sync.gyp:sync_unit_tests', - '../ui/gfx/gfx.gyp:gfx_unittests', + '../ui/gfx/gfx_tests.gyp:gfx_unittests', '../ui/ui_unittests.gyp:ui_unittests', '../url/url.gyp:url_unittests', ], @@ -771,7 +771,7 @@ '../sql/sql.gyp:sql_unittests_apk', '../sync/sync.gyp:sync_unit_tests_apk', '../ui/events/events.gyp:events_unittests_apk', - '../ui/gfx/gfx.gyp:gfx_unittests_apk', + '../ui/gfx/gfx_tests.gyp:gfx_unittests_apk', '../ui/ui_unittests.gyp:ui_unittests_apk', '../android_webview/android_webview.gyp:android_webview_test_apk', '../chrome/chrome.gyp:chrome_shell_test_apk', @@ -871,7 +871,7 @@ '../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests', '../tools/perf/clear_system_cache/clear_system_cache.gyp:*', '../tools/telemetry/telemetry.gyp:*', - '../ui/gfx/gfx.gyp:gfx_unittests', + '../ui/gfx/gfx_tests.gyp:gfx_unittests', '../ui/ui_unittests.gyp:ui_unittests', '../url/url.gyp:url_unittests', '../webkit/renderer/compositor_bindings/compositor_bindings_tests.gyp:webkit_compositor_bindings_unittests', @@ -906,7 +906,7 @@ '../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests', '../tools/perf/clear_system_cache/clear_system_cache.gyp:*', '../tools/telemetry/telemetry.gyp:*', - '../ui/gfx/gfx.gyp:gfx_unittests', + '../ui/gfx/gfx_tests.gyp:gfx_unittests', '../ui/ui_unittests.gyp:ui_unittests', '../url/url.gyp:url_unittests', '../webkit/renderer/compositor_bindings/compositor_bindings_tests.gyp:webkit_compositor_bindings_unittests', @@ -954,7 +954,7 @@ '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests', '../third_party/libaddressinput/libaddressinput.gyp:libaddressinput_unittests', '../third_party/libphonenumber/libphonenumber.gyp:libphonenumber_unittests', - '../ui/gfx/gfx.gyp:gfx_unittests', + '../ui/gfx/gfx_tests.gyp:gfx_unittests', '../ui/ui_unittests.gyp:ui_unittests', '../url/url.gyp:url_unittests', ], @@ -1005,7 +1005,7 @@ '../tools/perf/clear_system_cache/clear_system_cache.gyp:*', '../tools/telemetry/telemetry.gyp:*', '../ui/events/events.gyp:events_unittests', - '../ui/gfx/gfx.gyp:gfx_unittests', + '../ui/gfx/gfx_tests.gyp:gfx_unittests', '../ui/ui_unittests.gyp:ui_unittests', '../ui/views/views.gyp:views_unittests', '../url/url.gyp:url_unittests', @@ -1109,7 +1109,7 @@ '../sql/sql.gyp:sql_unittests', '../sync/sync.gyp:sync_unit_tests', '../third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter', - '../ui/gfx/gfx.gyp:gfx_unittests', + '../ui/gfx/gfx_tests.gyp:gfx_unittests', '../ui/ui_unittests.gyp:ui_unittests', '../ui/views/views.gyp:views_unittests', '../url/url.gyp:url_unittests', @@ -1154,8 +1154,7 @@ '../ui/aura/aura.gyp:*', '../ui/compositor/compositor.gyp:*', '../ui/events/events.gyp:*', - '../ui/wm/wm.gyp:*', - '../ui/gfx/gfx.gyp:gfx_unittests', + '../ui/gfx/gfx_tests.gyp:gfx_unittests', '../ui/keyboard/keyboard.gyp:*', '../ui/message_center/message_center.gyp:*', '../ui/snapshot/snapshot.gyp:snapshot_unittests', @@ -1163,6 +1162,7 @@ '../ui/views/examples/examples.gyp:views_examples_with_content_exe', '../ui/views/views.gyp:views', '../ui/views/views.gyp:views_unittests', + '../ui/wm/wm.gyp:*', '../webkit/renderer/compositor_bindings/compositor_bindings_tests.gyp:webkit_compositor_bindings_unittests', 'blink_tests', ], diff --git a/ui/gfx/gfx.gyp b/ui/gfx/gfx.gyp index 2e45f8b..53ba237 100644 --- a/ui/gfx/gfx.gyp +++ b/ui/gfx/gfx.gyp @@ -372,6 +372,7 @@ }], ['use_x11==1', { 'dependencies': [ + '../../build/linux/system.gyp:x11', 'x/gfx_x11.gyp:gfx_x11', ], }], @@ -438,97 +439,6 @@ }], ], }, - { - 'target_name': 'gfx_unittests', - 'type': '<(gtest_target_type)', - # iOS uses a small subset of ui. common_sources are the only files that - # are built on iOS. - 'common_sources' : [ - 'image/image_family_unittest.cc', - 'image/image_unittest.cc', - 'image/image_unittest_util.cc', - 'image/image_unittest_util.h', - 'image/image_unittest_util_ios.mm', - 'image/image_unittest_util_mac.mm', - ], - 'all_sources': [ - '<@(_common_sources)', - 'animation/animation_container_unittest.cc', - 'animation/animation_unittest.cc', - 'animation/multi_animation_unittest.cc', - 'animation/slide_animation_unittest.cc', - 'animation/tween_unittest.cc', - 'blit_unittest.cc', - 'break_list_unittest.cc', - 'codec/jpeg_codec_unittest.cc', - 'codec/png_codec_unittest.cc', - 'color_analysis_unittest.cc', - 'color_utils_unittest.cc', - 'display_unittest.cc', - 'geometry/box_unittest.cc', - 'geometry/cubic_bezier_unittest.cc', - 'geometry/insets_unittest.cc', - 'geometry/matrix3_unittest.cc', - 'geometry/point_unittest.cc', - 'geometry/point3_unittest.cc', - 'geometry/quad_unittest.cc', - 'geometry/r_tree_unittest.cc', - 'geometry/rect_unittest.cc', - 'geometry/safe_integer_conversions_unittest.cc', - 'geometry/size_unittest.cc', - 'geometry/vector2d_unittest.cc', - 'geometry/vector3d_unittest.cc', - 'image/image_mac_unittest.mm', - 'image/image_util_unittest.cc', - 'range/range_mac_unittest.mm', - 'range/range_unittest.cc', - 'range/range_win_unittest.cc', - 'sequential_id_generator_unittest.cc', - 'shadow_value_unittest.cc', - 'skbitmap_operations_unittest.cc', - 'skrect_conversion_unittest.cc', - 'transform_util_unittest.cc', - 'utf16_indexing_unittest.cc', - ], - 'dependencies': [ - '../../base/base.gyp:base', - '../../base/base.gyp:run_all_unittests', - '../../base/base.gyp:test_support_base', - '../../skia/skia.gyp:skia', - '../../testing/gtest.gyp:gtest', - '../../third_party/libpng/libpng.gyp:libpng', - 'gfx', - 'gfx_geometry', - 'gfx_test_support', - ], - 'conditions': [ - ['OS == "ios"', { - 'sources': ['<@(_common_sources)'], - }, { # OS != "ios" - 'sources': ['<@(_all_sources)'], - }], - ['OS == "win"', { - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], - }], - ['OS != "mac" and OS != "ios"', { - 'sources': [ - 'transform_unittest.cc', - 'interpolated_transform_unittest.cc', - ], - }], - ['OS == "android"', { - 'sources': [ - 'android/scroller_unittest.cc', - ], - }], - ['OS == "android" and gtest_target_type == "shared_library"', { - 'dependencies': [ - '../../testing/android/native_test.gyp:native_test_native_code', - ], - }], - ], - } ], 'conditions': [ ['OS=="android"' , { @@ -548,20 +458,5 @@ }, ], }], - ['OS == "android"', { - 'targets': [ - { - 'target_name': 'gfx_unittests_apk', - 'type': 'none', - 'dependencies': [ - 'gfx_unittests', - ], - 'variables': { - 'test_suite_name': 'gfx_unittests', - }, - 'includes': [ '../../build/apk_test.gypi' ], - }, - ], - }], ], } diff --git a/ui/gfx/gfx_tests.gyp b/ui/gfx/gfx_tests.gyp new file mode 100644 index 0000000..9fcfdf4 --- /dev/null +++ b/ui/gfx/gfx_tests.gyp @@ -0,0 +1,136 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'variables': { + 'chromium_code': 1, + }, + 'targets': [ + { + 'target_name': 'gfx_unittests', + 'type': '<(gtest_target_type)', + # iOS uses a small subset of ui. common_sources are the only files that + # are built on iOS. + 'common_sources' : [ + 'font_unittest.cc', + 'image/image_family_unittest.cc', + 'image/image_skia_unittest.cc', + 'image/image_unittest.cc', + 'image/image_unittest_util.cc', + 'image/image_unittest_util.h', + 'image/image_unittest_util_ios.mm', + 'image/image_unittest_util_mac.mm', + 'test/run_all_unittests.cc', + 'text_elider_unittest.cc', + 'text_utils_unittest.cc', + ], + 'all_sources': [ + '<@(_common_sources)', + 'animation/animation_container_unittest.cc', + 'animation/animation_unittest.cc', + 'animation/multi_animation_unittest.cc', + 'animation/slide_animation_unittest.cc', + 'animation/tween_unittest.cc', + 'blit_unittest.cc', + 'break_list_unittest.cc', + 'codec/jpeg_codec_unittest.cc', + 'codec/png_codec_unittest.cc', + 'color_analysis_unittest.cc', + 'color_utils_unittest.cc', + 'display_unittest.cc', + 'geometry/box_unittest.cc', + 'geometry/cubic_bezier_unittest.cc', + 'geometry/insets_unittest.cc', + 'geometry/matrix3_unittest.cc', + 'geometry/point_unittest.cc', + 'geometry/point3_unittest.cc', + 'geometry/quad_unittest.cc', + 'geometry/r_tree_unittest.cc', + 'geometry/rect_unittest.cc', + 'geometry/safe_integer_conversions_unittest.cc', + 'geometry/size_unittest.cc', + 'geometry/vector2d_unittest.cc', + 'geometry/vector3d_unittest.cc', + 'image/image_mac_unittest.mm', + 'image/image_util_unittest.cc', + 'range/range_mac_unittest.mm', + 'range/range_unittest.cc', + 'range/range_win_unittest.cc', + 'sequential_id_generator_unittest.cc', + 'shadow_value_unittest.cc', + 'skbitmap_operations_unittest.cc', + 'skrect_conversion_unittest.cc', + 'transform_util_unittest.cc', + 'utf16_indexing_unittest.cc', + ], + 'dependencies': [ + '../../base/base.gyp:base', + '../../base/base.gyp:test_support_base', + '../../skia/skia.gyp:skia', + '../../testing/gtest.gyp:gtest', + '../../third_party/libpng/libpng.gyp:libpng', + '../base/ui_base.gyp:ui_base', + 'gfx.gyp:gfx', + 'gfx.gyp:gfx_geometry', + 'gfx.gyp:gfx_test_support', + ], + 'conditions': [ + ['OS == "ios"', { + 'sources': ['<@(_common_sources)'], + }, { # OS != "ios" + 'sources': ['<@(_all_sources)'], + }], + ['OS == "win"', { + # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. + 'msvs_disabled_warnings': [ 4267, ], + }], + ['OS != "mac" and OS != "ios"', { + 'sources': [ + 'transform_unittest.cc', + 'interpolated_transform_unittest.cc', + ], + }], + ['use_pango == 1', { + 'dependencies': [ + '../../build/linux/system.gyp:fontconfig', + '../../build/linux/system.gyp:pangocairo', + ], + 'sources': [ + 'platform_font_pango_unittest.cc', + ], + 'conditions': [ + ['use_allocator!="none"', { + 'dependencies': [ + '../../base/allocator/allocator.gyp:allocator', + ], + }], + ], + }], + ['use_ozone==1 and use_pango==0', { + 'sources!': [ + 'font_unittest.cc', + 'text_elider_unittest.cc', + ], + }], + ], + } + ], + 'conditions': [ + ['OS == "android"', { + 'targets': [ + { + 'target_name': 'gfx_unittests_apk', + 'type': 'none', + 'dependencies': [ + 'gfx_unittests', + ], + 'variables': { + 'test_suite_name': 'gfx_unittests', + }, + 'includes': [ '../../build/apk_test.gypi' ], + }, + ], + }], + ], +} diff --git a/ui/gfx/test/DEPS b/ui/gfx/test/DEPS new file mode 100644 index 0000000..5d5c0a9 --- /dev/null +++ b/ui/gfx/test/DEPS @@ -0,0 +1,6 @@ +specific_include_rules = { + "run_all_unittests\.cc": [ + "+ui/base/resource/resource_bundle.h", + "+ui/base/ui_base_paths.h", + ], +} diff --git a/ui/gfx/test/run_all_unittests.cc b/ui/gfx/test/run_all_unittests.cc new file mode 100644 index 0000000..3ac61bc --- /dev/null +++ b/ui/gfx/test/run_all_unittests.cc @@ -0,0 +1,49 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/bind.h" +#include "base/compiler_specific.h" +#include "base/macros.h" +#include "base/path_service.h" +#include "base/test/launcher/unit_test_launcher.h" +#include "base/test/test_suite.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_paths.h" + +namespace { + +class GfxTestSuite : public base::TestSuite { + public: + GfxTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} + + protected: + virtual void Initialize() OVERRIDE { + base::TestSuite::Initialize(); + ui::RegisterPathProvider(); + + base::FilePath ui_test_pak_path; + ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); + ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); + } + + virtual void Shutdown() OVERRIDE { + ui::ResourceBundle::CleanupSharedInstance(); + base::TestSuite::Shutdown(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(GfxTestSuite); +}; + +} // namespace + +int main(int argc, char** argv) { + GfxTestSuite test_suite(argc, argv); + + return base::LaunchUnitTests( + argc, + argv, + base::Bind(&GfxTestSuite::Run, base::Unretained(&test_suite))); +} diff --git a/ui/ui_unittests.gyp b/ui/ui_unittests.gyp index cfe3d9d..222947a 100644 --- a/ui/ui_unittests.gyp +++ b/ui/ui_unittests.gyp @@ -40,11 +40,7 @@ 'base/resource/data_pack_unittest.cc', 'base/resource/resource_bundle_unittest.cc', 'base/test/run_all_unittests.cc', - 'gfx/font_unittest.cc', - 'gfx/image/image_skia_unittest.cc', 'gfx/screen_unittest.cc', - 'gfx/text_elider_unittest.cc', - 'gfx/text_utils_unittest.cc', ], 'all_sources': [ '<@(_common_sources)', @@ -142,12 +138,8 @@ }], ['use_pango == 1', { 'dependencies': [ - '../build/linux/system.gyp:fontconfig', '../build/linux/system.gyp:pangocairo', ], - 'sources': [ - 'gfx/platform_font_pango_unittest.cc', - ], 'conditions': [ ['use_allocator!="none"', { 'dependencies': [ @@ -208,11 +200,9 @@ }], ['use_ozone==1 and use_pango==0', { 'sources!': [ - 'gfx/text_elider_unittest.cc', - 'gfx/font_unittest.cc', + 'gfx/canvas_unittest.cc', 'gfx/font_list_unittest.cc', 'gfx/render_text_unittest.cc', - 'gfx/canvas_unittest.cc', ], }], ['chromeos==1', { |