summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfsave_embeddertest.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-03-14 13:51:24 -0400
committerDan Sinclair <dsinclair@chromium.org>2016-03-14 13:51:24 -0400
commitf766ad219f66543654520f6a1955836f519e26d1 (patch)
tree2edf8bc93b89503a3669f7add5b6c2a407b8a78c /fpdfsdk/fpdfsave_embeddertest.cpp
parent54b0abed08048008498471e39b7c72b034474090 (diff)
downloadpdfium-f766ad219f66543654520f6a1955836f519e26d1.tar.xz
Move fpdfsdk/src up to fpdfsdk/.
This CL moves the files in fpdfsdk/src/ up one level to fpdfsdk/ and fixes up the include paths, include guards and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1799773002 .
Diffstat (limited to 'fpdfsdk/fpdfsave_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfsave_embeddertest.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfsave_embeddertest.cpp b/fpdfsdk/fpdfsave_embeddertest.cpp
new file mode 100644
index 0000000000..1c93f4f0e1
--- /dev/null
+++ b/fpdfsdk/fpdfsave_embeddertest.cpp
@@ -0,0 +1,52 @@
+// Copyright 2016 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 <string.h>
+
+#include "core/include/fxcrt/fx_string.h"
+#include "public/fpdf_save.h"
+#include "public/fpdfview.h"
+#include "testing/embedder_test.h"
+#include "testing/fx_string_testhelpers.h"
+#include "testing/gmock/include/gmock/gmock-matchers.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/test_support.h"
+
+class FPDFSaveEmbedderTest : public EmbedderTest, public TestSaver {};
+
+TEST_F(FPDFSaveEmbedderTest, SaveSimpleDoc) {
+ EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
+ EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n"));
+ EXPECT_EQ(843, GetString().length());
+}
+
+TEST_F(FPDFSaveEmbedderTest, SaveSimpleDocWithVersion) {
+ EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, 14));
+ EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.4\r\n"));
+ EXPECT_EQ(843, GetString().length());
+}
+
+TEST_F(FPDFSaveEmbedderTest, SaveSimpleDocWithBadVersion) {
+ EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, -1));
+ EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n"));
+
+ ClearString();
+ EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, 0));
+ EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n"));
+
+ ClearString();
+ EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, 18));
+ EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n"));
+}
+
+TEST_F(FPDFSaveEmbedderTest, BUG_342) {
+ EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
+ EXPECT_THAT(GetString(), testing::HasSubstr("0000000000 65535 f\r\n"));
+ EXPECT_THAT(GetString(),
+ testing::Not(testing::HasSubstr("0000000000 65536 f\r\n")));
+}