summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-06-02 16:42:59 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-06-03 00:14:13 +0000
commitaf680b17e0e1b94e40afa6a01ba3bbdead2d6035 (patch)
treeba309c61c9615b0d3623b981c53ec4cb7108bf31 /fpdfsdk/pdfwindow
parent633a3b7b908031ca0db12d7694d6a09715fc6143 (diff)
downloadpdfium-af680b17e0e1b94e40afa6a01ba3bbdead2d6035.tar.xz
Add a basic embedder test for CPWL_Edit.
Change-Id: Ib381423b81e718410cb1d199aadbf396ee08b29a Reviewed-on: https://pdfium-review.googlesource.com/6251 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/pdfwindow')
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit_embeddertest.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/fpdfsdk/pdfwindow/cpwl_edit_embeddertest.cpp b/fpdfsdk/pdfwindow/cpwl_edit_embeddertest.cpp
new file mode 100644
index 0000000000..4a14b65d0d
--- /dev/null
+++ b/fpdfsdk/pdfwindow/cpwl_edit_embeddertest.cpp
@@ -0,0 +1,61 @@
+// Copyright 2017 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/cba_annotiterator.h"
+#include "fpdfsdk/cpdfsdk_annot.h"
+#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
+#include "fpdfsdk/formfiller/cffl_formfiller.h"
+#include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
+#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
+#include "testing/embedder_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class CPWLEditEmbeddertest : public EmbedderTest {};
+
+TEST_F(CPWLEditEmbeddertest, TypeText) {
+ EXPECT_TRUE(OpenDocument("text_form.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ ASSERT_TRUE(page);
+
+ CPDFSDK_FormFillEnvironment* pFormFillEnv =
+ static_cast<CPDFSDK_FormFillEnvironment*>(form_handle());
+
+ CPDFSDK_Annot* pAnnot;
+ {
+ CBA_AnnotIterator iter(pFormFillEnv->GetPageView(0),
+ CPDF_Annot::Subtype::WIDGET);
+ pAnnot = iter.GetFirstAnnot();
+ CPDFSDK_Annot* pLastAnnot = iter.GetLastAnnot();
+ ASSERT_EQ(pAnnot, pLastAnnot);
+ ASSERT_TRUE(pAnnot);
+ ASSERT_EQ(CPDF_Annot::Subtype::WIDGET, pAnnot->GetAnnotSubtype());
+ }
+
+ CFFL_InteractiveFormFiller* pInteractiveFormFiller =
+ pFormFillEnv->GetInteractiveFormFiller();
+ {
+ CPDFSDK_Annot::ObservedPtr pObserved(pAnnot);
+ EXPECT_TRUE(pInteractiveFormFiller->OnSetFocus(&pObserved, 0));
+ }
+
+ CFFL_FormFiller* pFormFiller =
+ pInteractiveFormFiller->GetFormFiller(pAnnot, false);
+ ASSERT_TRUE(pFormFiller);
+
+ CPWL_Wnd* pWindow =
+ pFormFiller->GetPDFWindow(pFormFillEnv->GetPageView(0), false);
+ ASSERT_TRUE(pWindow);
+ ASSERT_EQ(PWL_CLASSNAME_EDIT, pWindow->GetClassName());
+
+ CPWL_Edit* pEdit = static_cast<CPWL_Edit*>(pWindow);
+ EXPECT_TRUE(pEdit->GetText().IsEmpty());
+
+ EXPECT_TRUE(pFormFiller->OnChar(pAnnot, 'a', 0));
+ EXPECT_TRUE(pFormFiller->OnChar(pAnnot, 'b', 0));
+ EXPECT_TRUE(pFormFiller->OnChar(pAnnot, 'c', 0));
+
+ EXPECT_STREQ(L"abc", pEdit->GetText().c_str());
+
+ UnloadPage(page);
+}