OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging, re, time | 5 import logging, re, time |
6 from autotest_lib.client.bin import site_ui_test | 6 from autotest_lib.client.bin import site_ui_test |
7 from autotest_lib.client.common_lib import error | 7 from autotest_lib.client.common_lib import error |
8 | 8 |
9 class desktopui_ChromeFirstRender(site_ui_test.UITest): | 9 class desktopui_ChromeFirstRender(site_ui_test.UITest): |
10 version = 1 | 10 version = 1 |
11 | 11 |
12 | 12 |
13 def __parse_uptime(self, target_file): | 13 def __parse_uptime(self, target_file): |
14 data = file(target_file).read() | 14 data = file(target_file).read() |
15 time = re.split(r' +', data.strip())[0] | 15 time = re.split(r' +', data.strip())[0] |
16 return float(time) | 16 return float(time) |
17 | 17 |
18 | 18 |
19 def run_once(self): | 19 def run_once(self): |
20 try: | 20 try: |
21 time.sleep(10) # Wait for chrome to render. | 21 time.sleep(10) # Wait for chrome to render. |
22 start_time = self.__parse_uptime('/tmp/uptime-login-successful') | 22 start_time = self.__parse_uptime('/tmp/uptime-login-successful') |
23 end_time = self.__parse_uptime('/tmp/uptime-chrome-first-render') | 23 end_time = self.__parse_uptime('/tmp/uptime-chrome-first-render') |
24 self.write_perf_keyval({'seconds_chrome_first_tab': | 24 self.write_perf_keyval( |
25 end_time - start_time}) | 25 { 'seconds_chrome_first_tab': end_time - start_time }) |
26 except IOError, e: | 26 except IOError, e: |
27 logging.debug(e) | 27 logging.debug(e) |
28 raise error.TestFail('Login information missing') | 28 raise error.TestFail('Login information missing') |
29 | |
OLD | NEW |