summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-02-27 12:56:25 -0800
committerTom Sepez <tsepez@chromium.org>2015-02-27 12:56:25 -0800
commit3d25502adc5ae37d1c3c74d367f16f770c465109 (patch)
treeba894fdc7bba7e097864898fa2f80318c9b17638
parentec61a859344dc6d2a60e4cbcd1555e6d317f2add (diff)
downloadpdfium-3d25502adc5ae37d1c3c74d367f16f770c465109.tar.xz
Pull in gmock for standalone pdfium builds.
For chromium checkouts, the top-level gmock is used instead. Verify build with a simple test that ensures neither mock method is fired. R=thestig@chromium.org Review URL: https://codereview.chromium.org/955513009
-rw-r--r--BUILD.gn3
-rw-r--r--DEPS3
-rw-r--r--fpdfsdk/src/fpdfformfill_embeddertest.cpp27
-rw-r--r--pdfium.gyp3
-rw-r--r--testing/embedder_test.cpp2
-rw-r--r--testing/embedder_test_mock_delegate.h19
-rw-r--r--testing/gmock.gyp58
7 files changed, 115 insertions, 0 deletions
diff --git a/BUILD.gn b/BUILD.gn
index d6268a4967..3c6c74ab11 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -820,14 +820,17 @@ test("pdfium_embeddertests") {
sources = [
"fpdfsdk/src/fpdf_dataavail_embeddertest.cpp",
"fpdfsdk/src/fpdfdoc_embeddertest.cpp",
+ "fpdfsdk/src/fpdfformfill_embeddertest.cpp",
"fpdfsdk/src/fpdftext_embeddertest.cpp",
"fpdfsdk/src/fpdfview_embeddertest.cpp",
"testing/embedder_test.cpp",
"testing/embedder_test.h",
+ "testing/embedder_test_mock_delegate.h",
"testing/fx_string_testhelpers.cpp",
"testing/fx_string_testhelpers.h",
]
deps = [
+ "//testing/gmock",
"//testing/gtest",
":pdfium"
]
diff --git a/DEPS b/DEPS
index 335f80231b..6bde04d7e1 100644
--- a/DEPS
+++ b/DEPS
@@ -4,6 +4,9 @@ deps = {
"build/gyp":
"https://chromium.googlesource.com/external/gyp",
+ "testing/gmock":
+ "https://chromium.googlesource.com/external/googlemock.git@29763965ab52f24565299976b936d1265cb6a271",
+
"testing/gtest":
"https://chromium.googlesource.com/external/googletest.git@8245545b6dc9c4703e6496d1efd19e975ad2b038",
diff --git a/fpdfsdk/src/fpdfformfill_embeddertest.cpp b/fpdfsdk/src/fpdfformfill_embeddertest.cpp
new file mode 100644
index 0000000000..3fe34d5d8c
--- /dev/null
+++ b/fpdfsdk/src/fpdfformfill_embeddertest.cpp
@@ -0,0 +1,27 @@
+// Copyright 2015 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.
+
+
+#include "../../fpdfsdk/include/fpdfformfill.h"
+#include "../../testing/embedder_test.h"
+#include "../../testing/embedder_test_mock_delegate.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::_;
+using testing::Return;
+
+class FPDFFormFillEmbeddertest : public EmbedderTest {
+};
+
+TEST_F(FPDFFormFillEmbeddertest, FirstTest) {
+ EmbedderTestMockDelegate mock;
+ EXPECT_CALL(mock, Alert(_, _, _, _)).Times(0);
+ EXPECT_CALL(mock, UnsupportedHandler(_)).Times(0);
+ SetDelegate(&mock);
+
+ EXPECT_TRUE(OpenDocument("testing/resources/hello_world.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_NE(nullptr, page);
+}
diff --git a/pdfium.gyp b/pdfium.gyp
index c1cd724dc9..7b959bd45c 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -847,6 +847,7 @@
'target_name': 'pdfium_embeddertests',
'type': 'executable',
'dependencies': [
+ '<(DEPTH)/testing/gmock.gyp:gmock',
'<(DEPTH)/testing/gtest.gyp:gtest',
'pdfium',
],
@@ -856,10 +857,12 @@
'sources': [
'fpdfsdk/src/fpdf_dataavail_embeddertest.cpp',
'fpdfsdk/src/fpdfdoc_embeddertest.cpp',
+ 'fpdfsdk/src/fpdfformfill_embeddertest.cpp',
'fpdfsdk/src/fpdftext_embeddertest.cpp',
'fpdfsdk/src/fpdfview_embeddertest.cpp',
'testing/embedder_test.cpp',
'testing/embedder_test.h',
+ 'testing/embedder_test_mock_delegate.h',
'testing/fx_string_testhelpers.cpp',
'testing/fx_string_testhelpers.h',
],
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index fc6b4dbc80..e8d5a09f65 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -17,6 +17,7 @@
#include "../fpdfsdk/include/fpdftext.h"
#include "../fpdfsdk/include/fpdfview.h"
#include "../core/include/fxcrt/fx_system.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "v8/include/v8.h"
#ifdef _WIN32
@@ -340,5 +341,6 @@ int EmbedderTest::AlertTrampoline(IPDF_JSPLATFORM* platform,
int main(int argc, char** argv) {
g_exe_path_ = argv[0];
testing::InitGoogleTest(&argc, argv);
+ testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}
diff --git a/testing/embedder_test_mock_delegate.h b/testing/embedder_test_mock_delegate.h
new file mode 100644
index 0000000000..526e11774e
--- /dev/null
+++ b/testing/embedder_test_mock_delegate.h
@@ -0,0 +1,19 @@
+// Copyright 2015 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.
+
+#ifndef TESTING_EMBEDDER_TEST_MOCK_DELEGATE_H_
+#define TESTING_EMBEDDER_TEST_MOCK_DELEGATE_H_
+
+#include "embedder_test.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+class EmbedderTestMockDelegate : public EmbedderTest::Delegate {
+ public:
+ MOCK_METHOD1(UnsupportedHandler, void(int type));
+ MOCK_METHOD4(Alert, int(FPDF_WIDESTRING message, FPDF_WIDESTRING title,
+ int type, int icon));
+};
+
+#endif // TESTING_EMBEDDER_TEST_MOCK_DELEGATE_H_
+
diff --git a/testing/gmock.gyp b/testing/gmock.gyp
new file mode 100644
index 0000000000..55e1609d27
--- /dev/null
+++ b/testing/gmock.gyp
@@ -0,0 +1,58 @@
+# Copyright 2015 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.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'gmock',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'gtest.gyp:gtest',
+ ],
+ 'sources': [
+ # Sources based on files in r173 of gmock.
+ 'gmock/include/gmock/gmock-actions.h',
+ 'gmock/include/gmock/gmock-cardinalities.h',
+ 'gmock/include/gmock/gmock-generated-actions.h',
+ 'gmock/include/gmock/gmock-generated-function-mockers.h',
+ 'gmock/include/gmock/gmock-generated-matchers.h',
+ 'gmock/include/gmock/gmock-generated-nice-strict.h',
+ 'gmock/include/gmock/gmock-matchers.h',
+ 'gmock/include/gmock/gmock-spec-builders.h',
+ 'gmock/include/gmock/gmock.h',
+ 'gmock/include/gmock/internal/gmock-generated-internal-utils.h',
+ 'gmock/include/gmock/internal/gmock-internal-utils.h',
+ 'gmock/include/gmock/internal/gmock-port.h',
+ 'gmock/src/gmock-cardinalities.cc',
+ 'gmock/src/gmock-internal-utils.cc',
+ 'gmock/src/gmock-matchers.cc',
+ 'gmock/src/gmock-spec-builders.cc',
+ 'gmock/src/gmock.cc',
+ 'gmock_mutant.h', # gMock helpers
+ ],
+ 'include_dirs': [
+ 'gmock',
+ 'gmock/include',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ 'gmock/include', # So that gmock headers can find themselves.
+ ],
+ },
+ 'export_dependent_settings': [
+ 'gtest.gyp:gtest',
+ ],
+ },
+ {
+ 'target_name': 'gmock_main',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'gmock',
+ ],
+ 'sources': [
+ 'gmock/src/gmock_main.cc',
+ ],
+ },
+ ],
+}