summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp39
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());
+}