diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | DEPS | 13 | ||||
-rw-r--r-- | testing/gmock/BUILD.gn | 48 | ||||
-rw-r--r-- | testing/gmock/include/gmock/DEPS | 3 | ||||
-rw-r--r-- | testing/gmock/include/gmock/gmock-actions.h | 10 | ||||
-rw-r--r-- | testing/gmock/include/gmock/gmock-generated-function-mockers.h | 10 | ||||
-rw-r--r-- | testing/gmock/include/gmock/gmock-matchers.h | 10 | ||||
-rw-r--r-- | testing/gmock/include/gmock/gmock.h | 10 | ||||
-rw-r--r-- | testing/gtest/BUILD.gn | 100 | ||||
-rw-r--r-- | testing/gtest/empty.cc | 3 | ||||
-rw-r--r-- | testing/gtest/include/gtest/DEPS | 4 | ||||
-rw-r--r-- | testing/gtest/include/gtest/gtest.h | 10 | ||||
-rw-r--r-- | testing/gtest/include/gtest/gtest_prod.h | 10 | ||||
-rw-r--r-- | third_party/googletest/BUILD.gn | 144 | ||||
-rw-r--r-- | third_party/googletest/README.pdfium | 18 |
15 files changed, 386 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore index 830cb6e074..a1b040585f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,13 +3,12 @@ /buildtools /out /testing/corpus -/testing/gmock -/testing/gtest /third_party/android_ndk /third_party/binutils /third_party/catapult /third_party/depot_tools /third_party/freetype/src +/third_party/googletest/src /third_party/icu /third_party/instrumented_libraries /third_party/jinja2 @@ -22,8 +22,7 @@ vars = { 'cygwin_revision': 'c89e446b273697fadf3a10ff1007a97c0b7de6df', 'depot_tools_revision': '2e8d8348b8574f06c26dbf3ef959b5df11ba5148', 'freetype_revision': '713d68ee9f47cc8df56e47fa2f54b191bb8c3186', - 'gmock_revision': '29763965ab52f24565299976b936d1265cb6a271', - 'gtest_revision': '8245545b6dc9c4703e6496d1efd19e975ad2b038', + 'gtest_revision': 'a325ad2db5deb623eab740527e559b81c0f39d65', 'icu_revision': 'e3b480d3be4446ea17011c0cdc9c4cd380a5c58f', 'instrumented_lib_revision': '323cf32193caecbf074d1a0cb5b02b905f163e0f', 'jinja2_revision': 'd34383206fa42d52faa10bb9931d6d538f3a57e0', @@ -53,12 +52,6 @@ deps = { "testing/corpus": Var('pdfium_git') + "/pdfium_tests@" + Var('pdfium_tests_revision'), - "testing/gmock": - Var('chromium_git') + "/external/googlemock.git@" + Var('gmock_revision'), - - "testing/gtest": - Var('chromium_git') + "/external/googletest.git@" + Var('gtest_revision'), - "third_party/binutils": Var('chromium_git') + "/chromium/src/third_party/binutils.git@" + Var('binutils_revision'), @@ -71,6 +64,10 @@ deps = { Var('chromium_git') + '/chromium/src/third_party/freetype2.git@' + Var('freetype_revision'), + "third_party/googletest/src": + Var('chromium_git') + '/external/github.com/google/googletest.git' + '@' + + Var('gtest_revision'), + "third_party/icu": Var('chromium_git') + "/chromium/deps/icu.git@" + Var('icu_revision'), diff --git a/testing/gmock/BUILD.gn b/testing/gmock/BUILD.gn new file mode 100644 index 0000000000..a22d8929e6 --- /dev/null +++ b/testing/gmock/BUILD.gn @@ -0,0 +1,48 @@ +# Copyright 2018 The PDFium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# The file/directory layout of Google Test is not yet considered stable. Until +# it stabilizes, Chromium code MUST use this target instead of reaching directly +# into //third_party/googletest. + +import("//build_overrides/build.gni") + +source_set("gmock") { + testonly = true + sources = [ + "include/gmock/gmock-actions.h", + "include/gmock/gmock-generated-function-mockers.h", + "include/gmock/gmock-matchers.h", + "include/gmock/gmock.h", + ] + deps = [ + "//third_party/googletest:gmock", + ] + + # TODO(crbug.com/806952): Depending on gmock_mutant only if build_with_chromium, + # because gmock_mutant depends on //base which uses C++14. Since gmock is a + # third_party library used by other projects it should not include C++14 only code. + if (build_with_chromium) { + # Allow Chromium targets depending on gmock to #include testing/gmock_mutant.h + # without triggering a `gn check` error. + public_deps = [ + "//testing:gmock_mutant", + ] + } + + public_configs = [ + "//third_party/googletest:gmock_config", + "//third_party/googletest:gtest_config", + ] +} + +# The file/directory layout of Google Test is not yet considered stable. Until +# it stabilizes, Chromium code MUST use this target instead of reaching directly +# into //third_party/googletest. +source_set("gmock_main") { + testonly = true + deps = [ + "//third_party/googletest:gmock_main", + ] +} diff --git a/testing/gmock/include/gmock/DEPS b/testing/gmock/include/gmock/DEPS new file mode 100644 index 0000000000..c817a8474e --- /dev/null +++ b/testing/gmock/include/gmock/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + '+third_party/googletest/src/googlemock/include/gmock', +] diff --git a/testing/gmock/include/gmock/gmock-actions.h b/testing/gmock/include/gmock/gmock-actions.h new file mode 100644 index 0000000000..fb193e5dd9 --- /dev/null +++ b/testing/gmock/include/gmock/gmock-actions.h @@ -0,0 +1,10 @@ +// Copyright 2018 The PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// The file/directory layout of Google Test is not yet considered stable. Until +// it stabilizes, Chromium code will use forwarding headers in testing/gtest +// and testing/gmock, instead of directly including files in +// third_party/googletest. + +#include "third_party/googletest/src/googlemock/include/gmock/gmock-actions.h" diff --git a/testing/gmock/include/gmock/gmock-generated-function-mockers.h b/testing/gmock/include/gmock/gmock-generated-function-mockers.h new file mode 100644 index 0000000000..57cbc0a044 --- /dev/null +++ b/testing/gmock/include/gmock/gmock-generated-function-mockers.h @@ -0,0 +1,10 @@ +// Copyright 2018 The PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// The file/directory layout of Google Test is not yet considered stable. Until +// it stabilizes, Chromium code will use forwarding headers in testing/gtest +// and testing/gmock, instead of directly including files in +// third_party/googletest. + +#include "third_party/googletest/src/googlemock/include/gmock/gmock-generated-function-mockers.h" diff --git a/testing/gmock/include/gmock/gmock-matchers.h b/testing/gmock/include/gmock/gmock-matchers.h new file mode 100644 index 0000000000..25d25e9080 --- /dev/null +++ b/testing/gmock/include/gmock/gmock-matchers.h @@ -0,0 +1,10 @@ +// Copyright 2018 The PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// The file/directory layout of Google Test is not yet considered stable. Until +// it stabilizes, Chromium code will use forwarding headers in testing/gtest +// and testing/gmock, instead of directly including files in +// third_party/googletest. + +#include "third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h" diff --git a/testing/gmock/include/gmock/gmock.h b/testing/gmock/include/gmock/gmock.h new file mode 100644 index 0000000000..a344bcbf55 --- /dev/null +++ b/testing/gmock/include/gmock/gmock.h @@ -0,0 +1,10 @@ +// Copyright 2018 The PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// The file/directory layout of Google Test is not yet considered stable. Until +// it stabilizes, Chromium code will use forwarding headers in testing/gtest +// and testing/gmock, instead of directly including files in +// third_party/googletest. + +#include "third_party/googletest/src/googlemock/include/gmock/gmock.h" diff --git a/testing/gtest/BUILD.gn b/testing/gtest/BUILD.gn new file mode 100644 index 0000000000..4c1ce37bcd --- /dev/null +++ b/testing/gtest/BUILD.gn @@ -0,0 +1,100 @@ +# Copyright 2018 The PDFium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build_overrides/gtest.gni") +if (is_ios) { + import("//build/config/coverage/coverage.gni") + import("//build/config/ios/ios_sdk.gni") + import("//build/buildflag_header.gni") +} + +config("gtest_direct_config") { + visibility = [ ":*" ] + defines = [ "UNIT_TEST" ] +} + +# The file/directory layout of Google Test is not yet considered stable. Until +# it stabilizes, Chromium code MUST use this target instead of reaching directly +# into //third_party/googletest. +static_library("gtest") { + testonly = true + + sources = [ + "include/gtest/gtest-death-test.h", + "include/gtest/gtest-message.h", + "include/gtest/gtest-param-test.h", + "include/gtest/gtest-spi.h", + "include/gtest/gtest.h", + "include/gtest/gtest_prod.h", + + # This is a workaround for the issues below. + # + # 1) This target needs to be a static_library (not a source set) on Mac to + # avoid the build errors in + # https://codereview.chromium.org/2779193002#msg82. + # 2) A static_library must have at least one source file, to avoid build + # errors on Mac and Windows. https://crbug.com/710334 + # 3) A static_library with complete_static_lib = true, which would not + # require adding the empty file, will result in duplicate symbols on + # Android. https://codereview.chromium.org/2852613002/#ps20001 + "empty.cc", + ] + public_deps = [ + "//third_party/googletest:gtest", + ] + + public_configs = [ ":gtest_direct_config" ] + + if (gtest_include_multiprocess) { + sources += [ + "../multiprocess_func_list.cc", + "../multiprocess_func_list.h", + ] + } + + if (gtest_include_platform_test) { + sources += [ "../platform_test.h" ] + } + + if ((is_mac || is_ios) && gtest_include_objc_support) { + if (is_ios) { + set_sources_assignment_filter([]) + } + sources += [ + "../gtest_mac.h", + "../gtest_mac.mm", + ] + if (gtest_include_platform_test) { + sources += [ "../platform_test_mac.mm" ] + } + set_sources_assignment_filter(sources_assignment_filter) + } + + if (is_ios && gtest_include_ios_coverage) { + sources += [ + "../coverage_util_ios.h", + "../coverage_util_ios.mm", + ] + deps = [ + ":ios_enable_coverage", + ] + } +} + +# The file/directory layout of Google Test is not yet considered stable. Until +# it stabilizes, Chromium code MUST use this target instead of reaching directly +# into //third_party/googletest. +source_set("gtest_main") { + testonly = true + deps = [ + "//third_party/googletest:gtest_main", + ] +} + +if (is_ios) { + buildflag_header("ios_enable_coverage") { + header = "ios_enable_coverage.h" + flags = [ "IOS_ENABLE_COVERAGE=$use_clang_coverage" ] + } +} diff --git a/testing/gtest/empty.cc b/testing/gtest/empty.cc new file mode 100644 index 0000000000..5186b599d2 --- /dev/null +++ b/testing/gtest/empty.cc @@ -0,0 +1,3 @@ +// Copyright 2018 The PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. diff --git a/testing/gtest/include/gtest/DEPS b/testing/gtest/include/gtest/DEPS new file mode 100644 index 0000000000..eb5e079aed --- /dev/null +++ b/testing/gtest/include/gtest/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + '+third_party/googletest/src/googletest/include/gtest', +] + diff --git a/testing/gtest/include/gtest/gtest.h b/testing/gtest/include/gtest/gtest.h new file mode 100644 index 0000000000..9425b25c15 --- /dev/null +++ b/testing/gtest/include/gtest/gtest.h @@ -0,0 +1,10 @@ +// Copyright 2018 The PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// The file/directory layout of Google Test is not yet considered stable. Until +// it stabilizes, Chromium code will use forwarding headers in testing/gtest +// and testing/gmock, instead of directly including files in +// third_party/googletest. + +#include "third_party/googletest/src/googletest/include/gtest/gtest.h" diff --git a/testing/gtest/include/gtest/gtest_prod.h b/testing/gtest/include/gtest/gtest_prod.h new file mode 100644 index 0000000000..2d67b42013 --- /dev/null +++ b/testing/gtest/include/gtest/gtest_prod.h @@ -0,0 +1,10 @@ +// Copyright 2018 The PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// The file/directory layout of Google Test is not yet considered stable. Until +// it stabilizes, Chromium code will use forwarding headers in testing/gtest +// and testing/gmock, instead of directly including files in +// third_party/googletest. + +#include "third_party/googletest/src/googletest/include/gtest/gtest_prod.h" diff --git a/third_party/googletest/BUILD.gn b/third_party/googletest/BUILD.gn new file mode 100644 index 0000000000..d04d804046 --- /dev/null +++ b/third_party/googletest/BUILD.gn @@ -0,0 +1,144 @@ +# Copyright 2018 The PDFium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config("gtest_config") { + visibility = [ ":*" ] # gmock also shares this config. + + defines = [ + # Chromium always links googletest statically, so no API qualifier is + # necessary. The definition in gtest-port.h at the time of this writing + # causes crashes in content_browsertests. + "GTEST_API_=", + + # In order to allow regex matches in gtest to be shared between Windows + # and other systems, we tell gtest to always use its internal engine. + "GTEST_HAS_POSIX_RE=0", + "GTEST_LANG_CXX11=1", + + # ::testing::Combine, which is heavily used in Chromium, is gated on + # tr1::tuple. Upstream avoids using tr1::tuple on Visual Studio 2017+, + # because it causes warnings. We'll take (and ignore) the warnings to keep + # our ::testing::Combine. + "GTEST_HAS_TR1_TUPLE=1", + ] + + # Gtest headers need to be able to find themselves. + include_dirs = [ "src/googletest/include" ] + + if (is_win) { + cflags = [ "/wd4800" ] # Unused variable warning. + } +} + +config("gmock_config") { + # Gmock headers need to be able to find themselves. + include_dirs = [ + "custom", + "src/googlemock/include", + ] +} + +# Do NOT depend on this directly. Use //testing/gtest instead. +# See README.chromium for details. +source_set("gtest") { + testonly = true + sources = [ + "src/googletest/include/gtest/gtest-death-test.h", + "src/googletest/include/gtest/gtest-message.h", + "src/googletest/include/gtest/gtest-param-test.h", + "src/googletest/include/gtest/gtest-printers.h", + "src/googletest/include/gtest/gtest-spi.h", + "src/googletest/include/gtest/gtest-test-part.h", + "src/googletest/include/gtest/gtest-typed-test.h", + "src/googletest/include/gtest/gtest.h", + "src/googletest/include/gtest/gtest_pred_impl.h", + "src/googletest/include/gtest/internal/gtest-death-test-internal.h", + "src/googletest/include/gtest/internal/gtest-filepath.h", + "src/googletest/include/gtest/internal/gtest-internal.h", + "src/googletest/include/gtest/internal/gtest-linked_ptr.h", + "src/googletest/include/gtest/internal/gtest-param-util-generated.h", + "src/googletest/include/gtest/internal/gtest-param-util.h", + "src/googletest/include/gtest/internal/gtest-port.h", + "src/googletest/include/gtest/internal/gtest-string.h", + "src/googletest/include/gtest/internal/gtest-tuple.h", + "src/googletest/include/gtest/internal/gtest-type-util.h", + + #"src/googletest/src/gtest-all.cc", # Not needed by our build. + "src/googletest/src/gtest-death-test.cc", + "src/googletest/src/gtest-filepath.cc", + "src/googletest/src/gtest-internal-inl.h", + "src/googletest/src/gtest-port.cc", + "src/googletest/src/gtest-printers.cc", + "src/googletest/src/gtest-test-part.cc", + "src/googletest/src/gtest-typed-test.cc", + "src/googletest/src/gtest.cc", + ] + + # Some files include "src/gtest-internal-inl.h". + include_dirs = [ "src/googletest" ] + + all_dependent_configs = [ ":gtest_config" ] + + configs -= [ "//build/config/compiler:chromium_code" ] + configs += [ "//build/config/compiler:no_chromium_code" ] +} + +# Do NOT depend on this directly. Use //testing/gtest:gtest_main instead. +# See README.chromium for details. +source_set("gtest_main") { + testonly = true + sources = [ + "src/googletest/src/gtest_main.cc", + ] + deps = [ + ":gtest", + ] +} + +# Do NOT depend on this directly. Use //testing/gmock:gmock_main instead. +# See README.chromium for details. +source_set("gmock") { + testonly = true + sources = [ + "src/googlemock/include/gmock/gmock-actions.h", + "src/googlemock/include/gmock/gmock-cardinalities.h", + "src/googlemock/include/gmock/gmock-generated-actions.h", + "src/googlemock/include/gmock/gmock-generated-function-mockers.h", + "src/googlemock/include/gmock/gmock-generated-matchers.h", + "src/googlemock/include/gmock/gmock-generated-nice-strict.h", + "src/googlemock/include/gmock/gmock-matchers.h", + "src/googlemock/include/gmock/gmock-spec-builders.h", + "src/googlemock/include/gmock/gmock.h", + "src/googlemock/include/gmock/internal/gmock-generated-internal-utils.h", + "src/googlemock/include/gmock/internal/gmock-internal-utils.h", + "src/googlemock/include/gmock/internal/gmock-port.h", + + # gmock helpers. + "custom/gmock/internal/custom/gmock-port.h", + + #"src/googlemock/src/gmock-all.cc", # Not needed by our build. + "src/googlemock/src/gmock-cardinalities.cc", + "src/googlemock/src/gmock-internal-utils.cc", + "src/googlemock/src/gmock-matchers.cc", + "src/googlemock/src/gmock-spec-builders.cc", + "src/googlemock/src/gmock.cc", + ] + + public_configs = [ + ":gmock_config", + ":gtest_config", + ] +} + +# Do NOT depend on this directly. Use //testing/gmock:gmock_main instead. +# See README.chromium for details. +static_library("gmock_main") { + testonly = true + sources = [ + "src/googlemock/src/gmock_main.cc", + ] + deps = [ + ":gmock", + ] +} diff --git a/third_party/googletest/README.pdfium b/third_party/googletest/README.pdfium new file mode 100644 index 0000000000..1b3626cf4b --- /dev/null +++ b/third_party/googletest/README.pdfium @@ -0,0 +1,18 @@ +Name: Google Test: Google's C++ Testing Framework +Short Name: googletest +URL: https://github.com/google/googletest.git +Version: 1.8.0.git-7d15497f7538fb531d0f025929d080743af421ee +License: BSD +License File: NOT_SHIPPED +Security critical: no + +Google Test is imported as-is, to facilitate version bumping. However, the +file/directory layout of Google Test is not yet considered stable. Therefore, +until Google Test's layout stabilizes, PDFium code MUST NOT depend on it +directly. Instead, PDFium code MUST: + +* #include the headers in testing/gtest and testing/gmock +* use //testing/gtest(:gtest_main) and //testing/gmock(:gmock_main) in BUILD.gn + deps + +This will allow us to adapt to Google Test changes with minimal disruption. |