summaryrefslogtreecommitdiffstats
path: root/o3d/tests
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-17 19:40:06 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-17 19:40:06 +0000
commit3693429d2017029bdc68bb84b14e2ce3bddf6f92 (patch)
tree93cf6a1df39db415db21ae28312b425e4d164c10 /o3d/tests
parent8ab0d904596b19d8d306a740128c5834cb3e3996 (diff)
downloadchromium_src-3693429d2017029bdc68bb84b14e2ce3bddf6f92.zip
chromium_src-3693429d2017029bdc68bb84b14e2ce3bddf6f92.tar.gz
chromium_src-3693429d2017029bdc68bb84b14e2ce3bddf6f92.tar.bz2
Change selenium to run the samples from the artifacts
directory. Note: There is the issue that the scons build does not have the correct dependencies to make sure the samples get copied to the artifacts before selenium runs. If that's a 1 line fix then let's add it. Otherwise we can fix that in the gyp build? Review URL: http://codereview.chromium.org/172008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23565 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/tests')
-rw-r--r--o3d/tests/build.scons3
-rw-r--r--o3d/tests/selenium/javascript_unit_tests.py20
-rw-r--r--o3d/tests/selenium/main.py18
-rw-r--r--o3d/tests/selenium/samples_tests.py34
-rw-r--r--o3d/tests/selenium/selenium_utilities.py12
5 files changed, 52 insertions, 35 deletions
diff --git a/o3d/tests/build.scons b/o3d/tests/build.scons
index de2bb15..0b20588c 100644
--- a/o3d/tests/build.scons
+++ b/o3d/tests/build.scons
@@ -535,11 +535,14 @@ run_env.Replace(
SELENIUM_CAPTURE_SCREENSHOTS = ARGUMENTS.get(
'SELENIUM_CAPTURE_SCREENSHOTS',
''),
+ SELENIUM_SAMPLES_DIR = run_env.subst('$ARTIFACTS_DIR')[
+ len(run_env.subst('$SCONSTRUCT_DIR')):],
SELENIUM_FLAGS = ('--verbose=$SELENIUM_VERBOSE '
'--selenium_server="$SELENIUM_SERVER_JAR" '
'--testprefix=$SELENIUM_TEST_PREFIX '
'--testsuffixes=$SELENIUM_TEST_SUFFIXES '
'--screencompare=$PDIFF_PATH '
+ '--samplespath=$SELENIUM_SAMPLES_DIR '
'$SELENIUM_CAPTURE_SCREENSHOTS '
'$SELENIUM_EXTRA_FLAGS'),
)
diff --git a/o3d/tests/selenium/javascript_unit_tests.py b/o3d/tests/selenium/javascript_unit_tests.py
index 6d686ee..5b59f19 100644
--- a/o3d/tests/selenium/javascript_unit_tests.py
+++ b/o3d/tests/selenium/javascript_unit_tests.py
@@ -49,10 +49,11 @@ import selenium_utilities
class JavaScriptUnitTests(selenium_utilities.SeleniumTestCase):
"""Runs the JavaScript unit tests for the sample utilities."""
- def __init__(self, name, session, browser, test_type=None, sample_path=None,
- options=None):
+ def __init__(self, name, session, browser, path_to_html, test_type=None,
+ sample_path=None, options=None):
selenium_utilities.SeleniumTestCase.__init__(
- self, name, session, browser, test_type, sample_path, options)
+ self, name, session, browser, path_to_html, test_type, sample_path,
+ options)
def GenericTest(self):
"""Generically test a sample.
@@ -61,8 +62,7 @@ class JavaScriptUnitTests(selenium_utilities.SeleniumTestCase):
That starts undefined and is set to true or false when the test is finished.
"""
self.RunGenericTest(
- self.session.browserURL +
- "/tests/selenium/tests/",
+ "/tests/selenium/tests/",
"typeof(window.g_testResult) != 'undefined'",
"window.g_testResult")
@@ -71,8 +71,7 @@ class JavaScriptUnitTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL +
- "/tests/selenium/tests/drawshapes.html")
+ s.open(self.GetURL("/tests/selenium/tests/drawshapes.html"))
# Allow a limited time for the plugin to initialize.
s.wait_for_condition("typeof(window.g_client) != 'undefined';", 20000)
@@ -216,8 +215,8 @@ class JavaScriptUnitTests(selenium_utilities.SeleniumTestCase):
old = s.get_all_window_titles()
for i in range(1, 5):
- s.open_window(s.browserURL +
- "/samples/simpletexture.html",
+ s.open_window(
+ self.GetURL("/samples/simpletexture.html"),
"o3dstress_window%d" % i)
for i in range(1, 5):
@@ -241,8 +240,7 @@ class JavaScriptUnitTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL +
- "/tests/selenium/tests/culling-zsort-test.html")
+ s.open(self.GetURL("/tests/selenium/tests/culling-zsort-test.html"))
# Allow a limited time for the plugin to initialize.
s.wait_for_condition("typeof(window.g_client) != 'undefined';", 20000)
diff --git a/o3d/tests/selenium/main.py b/o3d/tests/selenium/main.py
index b0a7bc0..278ad67 100644
--- a/o3d/tests/selenium/main.py
+++ b/o3d/tests/selenium/main.py
@@ -115,6 +115,11 @@ gflags.DEFINE_string(
"",
"specifies the path to the browser executable "
"(for platforms that don't support MOZ_PLUGIN_PATH)")
+gflags.DEFINE_string(
+ "samplespath",
+ "/",
+ "specifies the path from the web root to the samples."
+ "eg. 'scons-out/test-dbg-d3d/artifacts'")
TESTING_ROOT = os.path.abspath(os.path.dirname(__file__) + "/..")
@@ -486,7 +491,7 @@ def MatchesSuffix(name, suffixes):
def AddTests(test_suite, session, browser, module, filename, prefix,
- test_prefix_filter, test_suffixes):
+ test_prefix_filter, test_suffixes, path_to_html):
"""Add tests defined in filename.
Assumes module has a method "GenericTest" that uses self.args to run.
@@ -500,6 +505,7 @@ def AddTests(test_suite, session, browser, module, filename, prefix,
prefix: prefix to add to the beginning of each test.
test_prefix_filter: Only adds a test if it starts with this.
test_suffixes: list of suffixes to filter by. An empty list = pass all.
+ path_to_html: Path from server root to html
"""
# See comments in that file for the expected format.
# skip lines that are blank or have "#" or ";" as their first non whitespace
@@ -539,12 +545,12 @@ def AddTests(test_suite, session, browser, module, filename, prefix,
if (test_path.startswith(test_prefix_filter) and
hasattr(module, test_path) and callable(getattr(module, test_path))):
test_suite.addTest(test_path, module(test_path, session, browser,
- options=options))
+ path_to_html, options=options))
elif (name.startswith(test_prefix_filter) and
MatchesSuffix(name, test_suffixes)):
# no, so add a method that will run a test generically.
setattr(module, name, module.GenericTest)
- test_suite.addTest(name, module(name, session, browser,
+ test_suite.addTest(name, module(name, session, browser, path_to_html,
test_type, test_path, options))
@@ -574,7 +580,8 @@ def SeleniumSuite(session, browser, test_list, test_prefix, test_suffixes):
filename,
"Sample",
test_prefix,
- suffixes)
+ suffixes,
+ FLAGS.samplespath.replace("\\", "/"))
# add javascript tests.
filename = os.path.join(os.getcwd(), "tests", "selenium",
@@ -586,7 +593,8 @@ def SeleniumSuite(session, browser, test_list, test_prefix, test_suffixes):
filename,
"UnitTest",
test_prefix,
- suffixes)
+ suffixes,
+ '')
test_list += test_suite.test_list
diff --git a/o3d/tests/selenium/samples_tests.py b/o3d/tests/selenium/samples_tests.py
index 7d2591e..ef5a66b 100644
--- a/o3d/tests/selenium/samples_tests.py
+++ b/o3d/tests/selenium/samples_tests.py
@@ -49,6 +49,7 @@ screenshot.
import os
import time
+import gflags
import selenium_utilities
@@ -58,10 +59,11 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# TODO: Change to correct object class when NPAPI class is exposed.
SELENIUM_OBJ_TYPE = "[object HTMLObjectElement]"
- def __init__(self, name, session, browser, test_type=None, sample_path=None,
- options=None):
+ def __init__(self, name, session, browser, path_to_html, test_type=None,
+ sample_path=None, options=None):
selenium_utilities.SeleniumTestCase.__init__(
- self, name, session, browser, test_type, sample_path, options)
+ self, name, session, browser, path_to_html, test_type, sample_path,
+ options)
def GenericTest(self):
"""Generically test a sample.
@@ -71,7 +73,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
ready for a screenshot.
"""
self.RunGenericTest(
- self.session.browserURL + "/samples/",
+ "/samples/",
"(typeof(window.g_finished) != 'undefined') && "
"window.g_finished == true;",
None)
@@ -99,7 +101,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL + "/samples/rotatemodel.html")
+ s.open(self.GetURL("/samples/rotatemodel.html"))
# wait for sample to be ready.
s.wait_for_condition("(typeof(window.g_finished) != 'undefined') && "
@@ -168,7 +170,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL + "/samples/customcamera.html")
+ s.open(self.GetURL("/samples/customcamera.html"))
# Allow a limited time for the plugin to initialize.
s.wait_for_condition("typeof(window.g_client) != 'undefined';", 10000)
@@ -214,7 +216,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL + "/samples/render-mode.html")
+ s.open(self.GetURL("/samples/render-mode.html"))
# Allow a limited time for the plugin to initialize.
s.wait_for_condition("typeof(window.g_client) != 'undefined';", 10000)
@@ -252,7 +254,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL + "/samples/picking.html")
+ s.open(self.GetURL("/samples/picking.html"))
# wait for sample to be ready.
s.wait_for_condition("(typeof(window.g_finished) != 'undefined') && "
@@ -283,7 +285,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL + "/samples/shader-test.html")
+ s.open(self.GetURL("/samples/shader-test.html"))
# Allow a limited time for the plugin to initialize.
s.wait_for_condition("typeof(window.g_client) != 'undefined';", 20000)
@@ -319,7 +321,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL + "/samples/error-texture.html")
+ s.open(self.GetURL("/samples/error-texture.html"))
# Allow a limited time for the plugin to initialize.
s.wait_for_condition("typeof(window.g_client) != 'undefined';", 30000)
@@ -367,7 +369,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL + "/samples/multiple-clients.html")
+ s.open(self.GetURL("/samples/multiple-clients.html"))
# Allow a limited time for the plugin to initialize. We spot-check the
# first and last here to make sure the page has basically loaded. Before we
@@ -413,7 +415,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL + "/samples/pingpong/o3dPingPong.html")
+ s.open(self.GetURL("/samples/pingpong/o3dPingPong.html"))
# Sanity checks.
self.assertEqual("o3dPingPong", s.get_title())
@@ -431,7 +433,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL + "/samples/hellocube-textures.html")
+ s.open(self.GetURL("/samples/hellocube-textures.html"))
# Sanity checks.
self.assertEqual(
@@ -460,7 +462,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session.
s = self.session
- s.open(s.browserURL + "/samples/hellocube-textures.html")
+ s.open(self.GetURL("/samples/hellocube-textures.html"))
# Sanity checks.
self.assertEqual(
@@ -497,7 +499,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Alias for the selenium session
s = self.session
- s.open(s.browserURL + "/samples/archive-textures.html")
+ s.open(self.GetURL("/samples/archive-textures.html"))
# Allow a limited time for the plugin to initialize.
s.wait_for_condition("typeof(window.g_client) != 'undefined';", 10000)
@@ -513,7 +515,7 @@ class SampleTests(selenium_utilities.SeleniumTestCase):
# Refresh the page, before waiting for all of the textures to be loaded.
# This tests that the browser won't hang while processing the
# no-longer-needed streams.
- s.open(s.browserURL + "/samples/archive-textures.html")
+ s.open(self.GetURL("/samples/archive-textures.html"))
# Allow a limited time for the plugin to initialize.
s.wait_for_condition("typeof(window.g_client) != 'undefined';", 10000)
diff --git a/o3d/tests/selenium/selenium_utilities.py b/o3d/tests/selenium/selenium_utilities.py
index da35e8a..1e55089 100644
--- a/o3d/tests/selenium/selenium_utilities.py
+++ b/o3d/tests/selenium/selenium_utilities.py
@@ -214,14 +214,15 @@ def TakeScreenShotAtPath(session,
class SeleniumTestCase(unittest.TestCase):
"""Wrapper for TestCase for selenium."""
- def __init__(self, name, session, browser, test_type=None, sample_path=None,
- options=None):
+ def __init__(self, name, session, browser, path_to_html, test_type=None,
+ sample_path=None, options=None):
"""Constructor for SampleTests.
Args:
name: Name of unit test.
session: Selenium session.
browser: Name of browser.
+ path_to_html: path to html from server root
test_type: Type of test ("small", "medium", "large")
sample_path: Path to test.
options: list of option strings.
@@ -233,6 +234,11 @@ class SeleniumTestCase(unittest.TestCase):
self.test_type = test_type
self.sample_path = sample_path
self.options = options
+ self.path_to_html = path_to_html
+
+ def GetURL(self, url):
+ """Gets a URL for the test."""
+ return self.session.browserURL + self.path_to_html + url
def shortDescription(self):
"""override unittest.TestCase shortDescription for our own descriptions."""
@@ -281,7 +287,7 @@ class SeleniumTestCase(unittest.TestCase):
client = GetArgument(option)
self.assertTrue(not client is None)
- url = base_path + self.sample_path + ".html"
+ url = self.GetURL(base_path + self.sample_path + ".html")
# load the sample.
self.session.open(url)