Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
erp5
Commits
ea890a3a
Commit
ea890a3a
authored
Aug 16, 2011
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Generic Browser class.
Make code more generic and several clean ups and API definititions.
parent
c1022c61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
23 deletions
+47
-23
product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
+47
-23
No files found.
product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
View file @
ea890a3a
...
...
@@ -88,8 +88,9 @@ class Xvfb:
print "Stopping Xvfb on pid: %s" % self.pid
os.kill(self.pid, signal.SIGTERM)
class Firefox:
class Browser:
use_xvfb = 1
def __init__(self, profile_dir, host, port):
self.profile_dir = profile_dir
self.host = host
...
...
@@ -100,9 +101,36 @@ class Firefox:
if self.pid:
os.kill(self.pid, signal.SIGTERM)
def _run(self, url, display):
""" This method should be implemented on a subclass """
raise NotImplementedError
def _setEnviron(self):
pass
def run(self, url, display):
self._prepare()
self.clean()
self._setEnviron()
self._setDisplay(display)
self._run(url)
print "Browser %s running on pid: %s" % (self.__class__.__name__, self.pid)
def clean(self):
""" Clean up removing profile dir and recreating it"""
os.system("rm -rf %s" % self.profile_dir)
os.mkdir(self.profile_dir)
def _createFile(self, filename, content):
file_path = os.path.join(self.profile_dir, filename)
f = open(file_path, '
w
')
try:
f.write(content)
finally:
f.close()
return file_path
def _setDisplay(self, display):
if display is None:
try:
shutil.copy2(os.path.expanduser('
~/
.
Xauthority
'), '
%
s
/
.
Xauthority
' % self.profile_dir)
...
...
@@ -111,21 +139,27 @@ class Firefox:
else:
os.environ["DISPLAY"] = display
def _runCommand(self, command_tuple):
print " ".join(list(command_tuple))
self.pid = os.spawnlp(os.P_NOWAIT, *command_tuple)
class Firefox(Browser):
""" Use firefox to open run all the tests"""
def _setEnviron(self):
os.environ['
MOZ_NO_REMOTE
'] = '
1
'
os.environ['
HOME
'] = self.profile_dir
os.environ['
LC_ALL
'] = '
C
'
os.environ["MOZ_CRASHREPORTER_DISABLE"] = "1"
os.environ["NO_EM_RESTART"] = "1"
command_tuple = ("firefox", "firefox", "-no-remote",
"-profile", self.profile_dir, url)
print " ".join(list(command_tuple))
def _run(self, url):
# Prepare to run
self._createFile('
prefs
.
js
', self.getPrefJs())
self._runCommand(("firefox", "firefox", "-no-remote",
"-profile", self.profile_dir, url))
self.pid = os.spawnlp(os.P_NOWAIT, *command_tuple)
os.environ['
MOZ_NO_REMOTE
'] = '
0
'
print '
firefox
:
%
d
' % self.pid
return self.pid
def getPrefJs(self):
return """
...
...
@@ -162,17 +196,7 @@ user_pref("capability.principal.codebase.p1.granted", "UniversalFileRead");
user_pref
(
"signed.applets.codebase_principal_support"
,
true
);
user_pref
(
"capability.principal.codebase.p1.id"
,
"http://%s:%s"
);
user_pref
(
"capability.principal.codebase.p1.subjectName"
,
""
);
""" %
\
def _prepare(self):
prefs_js = self.getPrefJs(self.host, self.port)
os.system("rm -rf %s" % self.profile_dir)
os.mkdir(self.profile_dir)
pref_file = open(os.path.join(self.profile_dir, 'prefs.js'), 'w')
pref_file.write(prefs_js)
pref_file.close()
def isXvfbRequired(self):
return True
(self.host, self.port)
class FunctionalTestRunner:
...
...
@@ -208,7 +232,7 @@ class FunctionalTestRunner:
display = None
xvfb = Xvfb(self.instance_home, None)
try:
if not debug and
browser.isXvfbRequired()
:
if not debug and
self.browser.use_xvfb
:
xvfb.display = self.xvfb_display
xvfb.run()
browser.run(test_url, xvfb.display)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment