diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-05-25 16:18:40 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-25 16:18:40 +0000 |
commit | cbf1550e48e300142a53f635daba3c1d8910add9 (patch) | |
tree | 71dca5ce8b3b5ac8a9f8ed6930601f3f0a272e0b /fxjs/cfxjse_formcalc_context_embeddertest.cpp | |
parent | 4ba76201df61467928bba429ea1d8115e292072e (diff) | |
download | pdfium-cbf1550e48e300142a53f635daba3c1d8910add9.tar.xz |
[xfa] Generate CXFA_EventParam.newText dynamically
When an xfa.event is sent it is possible to change the selStart, selEnd
and change values of the event. This should cause the value of newText
to be changed as needed.
This CL removes m_wsNewText from CXFA_EventParam and instead generates
the new text based on the previous text, the selection and the change.
Bug: 1066
Change-Id: I35d126fad9771c8980654a8af64d2b98989bff3f
Reviewed-on: https://pdfium-review.googlesource.com/32970
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fxjs/cfxjse_formcalc_context_embeddertest.cpp')
-rw-r--r-- | fxjs/cfxjse_formcalc_context_embeddertest.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/fxjs/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/cfxjse_formcalc_context_embeddertest.cpp index 4b9d93a660..ed0c5bccc7 100644 --- a/fxjs/cfxjse_formcalc_context_embeddertest.cpp +++ b/fxjs/cfxjse_formcalc_context_embeddertest.cpp @@ -1573,3 +1573,40 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, XFAEventCancelAction) { EXPECT_TRUE(Execute("xfa.event.cancelAction = \"true\"")); EXPECT_TRUE(context->GetEventParam()->m_bCancelAction); } + +TEST_F(CFXJSE_FormCalcContextEmbedderTest, ComplexTextChangeEvent) { + ASSERT_TRUE(OpenDocument("simple_xfa.pdf")); + + CXFA_EventParam params; + params.m_wsChange = L"g"; + params.m_wsPrevText = L"abcd"; + params.m_iSelStart = 1; + params.m_iSelEnd = 3; + + CFXJSE_Engine* context = GetScriptContext(); + context->SetEventParam(params); + + EXPECT_EQ(L"abcd", context->GetEventParam()->m_wsPrevText); + EXPECT_EQ(L"agd", context->GetEventParam()->GetNewText()); + EXPECT_EQ(L"g", context->GetEventParam()->m_wsChange); + EXPECT_EQ(1, context->GetEventParam()->m_iSelStart); + EXPECT_EQ(3, context->GetEventParam()->m_iSelEnd); + + const char change_event[] = {"xfa.event.change = \"xyz\""}; + EXPECT_TRUE(Execute(change_event)); + + EXPECT_EQ(L"abcd", context->GetEventParam()->m_wsPrevText); + EXPECT_EQ(L"xyz", context->GetEventParam()->m_wsChange); + EXPECT_EQ(L"axyzd", context->GetEventParam()->GetNewText()); + EXPECT_EQ(1, context->GetEventParam()->m_iSelStart); + EXPECT_EQ(3, context->GetEventParam()->m_iSelEnd); + + const char sel_event[] = {"xfa.event.selEnd = \"1\""}; + EXPECT_TRUE(Execute(sel_event)); + + EXPECT_EQ(L"abcd", context->GetEventParam()->m_wsPrevText); + EXPECT_EQ(L"xyz", context->GetEventParam()->m_wsChange); + EXPECT_EQ(L"axyzbcd", context->GetEventParam()->GetNewText()); + EXPECT_EQ(1, context->GetEventParam()->m_iSelStart); + EXPECT_EQ(1, context->GetEventParam()->m_iSelEnd); +} |