diff options
author | Adam Domurad <[email protected]> | 2013-08-23 16:35:37 -0400 |
---|---|---|
committer | Adam Domurad <[email protected]> | 2013-08-23 16:35:37 -0400 |
commit | 6fbf033b59cff6cedf9d31411835ab01938e048e (patch) | |
tree | abf76980459caddf4846c329b9ef61624d9978c0 /tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc | |
parent | 72ec74cba16e960095cb1fc9c1f37bfbfca64fe8 (diff) |
Spawn Java side during C++ unit tests. Many new tests.
Diffstat (limited to 'tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc')
-rw-r--r-- | tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc b/tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc index 9de0bbd..bb2b376 100644 --- a/tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc +++ b/tests/cpp-unit-tests/IcedTeaScriptablePluginObjectTest.cc @@ -95,4 +95,37 @@ SUITE(IcedTeaScriptableJavaPackageObject) { browser_functions.releaseobject(obj); CHECK(leak_detector.memory_leaks() == 0); } + + static NPVariant np_checked_get(NPObject* obj, const char* identifier) { + NPVariant result; + CHECK(browser_functions.getproperty(&dummy_npp, obj, browser_functions.getstringidentifier(identifier), &result)); + return result; + } + + /* NOTICE: Requires icedtea-web Java-side to be running! + * Loads java.lang.Integer.MAX_VALUE */ + TEST(getProperty) { + MemoryLeakDetector leak_detector; + /* Ensure destruction */{ + /* Get the 'root' package */ + NPObject* obj = IcedTeaScriptableJavaPackageObject::get_scriptable_java_package_object(&dummy_npp, ""); + // Look up java.lang.Integer.MAX_VALUE + NPVariant java_result = np_checked_get(obj, "java"); + NPVariant lang_result = np_checked_get(NPVARIANT_TO_OBJECT(java_result), "lang"); + NPVariant integer_result = np_checked_get(NPVARIANT_TO_OBJECT(lang_result), "Integer"); + NPVariant max_value_result = np_checked_get(NPVARIANT_TO_OBJECT(integer_result), "MAX_VALUE"); + + // Check that it is indeed equal to 2147483647 + CHECK(NPVARIANT_IS_INT32(max_value_result)); + CHECK_EQUAL(2147483647, NPVARIANT_TO_INT32(max_value_result)); + + browser_functions.releasevariantvalue(&java_result); + browser_functions.releasevariantvalue(&lang_result); + browser_functions.releasevariantvalue(&integer_result); + browser_functions.releasevariantvalue(&max_value_result); + + browser_functions.releaseobject(obj); + } + CHECK(leak_detector.memory_leaks() == 0); + } } |