Skip to content

Commit

Permalink
Merge pull request #3 from ldtp/master
Browse files Browse the repository at this point in the history
Latest update
  • Loading branch information
yingjunli committed Dec 18, 2012
2 parents 00022d3 + 505ea19 commit 08ed1ad
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
44 changes: 35 additions & 9 deletions atomac/ldtpd/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,32 @@ def __del__(self):
self._process_stats[key].stop()

"""Core LDTP class"""
def appundertest(self, app_name):
"""
Application under test
app_name: Application name should be app identifier
eg: com.apple.AppleSpell', 'com.apple.talagent', 'com.apple.dock',
'com.adiumX.adiumX', 'com.apple.notificationcenterui', 'org.3rddev.xchatazure',
'com.skype.skype', 'com.mcafee.McAfeeReporter', 'com.microsoft.outlook.database_daemon',
'com.apple.photostream-agent', 'com.google.GoogleTalkPluginD',
'com.microsoft.SyncServicesAgent', 'com.google.Chrome.helper.EH',
'com.apple.dashboard.client', 'None', 'com.vmware.fusionStartMenu',
'com.apple.ImageCaptureExtension2', 'com.apple.loginwindow', 'com.mozypro.status',
'com.apple.Preview', 'com.google.Chrome.helper', 'com.apple.calculator',
'com.apple.Terminal', 'com.apple.iTunesHelper', 'com.apple.ActivityMonitor',
'net.juniper.NetworkConnect', 'com.google.Chrome', 'com.apple.dock.extra',
'com.apple.finder', 'com.yourcompany.Menulet', 'com.apple.systemuiserver'
@return: return 1 on success
@rtype: int
"""
self._app_under_test=app_name
return 1

def getapplist(self):
"""
Get all accessibility application name that are currently running
@return: list of appliction name of string type on success.
@rtype: list
"""
Expand Down Expand Up @@ -391,15 +413,19 @@ def launchapp(self, cmd, args = [], delay = 0, env = 1, lang = "C"):
@raise LdtpServerException: When command fails
"""
if atomac.NativeUIElement.launchAppByBundlePath(cmd):
# Let us wait so that the application launches
try:
time.sleep(int(delay))
except ValueError:
time.sleep(5)
try:
atomac.NativeUIElement.launchAppByBundleId(cmd)
return 1
else:
raise LdtpServerException(u"Unable to find app '%s'" % cmd)
except RuntimeError:
if atomac.NativeUIElement.launchAppByBundlePath(cmd):
# Let us wait so that the application launches
try:
time.sleep(int(delay))
except ValueError:
time.sleep(5)
return 1
else:
raise LdtpServerException(u"Unable to find app '%s'" % cmd)

def wait(self, timeout=5):
"""
Expand Down
6 changes: 6 additions & 0 deletions atomac/ldtpd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def __init__(self):
self._windows={}
self._obj_timeout=5
self._window_timeout=30
self._app_under_test=None
self._custom_logger=_custom_logger
# Current opened applications list will be updated
self._running_apps=atomac.NativeUIElement._getRunningApps()
Expand Down Expand Up @@ -308,6 +309,11 @@ def _get_windows(self, force_remap=False):
windows={}
self._ldtpized_obj_index={}
for gui in set(self._running_apps):
if self._app_under_test and \
self._app_under_test != gui.bundleIdentifier() and \
self._app_under_test != gui.localizedName():
# Not the app under test, search next application
continue
# Get process id
pid=gui.processIdentifier()
# Get app id
Expand Down

0 comments on commit 08ed1ad

Please sign in to comment.