OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import copy | 7 import copy |
8 import email | 8 import email |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 This method resets the timeout before returning. | 229 This method resets the timeout before returning. |
230 """ | 230 """ |
231 timeout_changer = pyauto.PyUITest.ActionTimeoutChanger( | 231 timeout_changer = pyauto.PyUITest.ActionTimeoutChanger( |
232 self, new_timeout) | 232 self, new_timeout) |
233 logging.info('Automation execution timeout has been changed to %d. ' | 233 logging.info('Automation execution timeout has been changed to %d. ' |
234 'If the timeout is large the test might appear to hang.' | 234 'If the timeout is large the test might appear to hang.' |
235 % new_timeout) | 235 % new_timeout) |
236 function() | 236 function() |
237 del timeout_changer | 237 del timeout_changer |
238 | 238 |
| 239 def GetOmniboxMatchesFor(self, text, windex=0, attr_dict=None): |
| 240 """Fetch omnibox matches with the given attributes for the given query. |
| 241 |
| 242 Args: |
| 243 text: the query text to use |
| 244 windex: the window index to work on. Defaults to 0 (first window) |
| 245 attr_dict: the dictionary of properties to be satisfied |
| 246 |
| 247 Returns: |
| 248 a list of match items |
| 249 """ |
| 250 self.SetOmniboxText(text, windex=windex) |
| 251 self.WaitUntilOmniboxQueryDone(windex=windex) |
| 252 if not attr_dict: |
| 253 matches = self.GetOmniboxInfo(windex=windex).Matches() |
| 254 else: |
| 255 matches = self.GetOmniboxInfo(windex=windex).MatchesWithAttributes( |
| 256 attr_dict=attr_dict) |
| 257 return matches |
239 | 258 |
240 def GetMemoryUsageOfProcess(pid): | 259 def GetMemoryUsageOfProcess(pid): |
241 """Queries the system for the current memory usage of a specified process. | 260 """Queries the system for the current memory usage of a specified process. |
242 | 261 |
243 This function only works in Linux and ChromeOS. | 262 This function only works in Linux and ChromeOS. |
244 | 263 |
245 Args: | 264 Args: |
246 pid: The integer process identifier for the process to use. | 265 pid: The integer process identifier for the process to use. |
247 | 266 |
248 Returns: | 267 Returns: |
249 The memory usage of the process in MB, given as a float. If the process | 268 The memory usage of the process in MB, given as a float. If the process |
250 doesn't exist on the machine, then the value 0 is returned. | 269 doesn't exist on the machine, then the value 0 is returned. |
251 """ | 270 """ |
252 assert pyauto.PyUITest.IsLinux() or pyauto.PyUITest.IsChromeOS() | 271 assert pyauto.PyUITest.IsLinux() or pyauto.PyUITest.IsChromeOS() |
253 process = subprocess.Popen('ps h -o rss -p %s' % pid, shell=True, | 272 process = subprocess.Popen('ps h -o rss -p %s' % pid, shell=True, |
254 stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 273 stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
255 stdout = process.communicate()[0] | 274 stdout = process.communicate()[0] |
256 if stdout: | 275 if stdout: |
257 return float(stdout.strip()) / 1024 | 276 return float(stdout.strip()) / 1024 |
258 else: | 277 else: |
259 return 0 | 278 return 0 |
OLD | NEW |