Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: chrome/test/functional/media/worker_thread.py

Issue 10830193: Remove SWIGged use of BrowserProxy and TabProxy from PyAuto tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Used named arguments and deleted unused test files, as suggested by Nirnimesh. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/functional/media/media_stat_perf.py ('k') | chrome/test/functional/nacl_sdk.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium 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 """Worker thread base class. 5 """Worker thread base class.
6 6
7 Worker threads are used to run multiple PyUITests simultaneously. They 7 Worker threads are used to run multiple PyUITests simultaneously. They
8 synchronize calls to the browser.""" 8 synchronize calls to the browser."""
9 9
10 import itertools 10 import itertools
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 while True: 98 while True:
99 task = self.__tasks.get() 99 task = self.__tasks.get()
100 # Check for magic exit values. 100 # Check for magic exit values.
101 if task is None: 101 if task is None:
102 break 102 break
103 # Make the test URL unique so we can figure out our tab index later. 103 # Make the test URL unique so we can figure out our tab index later.
104 unique_url = '%s?%d' % (self.__url, WorkerThread._task_id.next()) 104 unique_url = '%s?%d' % (self.__url, WorkerThread._task_id.next())
105 self.AppendTab(unique_url) 105 self.AppendTab(unique_url)
106 if not self.RunTask(unique_url, task): 106 if not self.RunTask(unique_url, task):
107 self.failures += 1 107 self.failures += 1
108 self.CloseTab(unique_url) 108 self.CloseTabByURL(unique_url)
109 self.__tasks.task_done() 109 self.__tasks.task_done()
110 110
111 def __FindTabLocked(self, url): 111 def __FindTabLocked(self, url):
112 """Returns the tab index for the tab belonging to this url. 112 """Returns the tab index for the tab belonging to this url.
113 113
114 __lock must be owned by caller. 114 __lock must be owned by caller.
115 """ 115 """
116 if url is None: 116 if url is None:
117 return 0 117 return 0
118 for tab in self.__pyauto.GetBrowserInfo()['windows'][0]['tabs']: 118 for tab in self.__pyauto.GetBrowserInfo()['windows'][0]['tabs']:
(...skipping 12 matching lines...) Expand all
131 @synchronized 131 @synchronized
132 def AppendTab(self, url): 132 def AppendTab(self, url):
133 self.__pyauto.AppendTab(pyauto.GURL(url)) 133 self.__pyauto.AppendTab(pyauto.GURL(url))
134 134
135 @synchronized 135 @synchronized
136 def CallJavascriptFunc(self, fun_name, fun_args=[], url=None): 136 def CallJavascriptFunc(self, fun_name, fun_args=[], url=None):
137 return self.__pyauto.CallJavascriptFunc(fun_name, fun_args, 137 return self.__pyauto.CallJavascriptFunc(fun_name, fun_args,
138 tab_index=self.__FindTabLocked(url)) 138 tab_index=self.__FindTabLocked(url))
139 139
140 @synchronized 140 @synchronized
141 def CloseTab(self, url): 141 def CloseTabByURL(self, url):
142 """Closes the tab with the given url.""" 142 """Closes the tab with the given url."""
143 return self.__pyauto.GetBrowserWindow(0).GetTab( 143 self.CloseTab(tab_index=self.__FindTabLocked(url))
144 self.__FindTabLocked(url)).Close(True)
145 144
146 @synchronized 145 @synchronized
147 def GetDOMValue(self, name, url=None): 146 def GetDOMValue(self, name, url=None):
148 return self.__pyauto.GetDOMValue(name, tab_index=self.__FindTabLocked(url)) 147 return self.__pyauto.GetDOMValue(name, tab_index=self.__FindTabLocked(url))
149 148
150 def WaitUntil(self, *args, **kwargs): 149 def WaitUntil(self, *args, **kwargs):
151 """We do not need to lock WaitUntil since it does not call into Chrome. 150 """We do not need to lock WaitUntil since it does not call into Chrome.
152 151
153 Ensure that the function passed in the args is thread safe. 152 Ensure that the function passed in the args is thread safe.
154 """ 153 """
155 return self.__pyauto.WaitUntil(*args, **kwargs) 154 return self.__pyauto.WaitUntil(*args, **kwargs)
OLDNEW
« no previous file with comments | « chrome/test/functional/media/media_stat_perf.py ('k') | chrome/test/functional/nacl_sdk.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698