summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2017-05-24 21:58:48 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-05-25 13:51:42 +0000
commitc11bf4882a8bd7f0f611650cbd5b6bb69f31b9a4 (patch)
treea6efc5cd78595bd2f73d254d29fbe25ef0c7e396 /xfa/fxfa/fm2js
parent151c14f7c7100420670133c18abb94cfa9324745 (diff)
downloadpdfium-c11bf4882a8bd7f0f611650cbd5b6bb69f31b9a4.tar.xz
Enable FM2JSContext Choose tests
This Cl enables the Choose tests for FM2JSContext. The Choose tests always return a String. Change-Id: I29b3ce4ed38f94886c6036f3766182fecb6e787b Reviewed-on: https://pdfium-review.googlesource.com/5893 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp
index e9120dc3a0..a30a81742e 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext_embeddertest.cpp
@@ -797,26 +797,27 @@ TEST_F(FM2JSContextEmbedderTest, Term) {
}
}
-TEST_F(FM2JSContextEmbedderTest, DISABLED_Choose) {
+TEST_F(FM2JSContextEmbedderTest, Choose) {
ASSERT_TRUE(OpenDocument("simple_xfa.pdf"));
- EXPECT_TRUE(
- Execute("Choose(3, \"Taxes\", \"Price\", \"Person\", \"Teller\")"));
- CFXJSE_Value* value = GetValue();
- EXPECT_TRUE(value->IsString());
- EXPECT_STREQ("Person", value->ToString().c_str());
+ struct {
+ const char* program;
+ const char* result;
+ } tests[] = {
+ {"Choose(3, \"Taxes\", \"Price\", \"Person\", \"Teller\")", "Person"},
+ {"Choose(2, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)", "9"},
+ {"Choose(20/3, \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\")",
+ "F"}};
- EXPECT_TRUE(Execute("Choose(2, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)"));
- value = GetValue();
- EXPECT_TRUE(value->IsInteger());
- EXPECT_EQ(9, value->ToInteger());
+ for (size_t i = 0; i < FX_ArraySize(tests); ++i) {
+ EXPECT_TRUE(Execute(tests[i].program));
- EXPECT_TRUE(Execute(
- "Choose(20/3, \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\")"));
- value = GetValue();
- EXPECT_TRUE(value->IsString());
- EXPECT_STREQ("F", value->ToString().c_str())
- << " Result: '" << value->ToString().c_str() << "'";
+ CFXJSE_Value* value = GetValue();
+ EXPECT_TRUE(value->IsString());
+ EXPECT_STREQ(tests[i].result, value->ToString().c_str())
+ << "Program: " << tests[i].program << " Result: '"
+ << value->ToString().c_str() << "'";
+ }
}
TEST_F(FM2JSContextEmbedderTest, DISABLED_Exists) {