summaryrefslogtreecommitdiffstats
path: root/chrome/test/plugin
diff options
context:
space:
mode:
authorinitial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-26 23:55:29 +0000
committerinitial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-26 23:55:29 +0000
commit09911bf300f1a419907a9412154760efd0b7abc3 (patch)
treef131325fb4e2ad12c6d3504ab75b16dd92facfed /chrome/test/plugin
parent586acc5fe142f498261f52c66862fa417c3d52d2 (diff)
downloadchromium_src-09911bf300f1a419907a9412154760efd0b7abc3.zip
chromium_src-09911bf300f1a419907a9412154760efd0b7abc3.tar.gz
chromium_src-09911bf300f1a419907a9412154760efd0b7abc3.tar.bz2
Add chrome to the repository.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/plugin')
-rw-r--r--chrome/test/plugin/SConscript130
-rw-r--r--chrome/test/plugin/plugin_test.cpp232
-rw-r--r--chrome/test/plugin/plugin_tests.vcproj190
3 files changed, 552 insertions, 0 deletions
diff --git a/chrome/test/plugin/SConscript b/chrome/test/plugin/SConscript
new file mode 100644
index 0000000..6ad1cdc
--- /dev/null
+++ b/chrome/test/plugin/SConscript
@@ -0,0 +1,130 @@
+# Copyright 2008, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Import('env_test')
+
+env_test = env_test.Clone()
+
+
+env_test.Prepend(
+ CPPDEFINES = [
+ 'UI_TEST',
+ 'UNIT_TEST',
+ 'LIBXSLT_STATIC',
+ 'LIBXML_STATIC',
+ 'CERT_CHAIN_PARA_HAS_EXTRA_FIELDS',
+ 'WIN32_LEAN_AND_MEAN',
+ ],
+ CPPPATH = [
+ '$GTEST_DIR/include',
+ '$GTEST_DIR',
+ '$SKIA_DIR/include',
+ '$SKIA_DIR/include/corecg',
+ '$SKIA_DIR/platform',
+ '#/..',
+ '$LIBXSLT_DIR',
+ '$LIBXML_DIR/includ',
+ ],
+ LINKFLAGS = [
+ '/INCREMENTAL',
+ '/DEBUG',
+
+ '/DELAYLOAD:"ws2_32.dll"',
+ '/DELAYLOAD:"dwmapi.dll"',
+ '/DELAYLOAD:"uxtheme.dll"',
+
+ '/MACHINE:X86',
+ '/FIXED:No',
+
+ '/safeseh',
+ '/dynamicbase',
+ '/ignore:4199',
+ '/nxcompat',
+ ],
+ LIBS = [
+ 'winmm.lib',
+ 'rpcrt4.lib',
+ 'oleacc.lib',
+ 'comsupp.lib',
+
+ 'wininet.lib',
+ 'version.lib',
+ 'msimg32.lib',
+ 'ws2_32.lib',
+ 'usp10.lib',
+ 'psapi.lib',
+ 'kernel32.lib',
+ 'user32.lib',
+ 'gdi32.lib',
+ 'winspool.lib',
+ 'comdlg32.lib',
+ 'advapi32.lib',
+ 'shell32.lib',
+ 'ole32.lib',
+ 'oleaut32.lib',
+ 'uuid.lib',
+ 'odbc32.lib',
+ 'odbccp32.lib',
+
+ 'DelayImp.lib',
+ ],
+)
+
+input_files = [
+ '$CHROME_DIR/test/ui/run_all_unittests$OBJSUFFIX',
+ '$CHROME_DIR/test/ui/ui_test$OBJSUFFIX',
+ '$CHROME_DIR/test/ui/ui_test_suite$OBJSUFFIX',
+ '$CHROME_DIR/test/test_file_util$OBJSUFFIX',
+ 'plugin_test.cpp',
+]
+
+libs = [
+ '$GOOGLEURL_DIR/googleurl.lib',
+ '$CHROME_DIR/test/security_tests/security_tests.lib',
+ '$SKIA_DIR/skia.lib',
+ '$LIBPNG_DIR/libpng.lib',
+ '$TESTING_DIR/gtest.lib',
+ '$BASE_DIR/gfx/base_gfx.lib',
+ '$ICU38_DIR/icuuc.lib',
+ '$CHROME_DIR/common/common.lib',
+ '$ZLIB_DIR/zlib.lib',
+ '$MODP_B64_DIR/modp_b64.lib',
+ '$CHROME_DIR/browser/browser.lib',
+ '$NET_DIR/net.lib',
+ '$BASE_DIR/base.lib',
+ '$CHROME_DIR/test/automation/automation.lib',
+]
+
+
+exe = env_test.Program(['plugin_tests',
+ 'plugin_tests.pdb'],
+ input_files + libs)
+i = env_test.Install('$TARGET_ROOT', exe)
+
+env_test.Alias('chrome', i)
diff --git a/chrome/test/plugin/plugin_test.cpp b/chrome/test/plugin/plugin_test.cpp
new file mode 100644
index 0000000..c9f16c1
--- /dev/null
+++ b/chrome/test/plugin/plugin_test.cpp
@@ -0,0 +1,232 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Tests for the top plugins to catch regressions in our plugin host code, as
+// well as in the out of process code. Currently this tests:
+// Flash
+// Real
+// QuickTime
+// Windows Media Player
+// -this includes both WMP plugins. npdsplay.dll is the older one that
+// comes with XP. np-mswmp.dll can be downloaded from Microsoft and
+// needs SP2 or Vista.
+
+#include <windows.h>
+#include <shellapi.h>
+#include <shlobj.h>
+#include <atlbase.h>
+#include <comutil.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <memory.h>
+
+#include "base/file_util.h"
+#include "base/registry.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/test/automation/tab_proxy.h"
+#include "chrome/test/ui/ui_test.h"
+#include "net/base/net_util.h"
+#include "webkit/glue/plugins/plugin_list.h"
+
+const char kTestCompleteCookie[] = "status";
+const char kTestCompleteSuccess[] = "OK";
+const int kShortWaitTimeout = 10 * 1000;
+const int kLongWaitTimeout = 30 * 1000;
+
+class PluginTest : public UITest {
+ protected:
+ virtual void SetUp() {
+ const testing::TestInfo* const test_info =
+ testing::UnitTest::GetInstance()->current_test_info();
+ if (strcmp(test_info->name(), "MediaPlayerNew") == 0) {
+ // The installer adds our process names to the registry key below. Since
+ // the installer might not have run on this machine, add it manually.
+ RegKey regkey;
+ if (regkey.Open(HKEY_LOCAL_MACHINE,
+ L"Software\\Microsoft\\MediaPlayer\\ShimInclusionList",
+ KEY_WRITE)) {
+ regkey.CreateKey(L"CHROME.EXE", KEY_READ);
+ }
+ if (!launch_arguments_.empty())
+ launch_arguments_.append(L" ");
+ launch_arguments_.append(L"--" kNoNativeActiveXShimSwitch);
+
+ } else if (strcmp(test_info->name(), "MediaPlayerOld") == 0) {
+ // When testing the old WMP plugin, we need to force Chrome to not load
+ // the new plugin.
+ if (!launch_arguments_.empty())
+ launch_arguments_.append(L" ");
+
+ launch_arguments_.append(L"--" kUseOldWMPPluginSwitch);
+ launch_arguments_.append(L" ");
+ launch_arguments_.append(L"--" kNoNativeActiveXShimSwitch);
+ } else if (strcmp(test_info->name(), "FlashSecurity") == 0) {
+ if (!launch_arguments_.empty())
+ launch_arguments_.append(L" ");
+
+ launch_arguments_.append(L"--");
+ launch_arguments_.append(switches::kTestSandbox);
+ launch_arguments_.append(L"=");
+ launch_arguments_.append(L"security_tests.dll");
+ }
+
+ UITest::SetUp();
+ }
+
+ void TestPlugin(const std::wstring& test_case, int timeout) {
+ GURL url = GetTestUrl(test_case);
+ NavigateToURL(url);
+ WaitForFinish(timeout);
+ }
+
+ // Generate the URL for testing a particular test.
+ // HTML for the tests is all located in test_directory\plugin\<testcase>
+ GURL GetTestUrl(const std::wstring &test_case) {
+ std::wstring path;
+ PathService::Get(chrome::DIR_TEST_DATA, &path);
+ file_util::AppendToPath(&path, L"plugin");
+ file_util::AppendToPath(&path, test_case);
+ return net_util::FilePathToFileURL(path);
+ }
+
+ // Waits for the test case to finish.
+ void WaitForFinish(const int wait_time) {
+ const int kSleepTime = 500; // 2 times per second
+ const int kMaxIntervals = wait_time / kSleepTime;
+
+ GURL url = GetTestUrl(L"done");
+ scoped_ptr<TabProxy> tab(GetActiveTab());
+
+ std::string done_str;
+ for (int i = 0; i < kMaxIntervals; ++i) {
+ Sleep(kSleepTime);
+
+ // The webpage being tested has javascript which sets a cookie
+ // which signals completion of the test.
+ std::string cookieName = kTestCompleteCookie;
+ tab->GetCookieByName(url, cookieName, &done_str);
+ if (!done_str.empty())
+ break;
+ }
+
+ EXPECT_EQ(kTestCompleteSuccess, done_str);
+ }
+};
+
+TEST_F(PluginTest, Quicktime) {
+ TestPlugin(L"quicktime.html", kShortWaitTimeout);
+}
+
+TEST_F(PluginTest, MediaPlayerNew) {
+ TestPlugin(L"wmp_new.html", kShortWaitTimeout);
+}
+
+TEST_F(PluginTest, MediaPlayerOld) {
+ TestPlugin(L"wmp_old.html", kLongWaitTimeout);
+}
+
+TEST_F(PluginTest, Real) {
+ TestPlugin(L"real.html", kShortWaitTimeout);
+}
+
+TEST_F(PluginTest, Flash) {
+ TestPlugin(L"flash.html", kShortWaitTimeout);
+}
+
+TEST_F(PluginTest, FlashOctetStream) {
+ TestPlugin(L"flash-octet-stream.html", kShortWaitTimeout);
+}
+
+TEST_F(PluginTest, FlashSecurity) {
+ TestPlugin(L"flash.html", kShortWaitTimeout);
+}
+
+TEST_F(PluginTest, Java) {
+ TestPlugin(L"Java.html", kShortWaitTimeout);
+}
+
+TEST_F(PluginTest, Silverlight) {
+ TestPlugin(L"silverlight.html", kShortWaitTimeout);
+}
+
+typedef HRESULT (__stdcall* DllRegUnregServerFunc)();
+
+class ActiveXTest : public PluginTest {
+ public:
+ ActiveXTest() {
+ dll_registered = false;
+ }
+ protected:
+ void TestActiveX(const std::wstring& test_case, int timeout, bool reg_dll) {
+ if (reg_dll) {
+ RegisterTestControl(true);
+ dll_registered = true;
+ }
+ TestPlugin(test_case, timeout);
+ }
+ virtual void TearDown() {
+ PluginTest::TearDown();
+ if (dll_registered)
+ RegisterTestControl(false);
+ }
+ void RegisterTestControl(bool register_server) {
+ std::wstring test_control_path = browser_directory_ +
+ L"\\activex_test_control.dll";
+ HMODULE h = LoadLibrary(test_control_path.c_str());
+ ASSERT_TRUE(h != NULL) << "Failed to load activex_test_control.dll";
+ const char* func_name = register_server ?
+ "DllRegisterServer" : "DllUnregisterServer";
+ DllRegUnregServerFunc func = reinterpret_cast<DllRegUnregServerFunc>(
+ GetProcAddress(h, func_name));
+ // This should never happen actually.
+ ASSERT_TRUE(func != NULL) << "Failed to find reg/unreg function.";
+ HRESULT hr = func();
+ const char* error_message = register_server ? "Failed to register dll."
+ : "Failed to unregister dll";
+ ASSERT_TRUE(SUCCEEDED(hr)) << error_message;
+ FreeLibrary(h);
+ }
+ private:
+ bool dll_registered;
+};
+
+TEST_F(ActiveXTest, EmbeddedWMP) {
+ TestActiveX(L"activex_embedded_wmp.html", kLongWaitTimeout, false);
+}
+
+TEST_F(ActiveXTest, WMP) {
+ TestActiveX(L"activex_wmp.html", kLongWaitTimeout, false);
+}
+
+TEST_F(ActiveXTest, CustomScripting) {
+ TestActiveX(L"activex_custom_scripting.html", kShortWaitTimeout, true);
+}
+
diff --git a/chrome/test/plugin/plugin_tests.vcproj b/chrome/test/plugin/plugin_tests.vcproj
new file mode 100644
index 0000000..f8fca50
--- /dev/null
+++ b/chrome/test/plugin/plugin_tests.vcproj
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="plugin_tests"
+ ProjectGUID="{A1CAA831-C507-4B2E-87F3-AEC63C9907F9}"
+ RootNamespace="plugin_tests"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;..\..\tools\build\win\precompiled_wtl.vsprops;$(SolutionDir)..\third_party\libxml\build\using_libxml.vsprops;$(SolutionDir)..\third_party\libxslt\build\using_libxslt.vsprops;..\..\tools\build\win\unit_test.vsprops;..\..\tools\build\win\ui_test.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops;$(SolutionDir)..\third_party\libxml\build\using_libxml.vsprops;$(SolutionDir)..\third_party\libxslt\build\using_libxslt.vsprops;..\..\tools\build\win\unit_test.vsprops;..\..\tools\build\win\ui_test.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\plugin_test.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\tools\build\win\precompiled_wtl.cc"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\tools\build\win\precompiled_wtl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\ui\run_all_unittests.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\test_file_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\testing_browser_process.h"
+ >
+ </File>
+ <File
+ RelativePath="..\ui\ui_test.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\ui\ui_test.h"
+ >
+ </File>
+ <File
+ RelativePath="..\ui\ui_test_suite.cc"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>