diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-05-18 14:11:29 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-18 18:24:51 +0000 |
commit | 14aacd5825bcbeca10326f52612bbc2fdb298485 (patch) | |
tree | 7b6c2a43e6bddb6b13e938299d5c6ac7a81b4b46 /xfa/fxfa | |
parent | f0a404d41fcc72f59b528002ef9b2d6011992bc8 (diff) | |
download | pdfium-14aacd5825bcbeca10326f52612bbc2fdb298485.tar.xz |
Adding fm2js embedder tests
This Cl adds the basis of the test framework to execute the javascript
produced by CXFA_FM2JSContext and verify the results are correct.
Change-Id: Ie46625b7e27ca0808e9cc41fdc00b7c0a212837d
Reviewed-on: https://pdfium-review.googlesource.com/5651
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp new file mode 100644 index 0000000000..a94e8a9aa2 --- /dev/null +++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp @@ -0,0 +1,39 @@ +// 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 "testing/gtest/include/gtest/gtest.h" +#include "testing/xfa_js_embedder_test.h" + +class FM2JSContextEmbedderTest : public XFAJSEmbedderTest {}; + +TEST_F(FM2JSContextEmbedderTest, TranslateEmpty) { + ASSERT_TRUE(OpenDocument("simple_xfa.pdf")); + + const char input[] = ""; + EXPECT_TRUE(Execute(input)); + // TODO(dsinclair): This should probably throw as a blank formcalc script + // is invalid. +} + +TEST_F(FM2JSContextEmbedderTest, TranslateNumber) { + ASSERT_TRUE(OpenDocument("simple_xfa.pdf")); + + const char input[] = "123"; + EXPECT_TRUE(Execute(input)); + + CFXJSE_Value* value = GetValue(); + ASSERT_TRUE(value->IsNumber()); + EXPECT_EQ(123, value->ToInteger()); +} + +TEST_F(FM2JSContextEmbedderTest, Add) { + ASSERT_TRUE(OpenDocument("simple_xfa.pdf")); + + const char input[] = "123 + 456"; + EXPECT_TRUE(Execute(input)); + + CFXJSE_Value* value = GetValue(); + ASSERT_TRUE(value->IsNumber()); + EXPECT_EQ(579, value->ToInteger()); +} |