15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_test_factory.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_arguments_test.h"
8ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_delete_plugin_in_stream_test.h"
9ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_delete_plugin_in_deallocate_test.h"
10ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_get_javascript_url_test.h"
11ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_get_javascript_url2_test.h"
12ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_geturl_test.h"
13ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_javascript_open_popup.h"
14ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_new_fails_test.h"
15ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_npobject_identity_test.h"
16ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_npobject_lifetime_test.h"
17ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_npobject_proxy_test.h"
18ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_private_test.h"
19ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_request_read_test.h"
20ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_schedule_timer_test.h"
21ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_setup_test.h"
22ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_thread_async_call_test.h"
23ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_window_size_test.h"
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
25ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_windowed_test.h"
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
27ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch#include "content/test/plugin/plugin_windowless_test.h"
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace NPAPIClient {
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PluginTest* CreatePluginTest(const std::string& test_name,
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             NPP instance,
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                             NPNetscapeFuncs* host_functions) {
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PluginTest* new_test = NULL;
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (test_name == "arguments") {
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new PluginArgumentsTest(instance, host_functions);
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "geturl" || test_name == "geturl_404_response" ||
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "geturl_fail_write" ||
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "plugin_referrer_test" ||
41f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)             test_name == "geturlredirectnotify" ||
42f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)             test_name == "cookies") {
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new PluginGetURLTest(instance, host_functions);
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "npobject_identity") {
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new NPObjectIdentityTest(instance, host_functions);
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "npobject_proxy") {
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new NPObjectProxyTest(instance, host_functions);
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "invoke_js_function_on_create" ||
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "resize_during_paint"
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) || defined(OS_MACOSX)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          // TODO(port): plugin_windowless_test.*.
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          || test_name == "execute_script_delete_in_paint" ||
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "execute_script_delete_in_mouse_up" ||
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "delete_frame_test" ||
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "multiple_instances_sync_calls" ||
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "no_hang_if_init_crashes" ||
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "convert_point"
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             ) {
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new WindowlessPluginTest(instance, host_functions);
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "getjavascripturl") {
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new ExecuteGetJavascriptUrlTest(instance, host_functions);
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "getjavascripturl2") {
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new ExecuteGetJavascriptUrl2Test(instance, host_functions);
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(port): plugin_window_size_test.*.
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "checkwindowrect") {
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new PluginWindowSizeTest(instance, host_functions);
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "self_delete_plugin_stream") {
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new DeletePluginInStreamTest(instance, host_functions);
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(port): plugin_npobject_lifetime_test.*.
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "npobject_lifetime_test") {
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new NPObjectLifetimeTest(instance, host_functions);
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "npobject_lifetime_test_second_instance") {
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new NPObjectLifetimeTestInstance2(instance, host_functions);
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "new_fails") {
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new NewFailsTest(instance, host_functions);
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "npobject_delete_plugin_in_evaluate" ||
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "npobject_delete_create_plugin_in_evaluate") {
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new NPObjectDeletePluginInNPN_Evaluate(instance, host_functions);
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "plugin_javascript_open_popup_with_plugin") {
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new ExecuteJavascriptOpenPopupWithPluginTest(
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        instance, host_functions);
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "plugin_popup_with_plugin_target") {
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new ExecuteJavascriptPopupWindowTargetPluginTest(
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        instance, host_functions);
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "plugin_thread_async_call") {
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new PluginThreadAsyncCallTest(instance, host_functions);
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "private") {
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new PrivateTest(instance, host_functions);
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "schedule_timer") {
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new ScheduleTimerTest(instance, host_functions);
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN)
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(port): plugin_windowed_test.*.
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "hidden_plugin" ||
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "create_instance_in_paint" ||
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             test_name == "alert_in_window_message" ||
101f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)             test_name == "ensure_scripting_works_in_destroy" ||
1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)             test_name == "set_title_in_paint" ||
1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)             test_name == "set_title_in_set_window_and_paint") {
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new WindowedPluginTest(instance, host_functions);
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "setup") {
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // "plugin" is the name for plugin documents.
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new PluginSetupTest(instance, host_functions);
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  } else if (test_name == "delete_plugin_in_deallocate_test") {
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    new_test = new DeletePluginInDeallocateTest(instance, host_functions);
1117dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  } else if (test_name == "plugin_request_read_single_range") {
1127dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    new_test = new PluginRequestReadTest(instance, host_functions);
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return new_test;
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace NPAPIClient
119