Skip to content

Commit

Permalink
skia: Add 'skia_unittests' test suite for this directory.
Browse files Browse the repository at this point in the history
This should be a lightweight test suite that should allow a dev changing
something in skia/ext to test it much more quickly than having to build
all 'unit_tests' target just to run the tests from skia/ext.

BUG=444058
TEST=skia_unittests links and runs fine.
R=danakj@chromium.org,thakis@chromium.org

Review URL: https://codereview.chromium.org/815023003

Cr-Commit-Position: refs/heads/master@{#310310}
  • Loading branch information
tfarina authored and Commit bot committed Jan 7, 2015
1 parent f1d3d3d commit c87c3d2
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 44 deletions.
9 changes: 9 additions & 0 deletions build/all.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
'../components/components_tests.gyp:components_unittests',
'../crypto/crypto.gyp:crypto_unittests',
'../net/net.gyp:net_unittests',
'../skia/skia_tests.gyp:skia_unittests',
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../ui/base/ui_base_tests.gyp:ui_base_unittests',
Expand Down Expand Up @@ -839,6 +840,7 @@
'../media/media.gyp:media_unittests',
'../net/net.gyp:net_unittests',
'../sandbox/sandbox.gyp:sandbox_linux_unittests_deps',
'../skia/skia_tests.gyp:skia_unittests',
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../testing/android/junit/junit_test.gyp:junit_unit_tests',
Expand Down Expand Up @@ -873,6 +875,7 @@
'../media/media.gyp:media_unittests_apk',
'../net/net.gyp:net_unittests_apk',
'../sandbox/sandbox.gyp:sandbox_linux_jni_unittests_apk',
'../skia/skia_tests.gyp:skia_unittests_apk',
'../sql/sql.gyp:sql_unittests_apk',
'../sync/sync.gyp:sync_unit_tests_apk',
'../tools/android/heap_profiler/heap_profiler.gyp:heap_profiler_unittests_apk',
Expand Down Expand Up @@ -945,6 +948,7 @@
'../printing/printing.gyp:printing_unittests',
'../remoting/remoting.gyp:remoting_unittests',
'../rlz/rlz.gyp:*',
'../skia/skia_tests.gyp:skia_unittests',
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
Expand Down Expand Up @@ -982,6 +986,7 @@
'../ppapi/ppapi_internal.gyp:ppapi_unittests',
'../printing/printing.gyp:printing_unittests',
'../remoting/remoting.gyp:remoting_unittests',
'../skia/skia_tests.gyp:skia_unittests',
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
Expand Down Expand Up @@ -1032,6 +1037,7 @@
'../google_apis/gcm/gcm.gyp:gcm_unit_tests',
'../printing/printing.gyp:printing_unittests',
'../remoting/remoting.gyp:remoting_unittests',
'../skia/skia_tests.gyp:skia_unittests',
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
Expand Down Expand Up @@ -1081,6 +1087,7 @@
'../ppapi/ppapi_internal.gyp:ppapi_unittests',
'../printing/printing.gyp:printing_unittests',
'../remoting/remoting.gyp:remoting_unittests',
'../skia/skia_tests.gyp:skia_unittests',
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
Expand Down Expand Up @@ -1181,6 +1188,7 @@
'../net/net.gyp:net_unittests',
'../printing/printing.gyp:printing_unittests',
'../remoting/remoting.gyp:remoting_unittests',
'../skia/skia_tests.gyp:skia_unittests',
'../sql/sql.gyp:sql_unittests',
'../sync/sync.gyp:sync_unit_tests',
'../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation_unittests',
Expand Down Expand Up @@ -1277,6 +1285,7 @@
'../google_apis/gcm/gcm.gyp:gcm_unit_tests',
'../ppapi/ppapi_internal.gyp:ppapi_unittests',
'../remoting/remoting.gyp:remoting_unittests',
'../skia/skia_tests.gyp:skia_unittests',
'../ui/app_list/app_list.gyp:*',
'../ui/aura/aura.gyp:*',
'../ui/base/ui_base_tests.gyp:ui_base_unittests',
Expand Down
17 changes: 0 additions & 17 deletions chrome/chrome_tests_unit.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -1418,17 +1418,6 @@
'../components/search_engines/template_url_service_sync_unittest.cc',
'../components/search_engines/template_url_service_unittest.cc',

'../skia/ext/analysis_canvas_unittest.cc',
'../skia/ext/bitmap_platform_device_mac_unittest.cc',
'../skia/ext/convolver_unittest.cc',
'../skia/ext/image_operations_unittest.cc',
'../skia/ext/pixel_ref_utils_unittest.cc',
'../skia/ext/platform_canvas_unittest.cc',
'../skia/ext/recursive_gaussian_convolution_unittest.cc',
'../skia/ext/refptr_unittest.cc',
'../skia/ext/skia_utils_ios_unittest.mm',
'../skia/ext/skia_utils_mac_unittest.mm',
'../skia/ext/vector_canvas_unittest.cc',
'../testing/gtest_mac_unittest.mm',
'../third_party/zlib/google/zip_reader_unittest.cc',
'../third_party/zlib/google/zip_unittest.cc',
Expand Down Expand Up @@ -2478,11 +2467,6 @@
'tools/convert_dict/convert_dict.gyp:convert_dict_lib',
],
}],
['OS!="win" and OS!="mac"', {
'sources!': [
'../skia/ext/platform_canvas_unittest.cc',
],
}],
['OS=="win" or OS=="mac"', {
'sources': [
'browser/media_galleries/fileapi/itunes_file_util_unittest.cc',
Expand Down Expand Up @@ -2561,7 +2545,6 @@
'browser/search_engines/template_url_scraper_unittest.cc',
'browser/ui/views/extensions/browser_action_drag_data_unittest.cc',
'test/data/resource.rc',
'../skia/ext/vector_canvas_unittest.cc',
],
}],
['OS=="android" or OS=="ios"', {
Expand Down
46 changes: 46 additions & 0 deletions skia/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import("//build/config/ui.gni")
if (cpu_arch == "arm") {
import("//build/config/arm.gni")
}
if (is_android) {
import("//build/config/android/rules.gni")
}

skia_support_gpu = !is_ios
skia_support_pdf = !is_ios && (enable_basic_printing || enable_print_preview)
Expand Down Expand Up @@ -710,3 +713,46 @@ source_set("skia_opts") {

visibility = [ ":skia" ]
}

test("skia_unittests") {
sources = [
"ext/analysis_canvas_unittest.cc",
"ext/bitmap_platform_device_mac_unittest.cc",
"ext/convolver_unittest.cc",
"ext/image_operations_unittest.cc",
"ext/pixel_ref_utils_unittest.cc",
"ext/platform_canvas_unittest.cc",
"ext/recursive_gaussian_convolution_unittest.cc",
"ext/refptr_unittest.cc",
"ext/skia_utils_ios_unittest.mm",
"ext/skia_utils_mac_unittest.mm",
"ext/vector_canvas_unittest.cc",
]

if (!is_win) {
sources -= [ "ext/vector_canvas_unittest.cc" ]
}

if (!is_win && !is_mac) {
sources -= [ "ext/platform_canvas_unittest.cc" ]
}

deps = [
":skia",
"//base",
"//base/test:run_all_unittests",
"//testing/gtest",
"//ui/gfx",
"//ui/gfx/geometry",
]
}

if (is_android) {
# GYP: //skia/skia_tests.gyp:skia_unittests_apk
unittest_apk("skia_unittests_apk") {
unittests_dep = ":skia_unittests"
deps = [
":skia_unittests",
]
}
}
29 changes: 17 additions & 12 deletions skia/ext/platform_canvas_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@

// TODO(awalker): clean up the const/non-const reference handling in this test

#include "skia/ext/platform_canvas.h"

#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "skia/ext/platform_device.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkPixelRef.h"

#if defined(OS_MACOSX)
#import <ApplicationServices/ApplicationServices.h>
Expand All @@ -14,15 +24,6 @@
#include <unistd.h>
#endif

#include "base/memory/scoped_ptr.h"
#include "skia/ext/platform_canvas.h"
#include "skia/ext/platform_device.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkPixelRef.h"

namespace skia {

namespace {
Expand Down Expand Up @@ -67,8 +68,12 @@ bool VerifyRect(const PlatformCanvas& canvas,
// rectangle. Basically, we're just checking to make sure that the pixels in the
// middle are of rect_color and pixels in the corners are of canvas_color.
bool VerifyRoundedRect(const PlatformCanvas& canvas,
uint32_t canvas_color, uint32_t rect_color,
int x, int y, int w, int h) {
uint32_t canvas_color,
uint32_t rect_color,
int x,
int y,
int w,
int h) {
SkBaseDevice* device = skia::GetTopDevice(canvas);
const SkBitmap& bitmap = device->accessBitmap(false);
SkAutoLockPixels lock(bitmap);
Expand Down Expand Up @@ -126,7 +131,7 @@ void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) {
}
#else
void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) {
notImplemented();
NOTIMPLEMENTED();
}
#endif

Expand Down
65 changes: 65 additions & 0 deletions skia/skia_tests.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 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': 'skia_unittests',
'type': '<(gtest_target_type)',
'dependencies': [
'../base/base.gyp:base',
'../base/base.gyp:run_all_unittests',
'../testing/gtest.gyp:gtest',
'../skia/skia.gyp:skia',
'../ui/gfx/gfx.gyp:gfx',
'../ui/gfx/gfx.gyp:gfx_geometry',
],
'sources': [
'ext/analysis_canvas_unittest.cc',
'ext/bitmap_platform_device_mac_unittest.cc',
'ext/convolver_unittest.cc',
'ext/image_operations_unittest.cc',
'ext/pixel_ref_utils_unittest.cc',
'ext/platform_canvas_unittest.cc',
'ext/recursive_gaussian_convolution_unittest.cc',
'ext/refptr_unittest.cc',
'ext/skia_utils_ios_unittest.mm',
'ext/skia_utils_mac_unittest.mm',
'ext/vector_canvas_unittest.cc',
],
'conditions': [
['OS != "win"', {
'sources!': [
'ext/vector_canvas_unittest.cc',
],
}],
['OS != "win" and OS != "mac"', {
'sources!': [
'ext/platform_canvas_unittest.cc',
],
}],
],
},
],
'conditions': [
['OS == "android"', {
'targets': [
{
'target_name': 'skia_unittests_apk',
'type': 'none',
'dependencies': [
'skia_unittests',
],
'variables': {
'test_suite_name': 'skia_unittests',
},
'includes': [ '../build/apk_test.gypi' ],
},
],
}],
],
}
5 changes: 4 additions & 1 deletion testing/buildbot/chromium.chromiumos.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"athena_unittests",
"app_shell_browsertests",
"app_shell_unittests",
"chromevox_tests"
"chromevox_tests",
"skia_unittests"
]
},
"Linux ChromiumOS Ozone Tests (1)": {
Expand Down Expand Up @@ -149,6 +150,7 @@
"test": "sandbox_linux_unittests",
"args": ["--test-launcher-print-test-stdio=always"]
},
"skia_unittests",
"sql_unittests",
"sync_unit_tests",
"ui_base_unittests",
Expand Down Expand Up @@ -250,6 +252,7 @@
},
"athena_unittests",
"gcm_unit_tests",
"skia_unittests",
{
"test": "interactive_ui_tests",
"swarming": {
Expand Down
5 changes: 5 additions & 0 deletions testing/buildbot/chromium.fyi.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"printing_unittests",
"remoting_unittests",
"sandbox_linux_unittests",
"skia_unittests",
"ui_base_unittests",
"ui_touch_selection_unittests",
"ipc_tests",
Expand Down Expand Up @@ -98,6 +99,7 @@
"printing_unittests",
"remoting_unittests",
"sandbox_linux_unittests",
"skia_unittests",
"ui_base_unittests",
"ui_touch_selection_unittests",
"ipc_tests",
Expand Down Expand Up @@ -164,6 +166,7 @@
"printing_unittests",
"remoting_unittests",
"sandbox_linux_unittests",
"skia_unittests",
"ui_base_unittests",
"ui_touch_selection_unittests",
"ipc_tests",
Expand Down Expand Up @@ -230,6 +233,7 @@
"printing_unittests",
"remoting_unittests",
"sandbox_linux_unittests",
"skia_unittests",
"ui_base_unittests",
"ui_touch_selection_unittests",
"ipc_tests",
Expand Down Expand Up @@ -305,6 +309,7 @@
"printing_unittests",
"remoting_unittests",
"sandbox_mac_unittests",
"skia_unittests",
"sql_unittests",
"sync_integration_tests",
"sync_unit_tests",
Expand Down
12 changes: 8 additions & 4 deletions testing/buildbot/chromium.linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
},
"url_unittests",
"views_unittests",
"wm_unittests"
"wm_unittests",
"skia_unittests"
],
"scripts": [
{
Expand Down Expand Up @@ -262,7 +263,8 @@
},
"url_unittests",
"views_unittests",
"wm_unittests"
"wm_unittests",
"skia_unittests"
],
"scripts": [
{
Expand Down Expand Up @@ -398,7 +400,8 @@
},
"url_unittests",
"views_unittests",
"wm_unittests"
"wm_unittests",
"skia_unittests"
],
"scripts": [
{
Expand Down Expand Up @@ -440,7 +443,8 @@
"sql_unittests",
"sync_unit_tests",
"ui_base_unittests",
"unit_tests"
"unit_tests",
"skia_unittests"
]
}
}
Loading

0 comments on commit c87c3d2

Please sign in to comment.