| load("//bazel:skia_rules.bzl", "skia_cc_library") |
| load("//bazel:flags.bzl", "bool_flag", "selects") |
| load(":tests.bzl", "skia_cpu_tests", "skia_ganesh_tests") |
| load( |
| ":testgroups.bzl", |
| "CODEC_TESTS", |
| "CPU_ONLY_TESTS", |
| "DEBUGGER_TESTS", |
| "DISCARDABLE_MEMORY_POOL_TESTS", |
| "GANESH_TESTS", |
| "PATHOPS_TESTS", |
| "PDF_TESTS", |
| ) |
| load(":android.bzl", "skia_android_unit_test") |
| |
| skia_cc_library( |
| name = "tests_base", |
| testonly = True, |
| srcs = [ |
| "CanvasStateHelpers.cpp", |
| "CtsEnforcement.cpp", |
| "Test.cpp", |
| "TestHarness.cpp", |
| "//tools/flags", |
| ] + select({ |
| "//src/gpu:has_gpu_backend": ["TestUtils.cpp"], |
| "//conditions:default": [], |
| }), |
| hdrs = [ |
| "CanvasStateHelpers.h", |
| "CodecPriv.h", |
| "CtsEnforcement.h", |
| "FakeStreams.h", |
| "RecordTestUtils.h", |
| "Test.h", |
| "TestHarness.h", |
| "//tools/fonts:test_empty_typeface", |
| ] + select({ |
| "//src/gpu:has_gpu_backend": ["TestUtils.h"], |
| "//conditions:default": [], |
| }), |
| deps = [ |
| "//:skia_internal", |
| "//tools:registry", |
| "//tools:tool_utils", |
| ] + select({ |
| "//src/gpu:has_gpu_backend": ["//tools/gpu:utils"], |
| "//conditions:default": [], |
| }) + select({ |
| "//src/sksl:needs_sksl": ["//tools:runtime_blend_utils"], |
| "//conditions:default": [], |
| }), |
| ) |
| |
| skia_cc_library( |
| name = "fontmgr_tests_base", |
| testonly = True, |
| srcs = [ |
| "FontMgrFlags.cpp", |
| ], |
| deps = [":tests_base"], |
| ) |
| |
| skia_cc_library( |
| name = "pathops_tests_base", |
| testonly = True, |
| srcs = [ |
| "PathOpsCubicIntersectionTestData.cpp", |
| "PathOpsDebug.cpp", |
| "PathOpsExtendedTest.cpp", |
| "PathOpsQuadIntersectionTestData.cpp", |
| "PathOpsTestCommon.cpp", |
| "PathOpsThreadedCommon.cpp", |
| "SubsetPath.cpp", |
| ], |
| hdrs = [ |
| "PathOpsCubicIntersectionTestData.h", |
| "PathOpsDebug.h", |
| "PathOpsExtendedTest.h", |
| "PathOpsQuadIntersectionTestData.h", |
| "PathOpsTSectDebug.h", |
| "PathOpsTestCommon.h", |
| "PathOpsThreadedCommon.h", |
| "SubsetPath.h", |
| "Test.h", |
| ], |
| deps = [":tests_base"], |
| ) |
| |
| # These macros generates one test target per file listed in the passed in list. The test target |
| # has the name of the file, with the .cpp extension removed. |
| skia_cpu_tests( |
| name = "codec_tests", |
| flags = { |
| "include_decoder": [ |
| "avif_decode_codec", |
| "gif_decode_codec", |
| "jpeg_decode_codec", |
| "jxl_decode_codec", |
| "png_decode_codec", |
| "raw_decode_codec", |
| "webp_decode_codec", |
| ], |
| "include_encoder": [ |
| "jpeg_encode_codec", |
| "png_encode_codec", |
| "webp_encode_codec", |
| ], |
| }, |
| harness = ":tests_base", |
| resources = ["//resources"], |
| tests = CODEC_TESTS, |
| ) |
| |
| skia_cpu_tests( |
| name = "cpu_only_tests", |
| flags = { |
| "fontmgr_factory": ["custom_directory_fontmgr_factory"], |
| "enable_sksl": ["True"], |
| "enable_sksl_tracing": ["True"], |
| "include_decoder": [ |
| "jpeg_decode_codec", |
| "png_decode_codec", |
| ], |
| "include_encoder": [ |
| "png_encode_codec", |
| ], |
| }, |
| harness = ":tests_base", |
| resources = ["//resources"], |
| tests = CPU_ONLY_TESTS, |
| ) |
| |
| skia_cpu_tests( |
| name = "discardable_memory_tests", |
| flags = { |
| "enable_discardable_memory": ["True"], |
| "use_default_global_memory_pool": ["True"], |
| }, |
| harness = ":tests_base", |
| resources = ["//resources"], |
| tests = DISCARDABLE_MEMORY_POOL_TESTS, |
| ) |
| |
| skia_ganesh_tests( |
| name = "debugger_tests", |
| extra_deps = ["//tools/debugger"], |
| flags = { |
| "include_encoder": [ |
| "png_encode_codec", |
| ], |
| }, |
| harness = ":tests_base", |
| tests = DEBUGGER_TESTS, |
| ) |
| |
| skia_ganesh_tests( |
| name = "ganesh_tests", |
| flags = { |
| "include_encoder": [ |
| "png_encode_codec", |
| ], |
| }, |
| harness = ":tests_base", |
| resources = ["//resources"], |
| tests = GANESH_TESTS, |
| ) |
| |
| skia_cpu_tests( |
| name = "fontmgr_android_test", |
| flags = { |
| "fontmgr_factory": ["android_fontmgr_factory"], |
| }, |
| harness = ":fontmgr_tests_base", |
| resources = ["//resources"], |
| tests = ["FontMgrAndroidParserTest.cpp"], |
| ) |
| |
| skia_cpu_tests( |
| name = "fontmgr_test", |
| flags = { |
| "fontmgr_factory": ["custom_directory_fontmgr_factory"], |
| }, |
| harness = ":fontmgr_tests_base", |
| resources = ["//resources"], |
| tests = ["FontMgrTest.cpp"], |
| ) |
| |
| skia_cpu_tests( |
| name = "fontmgr_fci_test", |
| flags = { |
| "fontmgr_factory": ["fci_fontmgr_factory"], |
| }, |
| harness = ":fontmgr_tests_base", |
| resources = ["//resources"], |
| tests = ["FCITest.cpp"], |
| ) |
| |
| # TODO(kjlubick, bungeman) This test probably won't pass on Windows. We'll need a mechanism for |
| # running tests only on certain platforms. This probably can be achieved by expanding limit_to |
| # to generate a test that is configured to run only on linux and one that will only run on Mac |
| # and Windows will ignore both of those tests. |
| skia_cpu_tests( |
| name = "fontmgr_fontconfig_test", |
| flags = { |
| "fontmgr_factory": ["fontconfig_fontmgr_factory"], |
| }, |
| harness = ":fontmgr_tests_base", |
| resources = ["//resources"], |
| tests = ["FontMgrFontConfigTest.cpp"], |
| ) |
| |
| skia_cpu_tests( |
| name = "mac_only_tests", |
| harness = ":tests_base", |
| limit_to = ["@platforms//os:macos"], |
| tests = ["TypefaceMacTest.cpp"], |
| ) |
| |
| skia_cpu_tests( |
| name = "pathops_tests", |
| harness = ":pathops_tests_base", |
| tests = PATHOPS_TESTS, |
| ) |
| |
| skia_cpu_tests( |
| name = "pdf_tests", |
| flags = { |
| "fontmgr_factory": ["custom_directory_fontmgr_factory"], |
| "enable_pdf_backend": ["True"], |
| "include_decoder": ["jpeg_decode_codec"], |
| "include_encoder": ["jpeg_encode_codec"], |
| }, |
| harness = ":tests_base", |
| resources = ["//resources"], |
| tests = PDF_TESTS, |
| ) |
| |
| skia_ganesh_tests( |
| name = "secondary_draw_context_tests", |
| flags = { |
| "enable_secondary_draw_context": ["True"], |
| }, |
| harness = ":tests_base", |
| resources = ["//resources"], |
| tests = [ |
| "DeferredDisplayListTest.cpp", |
| "VkDrawableTest.cpp", |
| ], |
| ) |
| |
| skia_cpu_tests( |
| name = "svg_tests", |
| flags = { |
| "enable_svg_canvas": ["True"], |
| }, |
| harness = ":tests_base", |
| resources = ["//resources"], |
| tests = ["SVGDeviceTest.cpp"], |
| ) |
| |
| skia_ganesh_tests( |
| name = "text_blob_cache_test", |
| extra_deps = ["//tools/fonts:random_scaler_context"], |
| harness = ":tests_base", |
| resources = ["//resources"], |
| tests = ["TextBlobCacheTest.cpp"], |
| ) |
| |
| bool_flag( |
| name = "force_cpu_tests", |
| default = False, |
| public = False, |
| ) |
| |
| selects.config_setting_group( |
| name = "skip_cpu_tests", |
| match_all = [ |
| "//src/gpu:has_gpu_backend", |
| ":force_cpu_tests_false", |
| ], |
| ) |
| |
| # These targets can be run from a gLinux workstation. Example: |
| # |
| # 1. Port-forward the ADB server from a Raspberry Pi that is connected to a Pixel 5: |
| # |
| # $ ssh -L 5037:localhost:5037 skia-rpi2-rack1-shelf1-036 |
| # |
| # 2. Invoke Bazel as follows: |
| # |
| # $ bazel test //tests:android_codec_test --config=pixel_5 --config=linux_rbe --test_output=streamed |
| |
| skia_android_unit_test( |
| name = "android_codec_test", |
| srcs = CODEC_TESTS, |
| flags = { |
| "include_decoder": [ |
| "avif_decode_codec", |
| "gif_decode_codec", |
| "jpeg_decode_codec", |
| "jxl_decode_codec", |
| "png_decode_codec", |
| "raw_decode_codec", |
| "webp_decode_codec", |
| ], |
| "include_encoder": [ |
| "jpeg_encode_codec", |
| "png_encode_codec", |
| "webp_encode_codec", |
| ], |
| }, |
| requires_resources_dir = True, |
| deps = [ |
| ":tests_base", |
| "//:skia_internal", |
| ], |
| ) |
| |
| skia_android_unit_test( |
| name = "android_ganesh_test", |
| srcs = GANESH_TESTS, |
| requires_condition = "//src/gpu:has_gpu_backend", |
| requires_resources_dir = True, |
| deps = [ |
| ":tests_base", |
| "//:skia_internal", |
| ], |
| ) |
| |
| skia_android_unit_test( |
| name = "android_pathops_test", |
| srcs = PATHOPS_TESTS, |
| requires_resources_dir = True, |
| deps = [ |
| ":pathops_tests_base", |
| "//:skia_internal", |
| ], |
| ) |
| |
| # Some test cases fail with --config=pixel_7. |
| skia_android_unit_test( |
| name = "android_cpu_only_test", |
| srcs = CPU_ONLY_TESTS, |
| flags = { |
| "fontmgr_factory": ["custom_directory_fontmgr_factory"], |
| "enable_sksl": ["True"], |
| "enable_sksl_tracing": ["True"], |
| "include_decoder": [ |
| "jpeg_decode_codec", |
| "png_decode_codec", |
| ], |
| "include_encoder": [ |
| "png_encode_codec", |
| ], |
| }, |
| requires_resources_dir = True, |
| deps = [ |
| ":tests_base", |
| "//:skia_internal", |
| ], |
| ) |
| |
| skia_android_unit_test( |
| name = "android_discardable_memory_test", |
| srcs = DISCARDABLE_MEMORY_POOL_TESTS, |
| flags = { |
| "enable_discardable_memory": ["True"], |
| "use_default_global_memory_pool": ["True"], |
| }, |
| deps = [ |
| ":tests_base", |
| "//:skia_internal", |
| ], |
| ) |