diff options
author | Adam Domurad <[email protected]> | 2012-12-21 15:21:42 -0500 |
---|---|---|
committer | Adam Domurad <[email protected]> | 2012-12-21 15:21:42 -0500 |
commit | 0fc2ebc795558f3a3c712c3e530962057a818339 (patch) | |
tree | ba222ba6198c6e3366912fb54bdf119eae6d3a92 /tests | |
parent | 22118569a2d39ce315702a0a0346a420e6b7d1b3 (diff) |
Clean up NP_Initialize; add more C++ unit tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cpp-unit-tests/IcedTeaNPPluginTest.cc | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/tests/cpp-unit-tests/IcedTeaNPPluginTest.cc b/tests/cpp-unit-tests/IcedTeaNPPluginTest.cc new file mode 100644 index 0000000..1633d6b --- /dev/null +++ b/tests/cpp-unit-tests/IcedTeaNPPluginTest.cc @@ -0,0 +1,92 @@ +/* Copyright (C) 2012 Red Hat + + This file is part of IcedTea. + + IcedTea is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + IcedTea is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with IcedTea; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. + + Linking this library statically or dynamically with other modules is + making a combined work based on this library. Thus, the terms and + conditions of the GNU General Public License cover the whole + combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent + modules, and to copy and distribute the resulting executable under + terms of your choice, provided that you also meet, for each linked + independent module, the terms and conditions of the license of that + module. An independent module is a module which is not derived from + or based on this library. If you modify this library, you may extend + this exception to your version of the library, but you are not + obligated to do so. If you do not wish to do so, delete this + exception statement from your version. */ + +#include <cstdio> + +#include <npapi.h> + +#include <UnitTest++.h> + +#include "IcedTeaNPPlugin.h" +#include "IcedTeaPluginUtils.h" + +TEST(NP_GetMIMEDescription) { + std::string MIME_type = NP_GetMIMEDescription(); + CHECK(MIME_type.find("application/x-java-applet") != std::string::npos); + CHECK(MIME_type.find("application/x-java-vm") != std::string::npos); +} + +/* Not normally exposed */ +std::vector<std::string*>* get_jvm_args(); +extern gchar* in_pipe_name; +extern gchar* out_pipe_name; + +TEST(get_jvm_args) { + in_pipe_name = (gchar*)"inpipe"; + out_pipe_name = (gchar*)"outpipe"; + + std::vector<std::string*>* args = get_jvm_args(); + CHECK(args != NULL); + + IcedTeaPluginUtilities::freeStringPtrVector(args); +} + +TEST(NP_GetValue) { + void* __unused = NULL; + gchar* char_value = NULL; + + /* test plugin name */ { + CHECK_EQUAL(NPERR_NO_ERROR, + NP_GetValue(__unused, NPPVpluginNameString, &char_value)); + CHECK(std::string(char_value).find(PLUGIN_NAME) != std::string::npos); + g_free(char_value); + char_value = NULL; + } + /* test plugin desc */ { + CHECK_EQUAL(NPERR_NO_ERROR, + NP_GetValue(__unused, NPPVpluginDescriptionString, &char_value)); + CHECK(std::string(char_value).find("executes Java applets") != std::string::npos); + g_free(char_value); + char_value = NULL; + } + /* test plugin unknown */ { + printf("NOTE: Next error expected\n"); // the following will print an error message + CHECK_EQUAL(NPERR_GENERIC_ERROR, + NP_GetValue(__unused, NPPVformValue, &char_value)); + g_free(char_value); + char_value = NULL; + } +} |