summaryrefslogtreecommitdiff
path: root/fxjs/fxjs_v8_embeddertest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-02-09 18:26:09 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-09 18:26:09 +0000
commit3f8ee5e6b4e42fc77b4716b23ccd00840e24e250 (patch)
tree16406801eae8da64bbe44a1b014a3b3945c22bd6 /fxjs/fxjs_v8_embeddertest.cpp
parent026717cb667cf0c7215cf55daf794d69752fc900 (diff)
downloadpdfium-3f8ee5e6b4e42fc77b4716b23ccd00840e24e250.tar.xz
Move CFX_V8 testing from embeddertest to unittest.
Test the lowest layer without firing up the whole library. Requires firing up v8 in the unit test main, though. Move array buffer allocator to cfx_v8 to allow building isolates. Change-Id: I9a56d503a48e0e555d3310f2997fa12137695860 Reviewed-on: https://pdfium-review.googlesource.com/26130 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/fxjs_v8_embeddertest.cpp')
-rw-r--r--fxjs/fxjs_v8_embeddertest.cpp152
1 files changed, 0 insertions, 152 deletions
diff --git a/fxjs/fxjs_v8_embeddertest.cpp b/fxjs/fxjs_v8_embeddertest.cpp
index acc4366631..77bea86fe1 100644
--- a/fxjs/fxjs_v8_embeddertest.cpp
+++ b/fxjs/fxjs_v8_embeddertest.cpp
@@ -95,155 +95,3 @@ TEST_F(FXJSV8EmbedderTest, MultipleEngines) {
engine1.ReleaseEngine();
engine2.ReleaseEngine();
}
-
-TEST_F(FXJSV8EmbedderTest, EmptyLocal) {
- v8::Isolate::Scope isolate_scope(isolate());
- v8::HandleScope handle_scope(isolate());
- v8::Context::Scope context_scope(GetV8Context());
-
- v8::Local<v8::Value> empty;
- EXPECT_FALSE(engine()->ToBoolean(empty));
- EXPECT_EQ(0, engine()->ToInt32(empty));
- EXPECT_EQ(0.0, engine()->ToDouble(empty));
- EXPECT_EQ(L"", engine()->ToWideString(empty));
- EXPECT_TRUE(engine()->ToObject(empty).IsEmpty());
- EXPECT_TRUE(engine()->ToArray(empty).IsEmpty());
-}
-
-TEST_F(FXJSV8EmbedderTest, NewNull) {
- v8::Isolate::Scope isolate_scope(isolate());
- v8::HandleScope handle_scope(isolate());
- v8::Context::Scope context_scope(GetV8Context());
-
- auto nullz = engine()->NewNull();
- EXPECT_FALSE(engine()->ToBoolean(nullz));
- EXPECT_EQ(0, engine()->ToInt32(nullz));
- EXPECT_EQ(0.0, engine()->ToDouble(nullz));
- EXPECT_EQ(L"null", engine()->ToWideString(nullz));
- EXPECT_TRUE(engine()->ToObject(nullz).IsEmpty());
- EXPECT_TRUE(engine()->ToArray(nullz).IsEmpty());
-}
-
-TEST_F(FXJSV8EmbedderTest, NewUndefined) {
- v8::Isolate::Scope isolate_scope(isolate());
- v8::HandleScope handle_scope(isolate());
- v8::Context::Scope context_scope(GetV8Context());
-
- auto undef = engine()->NewUndefined();
- EXPECT_FALSE(engine()->ToBoolean(undef));
- EXPECT_EQ(0, engine()->ToInt32(undef));
- EXPECT_TRUE(std::isnan(engine()->ToDouble(undef)));
- EXPECT_EQ(L"undefined", engine()->ToWideString(undef));
- EXPECT_TRUE(engine()->ToObject(undef).IsEmpty());
- EXPECT_TRUE(engine()->ToArray(undef).IsEmpty());
-}
-
-TEST_F(FXJSV8EmbedderTest, NewBoolean) {
- v8::Isolate::Scope isolate_scope(isolate());
- v8::HandleScope handle_scope(isolate());
- v8::Context::Scope context_scope(GetV8Context());
-
- auto boolz = engine()->NewBoolean(true);
- EXPECT_TRUE(engine()->ToBoolean(boolz));
- EXPECT_EQ(1, engine()->ToInt32(boolz));
- EXPECT_EQ(1.0, engine()->ToDouble(boolz));
- EXPECT_EQ(L"true", engine()->ToWideString(boolz));
- EXPECT_TRUE(engine()->ToObject(boolz).IsEmpty());
- EXPECT_TRUE(engine()->ToArray(boolz).IsEmpty());
-}
-
-TEST_F(FXJSV8EmbedderTest, NewNumber) {
- v8::Isolate::Scope isolate_scope(isolate());
- v8::HandleScope handle_scope(isolate());
- v8::Context::Scope context_scope(GetV8Context());
-
- auto num = engine()->NewNumber(42.1);
- EXPECT_TRUE(engine()->ToBoolean(num));
- EXPECT_EQ(42, engine()->ToInt32(num));
- EXPECT_EQ(42.1, engine()->ToDouble(num));
- EXPECT_EQ(L"42.1", engine()->ToWideString(num));
- EXPECT_TRUE(engine()->ToObject(num).IsEmpty());
- EXPECT_TRUE(engine()->ToArray(num).IsEmpty());
-}
-
-TEST_F(FXJSV8EmbedderTest, NewString) {
- v8::Isolate::Scope isolate_scope(isolate());
- v8::HandleScope handle_scope(isolate());
- v8::Context::Scope context_scope(GetV8Context());
-
- auto str = engine()->NewString(L"123");
- EXPECT_TRUE(engine()->ToBoolean(str));
- EXPECT_EQ(123, engine()->ToInt32(str));
- EXPECT_EQ(123, engine()->ToDouble(str));
- EXPECT_EQ(L"123", engine()->ToWideString(str));
- EXPECT_TRUE(engine()->ToObject(str).IsEmpty());
- EXPECT_TRUE(engine()->ToArray(str).IsEmpty());
-}
-
-TEST_F(FXJSV8EmbedderTest, NewDate) {
- v8::Isolate::Scope isolate_scope(isolate());
- v8::HandleScope handle_scope(isolate());
- v8::Context::Scope context_scope(GetV8Context());
-
- auto date = engine()->NewDate(1111111111);
- EXPECT_TRUE(engine()->ToBoolean(date));
- EXPECT_EQ(1111111111, engine()->ToInt32(date));
- EXPECT_EQ(1111111111.0, engine()->ToDouble(date));
- EXPECT_NE(L"", engine()->ToWideString(date)); // exact format varies.
- EXPECT_TRUE(engine()->ToObject(date)->IsObject());
- EXPECT_TRUE(engine()->ToArray(date).IsEmpty());
-}
-
-TEST_F(FXJSV8EmbedderTest, NewArray) {
- v8::Isolate::Scope isolate_scope(isolate());
- v8::HandleScope handle_scope(isolate());
- v8::Context::Scope context_scope(GetV8Context());
-
- auto array = engine()->NewArray();
- EXPECT_EQ(0u, engine()->GetArrayLength(array));
- EXPECT_FALSE(engine()->GetArrayElement(array, 2).IsEmpty());
- EXPECT_TRUE(engine()->GetArrayElement(array, 2)->IsUndefined());
- EXPECT_EQ(0u, engine()->GetArrayLength(array));
-
- engine()->PutArrayElement(array, 3, engine()->NewNumber(12));
- EXPECT_FALSE(engine()->GetArrayElement(array, 2).IsEmpty());
- EXPECT_TRUE(engine()->GetArrayElement(array, 2)->IsUndefined());
- EXPECT_FALSE(engine()->GetArrayElement(array, 3).IsEmpty());
- EXPECT_TRUE(engine()->GetArrayElement(array, 3)->IsNumber());
- EXPECT_EQ(4u, engine()->GetArrayLength(array));
-
- EXPECT_TRUE(engine()->ToBoolean(array));
- EXPECT_EQ(0, engine()->ToInt32(array));
- double d = engine()->ToDouble(array);
- EXPECT_NE(d, d); // i.e. NaN.
- EXPECT_EQ(L",,,12", engine()->ToWideString(array));
- EXPECT_TRUE(engine()->ToObject(array)->IsObject());
- EXPECT_TRUE(engine()->ToArray(array)->IsArray());
-}
-
-TEST_F(FXJSV8EmbedderTest, NewObject) {
- v8::Isolate::Scope isolate_scope(isolate());
- v8::HandleScope handle_scope(isolate());
- v8::Context::Scope context_scope(GetV8Context());
-
- auto object = engine()->NewObject();
- ASSERT_FALSE(object.IsEmpty());
- EXPECT_EQ(0u, engine()->GetObjectPropertyNames(object).size());
- EXPECT_FALSE(engine()->GetObjectProperty(object, L"clams").IsEmpty());
- EXPECT_TRUE(engine()->GetObjectProperty(object, L"clams")->IsUndefined());
- EXPECT_EQ(0u, engine()->GetObjectPropertyNames(object).size());
-
- engine()->PutObjectProperty(object, L"clams", engine()->NewNumber(12));
- EXPECT_FALSE(engine()->GetObjectProperty(object, L"clams").IsEmpty());
- EXPECT_TRUE(engine()->GetObjectProperty(object, L"clams")->IsNumber());
- EXPECT_EQ(1u, engine()->GetObjectPropertyNames(object).size());
- EXPECT_EQ(L"clams", engine()->GetObjectPropertyNames(object)[0]);
-
- EXPECT_TRUE(engine()->ToBoolean(object));
- EXPECT_EQ(0, engine()->ToInt32(object));
- double d = engine()->ToDouble(object);
- EXPECT_NE(d, d); // i.e. NaN.
- EXPECT_EQ(L"[object Object]", engine()->ToWideString(object));
- EXPECT_TRUE(engine()->ToObject(object)->IsObject());
- EXPECT_TRUE(engine()->ToArray(object).IsEmpty());
-}