Commit 7abbb509 authored by krisr@chromium.org's avatar krisr@chromium.org

Track what PDFs fail to load

TEST=Ran it
BUG=chromium-os:25775
Review URL: https://chromiumcodereview.appspot.com/9595032

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125007 0039d316-1c4b-4281-b951-d872f2087c98
parent 20098535
...@@ -8,6 +8,7 @@ import glob ...@@ -8,6 +8,7 @@ import glob
import pyauto_functional # Must be imported before pyauto import pyauto_functional # Must be imported before pyauto
import pyauto import pyauto
from pyauto_errors import JSONInterfaceError
class PDFTest(pyauto.PyUITest): class PDFTest(pyauto.PyUITest):
...@@ -16,6 +17,8 @@ class PDFTest(pyauto.PyUITest): ...@@ -16,6 +17,8 @@ class PDFTest(pyauto.PyUITest):
This test runs only on Google Chrome build, not on Chromium. This test runs only on Google Chrome build, not on Chromium.
""" """
unloadable_pdfs = []
def _PerformPDFAction(self, action, tab_index=0, windex=0): def _PerformPDFAction(self, action, tab_index=0, windex=0):
"""Perform an action on a PDF tab. """Perform an action on a PDF tab.
...@@ -30,10 +33,16 @@ class PDFTest(pyauto.PyUITest): ...@@ -30,10 +33,16 @@ class PDFTest(pyauto.PyUITest):
document.getElementsByName("plugin")[0]) document.getElementsByName("plugin")[0])
{ window.domAutomationController.send("true"); } { window.domAutomationController.send("true"); }
else {window.domAutomationController.send("false"); }""" else {window.domAutomationController.send("false"); }"""
self.assertTrue(self.WaitUntil(lambda: self.ExecuteJavascript(js, try:
tab_index=tab_index, windex=windex), expect_retval="true"), self.assertTrue(self.WaitUntil(lambda: self.ExecuteJavascript(js,
msg='Could not find zoom/fit to page/width bar so we will not be able ' tab_index=tab_index, windex=windex), expect_retval="true"),
'to peform the requested action') msg='Could not find zoom/fit to page/width bar so we will not be able '
'to peform the requested action')
except JSONInterfaceError as e:
# The PDF did not load, add it to the list and move on, we don't want the
# test to abort so we can check all of the PDFs.
PDFTest.unloadable_pdfs.append(self.GetActiveTabTitle())
return
assert action in ('fitToHeight', 'fitToWidth', 'ZoomIn', 'ZoomOut') assert action in ('fitToHeight', 'fitToWidth', 'ZoomIn', 'ZoomOut')
js = 'document.getElementsByName("plugin")[0].%s()' % action js = 'document.getElementsByName("plugin")[0].%s()' % action
# Add an empty string so that there's something to return back # Add an empty string so that there's something to return back
...@@ -61,6 +70,7 @@ class PDFTest(pyauto.PyUITest): ...@@ -61,6 +70,7 @@ class PDFTest(pyauto.PyUITest):
pdf_files = [x for x in pdf_files if pdf_files = [x for x in pdf_files if
os.path.basename(x) not in exclude_list] os.path.basename(x) not in exclude_list]
PDFTest.unloadable_pdfs = []
for url in pdf_files: for url in pdf_files:
self.AppendTab(pyauto.GURL(url)) self.AppendTab(pyauto.GURL(url))
for tab_index in range(1, len(pdf_files) + 1): for tab_index in range(1, len(pdf_files) + 1):
...@@ -74,6 +84,8 @@ class PDFTest(pyauto.PyUITest): ...@@ -74,6 +84,8 @@ class PDFTest(pyauto.PyUITest):
for dmp_file in glob.glob(os.path.join(breakpad_folder, '*.dmp')): for dmp_file in glob.glob(os.path.join(breakpad_folder, '*.dmp')):
self.assertTrue(dmp_file in old_dmp_files, self.assertTrue(dmp_file in old_dmp_files,
msg='Crash dump %s found' % dmp_file) msg='Crash dump %s found' % dmp_file)
self.assertEqual(len(PDFTest.unloadable_pdfs), 0, msg='The following PDFs '
'did not load: %s' % PDFTest.unloadable_pdfs)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment