summaryrefslogtreecommitdiffstats
path: root/o3d/tests
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-08 19:50:29 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-08 19:50:29 +0000
commit16f5c4de8b926dc889859cfff03c9328edb60a5c (patch)
treec6d7a6f51973164ae28ff3157f0cf6356736c1d7 /o3d/tests
parentc890e98205d97b57534f2eac00618a2864d61bb5 (diff)
downloadchromium_src-16f5c4de8b926dc889859cfff03c9328edb60a5c.zip
chromium_src-16f5c4de8b926dc889859cfff03c9328edb60a5c.tar.gz
chromium_src-16f5c4de8b926dc889859cfff03c9328edb60a5c.tar.bz2
This CL adds client.toDataURL which gets the contents
of the client area as a data url (which is a base64 encoded string of a png file) data urls are part of the HTML5 standard and supported by firefox, safari and chrome. http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-canvas-todataurl That means you can now do this var dataURL = client.toDataURL(); // make an IMG tag display the screenshot someImgTag.src = dataURL; // use the IMG tag to draw into a canvas someCanvasContext.drawImage(someImageTag, ...); It also means there is no need for the test builds anymore "test-dbg-d3d", "test-opt-d3d" etc as toDataURL is part of the public API and can therefore always be used to take screenshots in any build. I updated the selenium code to use it. There are a few issues: 1) The GL version has the same limitations as taking a screenshot before. Namely that the client area must be on screen. We need to fix this. 2) We need to add support for origin-clean. See https://tracker.corp.google.com/story/show/180334 Review URL: http://codereview.chromium.org/164130 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/tests')
-rw-r--r--o3d/tests/build.scons2
-rw-r--r--o3d/tests/selenium/selenium_utilities.py14
2 files changed, 12 insertions, 4 deletions
diff --git a/o3d/tests/build.scons b/o3d/tests/build.scons
index f37d5a7..dc6b23a 100644
--- a/o3d/tests/build.scons
+++ b/o3d/tests/build.scons
@@ -254,6 +254,8 @@ tests = [
'import/cross/threaded_stream_processor_test.cc',
'serializer/cross/serializer_test.cc',
'tests/common/cross/test_utils.cc',
+ 'utils/cross/base64_test.cc',
+ 'utils/cross/dataurl_test.cc',
'utils/cross/file_path_utils_test.cc',
'utils/cross/file_text_reader_test.cc',
'utils/cross/json_writer_test.cc',
diff --git a/o3d/tests/selenium/selenium_utilities.py b/o3d/tests/selenium/selenium_utilities.py
index 8f8ccc0..da35e8a 100644
--- a/o3d/tests/selenium/selenium_utilities.py
+++ b/o3d/tests/selenium/selenium_utilities.py
@@ -39,6 +39,7 @@ import os
import re
import time
import unittest
+import base64
import gflags
import selenium_constants
@@ -174,7 +175,8 @@ def TakeScreenShotAtPath(session,
full_path = filename.replace("\\", "/")
# Attempt to take a screenshot of the display buffer
- eval_string = ("%s.saveScreen('%s')" % (client, full_path))
+ eval_string = ("%s.toDataURL()" % client)
+
# Set Post render call back to take screenshot
script = ["window.g_selenium_post_render = false;",
@@ -196,9 +198,13 @@ def TakeScreenShotAtPath(session,
session.wait_for_condition("window.g_selenium_post_render", 20000)
# Get result
- success = session.get_eval("window.g_selenium_save_screen_result")
-
- if success == u"true":
+ data_url = session.get_eval("window.g_selenium_save_screen_result")
+ expected_header = "data:image/png;base64,"
+ if data_url.startswith(expected_header):
+ png = base64.b64decode(data_url[len(expected_header):])
+ file = open(full_path + ".png", 'wb')
+ file.write(png)
+ file.close()
print "Saved screenshot %s." % full_path
return True