| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/basictypes.h" | |
| 6 #include "base/string_util.h" | |
| 7 #include "base/stringprintf.h" | |
| 8 | |
| 9 #include "webkit/glue/plugins/test/plugin_arguments_test.h" | |
| 10 | |
| 11 namespace NPAPIClient { | |
| 12 | |
| 13 PluginArgumentsTest::PluginArgumentsTest(NPP id, | |
| 14 NPNetscapeFuncs *host_functions) | |
| 15 : PluginTest(id, host_functions) { | |
| 16 } | |
| 17 | |
| 18 NPError PluginArgumentsTest::New(uint16 mode, int16 argc, | |
| 19 const char* argn[], const char* argv[], | |
| 20 NPSavedData* saved) { | |
| 21 // mode: should be the string either "NP_EMBED" or "NP_FULL", | |
| 22 // depending on the mode passed in. | |
| 23 // count: the count of "val" arguments. If the value is | |
| 24 // 2, then we'll find arguments "val1" and "val2". If | |
| 25 // the value is 0, then there will be no "val" arguments. | |
| 26 // size: each val string will be this size * the value's | |
| 27 // index. E.g if size is "10", val1 will be 10bytes, | |
| 28 // and val2 will be 20bytes. | |
| 29 const char *mode_string = GetArgValue("mode", argc, argn, argv); | |
| 30 ExpectAsciiStringNotEqual(mode_string, (const char *)NULL); | |
| 31 if (mode_string != NULL) { | |
| 32 std::string mode_dep_string = mode_string; | |
| 33 if (mode == NP_EMBED) | |
| 34 ExpectStringLowerCaseEqual(mode_dep_string, "np_embed"); | |
| 35 else if (mode == NP_FULL) | |
| 36 ExpectStringLowerCaseEqual(mode_dep_string, "np_full"); | |
| 37 } | |
| 38 | |
| 39 const char *count_string = GetArgValue("count", argc, argn, argv); | |
| 40 if (count_string != NULL) { | |
| 41 int max_args = atoi(count_string); | |
| 42 | |
| 43 const char *size_string = GetArgValue("size", argc, argn, argv); | |
| 44 ExpectAsciiStringNotEqual(size_string, (const char *)NULL); | |
| 45 if (size_string != NULL) { | |
| 46 int size = atoi(size_string); | |
| 47 | |
| 48 for (int index = 1; index <= max_args; index++) { | |
| 49 std::string arg_name = base::StringPrintf("%s%d", "val", index); | |
| 50 const char *val_string = GetArgValue(arg_name.c_str(), argc, argn, | |
| 51 argv); | |
| 52 ExpectAsciiStringNotEqual(val_string, (const char*)NULL); | |
| 53 if (val_string != NULL) | |
| 54 ExpectIntegerEqual((int)strlen(val_string), (index*size)); | |
| 55 } | |
| 56 } | |
| 57 } | |
| 58 | |
| 59 return PluginTest::New(mode, argc, argn, argv, saved); | |
| 60 } | |
| 61 | |
| 62 NPError PluginArgumentsTest::SetWindow(NPWindow* pNPWindow) { | |
| 63 // This test just tests the arguments. We're done now. | |
| 64 this->SignalTestCompleted(); | |
| 65 | |
| 66 return NPERR_NO_ERROR; | |
| 67 } | |
| 68 | |
| 69 } // namespace NPAPIClient | |
| OLD | NEW |