diff options
author | aocampo@chromium.org <aocampo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 03:58:46 +0000 |
---|---|---|
committer | aocampo@chromium.org <aocampo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 03:58:46 +0000 |
commit | 8df71985b7a6c86da522773b0f3acc5c6ccf3d56 (patch) | |
tree | f89e44d8f504e763b32a68a4b43c5a286ba72571 /chrome/test | |
parent | e01bbe63cebccc443986b30917a8d2c45cec8f63 (diff) | |
download | chromium_src-8df71985b7a6c86da522773b0f3acc5c6ccf3d56.zip chromium_src-8df71985b7a6c86da522773b0f3acc5c6ccf3d56.tar.gz chromium_src-8df71985b7a6c86da522773b0f3acc5c6ccf3d56.tar.bz2 |
Pyauto runner for gpu tests
BUG= 65679
Review URL: http://codereview.chromium.org/7290021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/functional/PYAUTO_TESTS | 1 | ||||
-rw-r--r-- | chrome/test/functional/gpu.py | 96 |
2 files changed, 97 insertions, 0 deletions
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index aaf0b9a..27f959b 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -48,6 +48,7 @@ 'extensions', 'find_in_page', 'flash', + 'gpu', 'history', 'https', 'imports', diff --git a/chrome/test/functional/gpu.py b/chrome/test/functional/gpu.py new file mode 100644 index 0000000..5b04dc4 --- /dev/null +++ b/chrome/test/functional/gpu.py @@ -0,0 +1,96 @@ +#!/usr/bin/python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import logging +import os + +import pyauto_functional # Must be imported before pyauto +import pyauto + + +class GpuTest(pyauto.PyUITest): + """GPU Tests Runner.""" + + def _GetGpuPID(self): + """Fetch the pid of the GPU process.""" + child_processes = self.GetBrowserInfo()['child_processes'] + for x in child_processes: + if x['type'] == 'GPU': + return x['pid'] + return None + + def _IsHardwareAccelerated(self, feature): + """Check if gpu is enabled in the machine before running any tests.""" + self.NavigateToURL('about:gpu') + search = feature + ': Hardware accelerated' + find_result = self.FindInPage(search)['match_count'] + if find_result: + # about:gpu page starts a gpu process. + # Make sure to kill the GPU process after navigating to about:gpu page + pid = self._GetGpuPID() + self.Kill(pid) + return True + else: + logging.warn('Hardware acceleration not available') + return False + + def _VerifyGPUProcessOnPage(self, url): + url = self.GetFileURLForDataPath('pyauto_private', 'gpu', url) + self.NavigateToURL(url) + self.assertTrue(self.WaitUntil( + lambda: self._GetGpuPID() is not None), msg='No process for GPU') + + def testNoGpuProcessOnStart(self): + """Verify that no gpu process is spawned when first starting browser.""" + self.AppendTab(pyauto.GURL('about:blank')) + self.assertFalse(self._GetGpuPID()) + + def test2dCanvas(self): + """Verify that gpu process is spawned when viewing a 2D canvas.""" + if self._IsHardwareAccelerated('Canvas'): + self._VerifyGPUProcessOnPage('CanvasDemo.html') + + def test3dCss(self): + """Verify that gpu process is spawned when viewing a 3D CSS page.""" + if self._IsHardwareAccelerated('3D CSS'): + self._VerifyGPUProcessOnPage('3dCss.html') + + def testCompositing(self): + """Verify gpu process in compositing example.""" + if self._IsHardwareAccelerated('Compositing'): + self._VerifyGPUProcessOnPage('WebGLTeapot.html') + + def testWebGL(self): + """Verify that gpu process is spawned in webgl example.""" + if self._IsHardwareAccelerated('WebGL'): + self._VerifyGPUProcessOnPage('WebGLField.html') + + def testGpuWithVideo(self): + """Verify that gpu process is started when viewing video.""" + if self._IsHardwareAccelerated('WebGL'): + self._VerifyGPUProcessOnPage('color2.ogv') + + def testSingleGpuProcess(self): + """Verify there's only one gpu process shared across all uses.""" + if self._IsHardwareAccelerated('WebGL'): + url = self.GetFileURLForDataPath('pyauto_private', + 'gpu', 'WebGLField.html') + self.AppendTab(pyauto.GURL(url)) + # Open a new window. + self.OpenNewBrowserWindow(True) + self.NavigateToURL(url, 1, 0) + # Open a new incognito window. + self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) + self.NavigateToURL(url, 1, 0) + # Verify there's only 1 gpu process. + gpu_process_count = 0 + for x in self.GetBrowserInfo()['child_processes']: + if x['type'] == 'GPU': + gpu_process_count += 1 + self.assertEqual(1, gpu_process_count) + + +if __name__ == '__main__': + pyauto_functional.Main()
\ No newline at end of file |