summaryrefslogtreecommitdiffstats
path: root/chrome/test/selenium
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/selenium
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/selenium')
-rw-r--r--chrome/test/selenium/README2
-rw-r--r--chrome/test/selenium/SConscript122
-rw-r--r--chrome/test/selenium/expected_failures.txt1
-rw-r--r--chrome/test/selenium/selenium_test.cc196
-rw-r--r--chrome/test/selenium/selenium_tests.vcproj198
5 files changed, 519 insertions, 0 deletions
diff --git a/chrome/test/selenium/README b/chrome/test/selenium/README
new file mode 100644
index 0000000..a9e60f6
--- /dev/null
+++ b/chrome/test/selenium/README
@@ -0,0 +1,2 @@
+This directory contains code to automate the selenium core test suite found
+under chrome/test/third_party/selenium_core/.
diff --git a/chrome/test/selenium/SConscript b/chrome/test/selenium/SConscript
new file mode 100644
index 0000000..eaa1b6e
--- /dev/null
+++ b/chrome/test/selenium/SConscript
@@ -0,0 +1,122 @@
+# 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',
+ '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',
+ '#/..',
+ ],
+ LINKFLAGS = [
+ '/INCREMENTAL',
+ '/DEBUG',
+
+ '/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',
+ 'selenium_test.cc',
+]
+
+libs = [
+ '$GOOGLEURL_DIR/googleurl.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(['selenium_tests',
+ 'selenium_tests.pdb'],
+ input_files + libs)
+i = env_test.Install('$TARGET_ROOT', exe)
+
+env_test.Alias('chrome', i)
diff --git a/chrome/test/selenium/expected_failures.txt b/chrome/test/selenium/expected_failures.txt
new file mode 100644
index 0000000..455ac71
--- /dev/null
+++ b/chrome/test/selenium/expected_failures.txt
@@ -0,0 +1 @@
+46.type
diff --git a/chrome/test/selenium/selenium_test.cc b/chrome/test/selenium/selenium_test.cc
new file mode 100644
index 0000000..043def8
--- /dev/null
+++ b/chrome/test/selenium/selenium_test.cc
@@ -0,0 +1,196 @@
+// 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.
+
+// This is a gTest-based test that runs the Selenium Core testsuite in Chrome
+// using the UITest automation. The number of total and failed tests are
+// written to stdout.
+//
+// TODO(darin): output the names of the failed tests so we can easily track
+// deviations from the expected output.
+
+#include <list>
+#include <set>
+
+#include "base/file_util.h"
+#include "base/path_service.h"
+#include "base/string_util.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/rand_util.h"
+#include "chrome/test/automation/tab_proxy.h"
+#include "chrome/test/automation/window_proxy.h"
+#include "chrome/test/ui/ui_test.h"
+#include "net/base/net_util.h"
+
+// Uncomment this to exercise this test without actually running the selenium
+// test, which can take a while to run. This define is useful when modifying
+// the analysis code.
+//#define SIMULATE_RUN 1
+
+namespace {
+
+// This file is a comma separated list of tests that are currently failing.
+const wchar_t kExpectedFailuresFileName[] = L"expected_failures.txt";
+
+class SeleniumTest : public UITest {
+ public:
+ SeleniumTest() {
+ show_window_ = true;
+ }
+ typedef std::list<std::string> ResultsList;
+ typedef std::set<std::string> ResultsSet;
+
+ // Parses a selenium results string, which is of the form:
+ // "5.selectFrame,6.click,24.selectAndWait,24.verifyTitle"
+ void ParseResults(const std::string& input, ResultsSet* output) {
+ if (input.empty())
+ return;
+
+ std::vector<std::string> tokens;
+ SplitString(input, ',', &tokens);
+ for (size_t i = 0; i < tokens.size(); ++i) {
+ TrimWhitespace(tokens[i], TRIM_ALL, &tokens[i]);
+ output->insert(tokens[i]);
+ }
+ }
+
+ // Find the elements of "b" that are not in "a"
+ void CompareSets(const ResultsSet& a, const ResultsSet& b,
+ ResultsList* only_in_b) {
+ ResultsSet::const_iterator it = b.begin();
+ for (; it != b.end(); ++it) {
+ if (a.find(*it) == a.end())
+ only_in_b->push_back(*it);
+ }
+ }
+
+ // The results file is in trunk/chrome/test/selenium/
+ std::wstring GetResultsFilePath() {
+ std::wstring results_path;
+ PathService::Get(chrome::DIR_TEST_DATA, &results_path);
+ file_util::UpOneDirectory(&results_path);
+ file_util::AppendToPath(&results_path, L"selenium");
+
+ file_util::AppendToPath(&results_path, kExpectedFailuresFileName);
+ return results_path;
+ }
+
+ bool ReadExpectedResults(std::string* results) {
+ std::wstring results_path = GetResultsFilePath();
+ return file_util::ReadFileToString(results_path, results);
+ }
+
+ void RunSelenium(std::wstring* total, std::wstring* failed) {
+#ifdef SIMULATE_RUN
+ *total = L"100";
+ const wchar_t* kBogusFailures[] = {
+ L"5.selectFrame,6.click,24.selectAndWait,24.verifyTitle",
+ L"5.selectFrame,6.click,13.verifyLocation,13.verifyLocation,13.click,24.selectAndWait,24.verifyTitle",
+ L"5.selectFrame,6.click,24.selectAndWait"
+ };
+ *failed = kBogusFailures[rand_util::RandInt(0, 2)];
+#else
+ std::wstring test_path;
+ PathService::Get(chrome::DIR_TEST_DATA, &test_path);
+ file_util::UpOneDirectory(&test_path);
+ file_util::UpOneDirectory(&test_path);
+ file_util::UpOneDirectory(&test_path);
+ file_util::AppendToPath(&test_path, L"data");
+ file_util::AppendToPath(&test_path, L"selenium_core");
+ file_util::AppendToPath(&test_path, L"core");
+ file_util::AppendToPath(&test_path, L"TestRunner.html");
+
+ GURL test_url(net_util::FilePathToFileURL(test_path));
+ scoped_ptr<TabProxy> tab(GetActiveTab());
+ tab->NavigateToURL(test_url);
+
+ // Wait for the test to finish.
+ ASSERT_TRUE(WaitUntilCookieValue(tab.get(), test_url, "__tests_finished",
+ 3000, UITest::test_timeout_ms(), "1"));
+
+ std::string cookie;
+ ASSERT_TRUE(tab->GetCookieByName(test_url, "__num_tests_total", &cookie));
+ total->swap(UTF8ToWide(cookie));
+ ASSERT_FALSE(total->empty());
+ ASSERT_TRUE(tab->GetCookieByName(test_url, "__tests_failed", &cookie));
+ failed->swap(UTF8ToWide(cookie));
+ // The __tests_failed cookie will be empty if all the tests pass.
+#endif
+ }
+
+ void RunTest(ResultsList* new_passes_list, ResultsList* new_failures_list) {
+ std::string expected_failures;
+ bool have_expected_results = ReadExpectedResults(&expected_failures);
+ ASSERT_TRUE(have_expected_results);
+
+ std::wstring total, failed;
+ RunSelenium(&total, &failed);
+ if (total.empty())
+ return;
+
+ printf("\n");
+ wprintf(L"__num_tests_total = [%s]\n", total.c_str());
+ wprintf(L"__tests_failed = [%s]\n", failed.c_str());
+
+ std::string cur_failures = WideToUTF8(failed);
+
+ ResultsSet expected_failures_set;
+ ParseResults(expected_failures, &expected_failures_set);
+
+ ResultsSet cur_failures_set;
+ ParseResults(cur_failures, &cur_failures_set);
+
+ // Compute the list of new passes and failures
+ CompareSets(cur_failures_set, expected_failures_set, new_passes_list);
+ CompareSets(expected_failures_set, cur_failures_set, new_failures_list);
+ }
+};
+
+} // namespace
+
+TEST_F(SeleniumTest, Core) {
+ ResultsList new_passes_list, new_failures_list;
+ RunTest(&new_passes_list, &new_failures_list);
+
+ if (!new_failures_list.empty()) {
+ ADD_FAILURE();
+ printf("new tests failing:\n");
+ ResultsList::const_iterator it = new_failures_list.begin();
+ for (; it != new_failures_list.end(); ++it)
+ printf(" %s\n", it->c_str());
+ printf("\n");
+ }
+
+ if (!new_passes_list.empty()) {
+ printf("new tests passing:\n");
+ ResultsList::const_iterator it = new_passes_list.begin();
+ for (; it != new_passes_list.end(); ++it)
+ printf(" %s\n", it->c_str());
+ printf("\n");
+ }
+}
diff --git a/chrome/test/selenium/selenium_tests.vcproj b/chrome/test/selenium/selenium_tests.vcproj
new file mode 100644
index 0000000..572819c
--- /dev/null
+++ b/chrome/test/selenium/selenium_tests.vcproj
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="selenium_tests"
+ ProjectGUID="{E3749617-BA3D-4230-B54C-B758E56D9FA5}"
+ RootNamespace="selenium_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;..\..\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;..\..\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>
+ <Filter
+ Name="Common"
+ >
+ <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>
+ </Filter>
+ <Filter
+ Name="TestSelenium"
+ >
+ <File
+ RelativePath=".\selenium_test.cc"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>