Commit 4acb37fb authored by Arnaud Fontaine's avatar Arnaud Fontaine

Add code within the example to show to use listboxes


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@44875 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7e3a7450
...@@ -5,7 +5,7 @@ from erp5.utils.test_browser.browser import Browser ...@@ -5,7 +5,7 @@ from erp5.utils.test_browser.browser import Browser
ITERATION = 20 ITERATION = 20
def benchmarkAddPerson(result_dict): def benchmarkAddPerson(iteration_counter, result_dict):
""" """
Benchmark adding a person. Benchmark adding a person.
""" """
...@@ -27,8 +27,11 @@ def benchmarkAddPerson(result_dict): ...@@ -27,8 +27,11 @@ def benchmarkAddPerson(result_dict):
assert browser.getTransitionMessage() == 'Object created.' assert browser.getTransitionMessage() == 'Object created.'
# Fill the first and last name of the newly created person # Fill the first and last name of the newly created person
browser.mainForm.getControl(name='field_my_first_name').value = 'Foo' browser.mainForm.getControl(name='field_my_first_name').value = 'Foo%d' % \
browser.mainForm.getControl(name='field_my_last_name').value = 'Bar' iteration_counter
browser.mainForm.getControl(name='field_my_last_name').value = 'Bar%d' % \
iteration_counter
# Submit the changes, record the time elapsed in seconds # Submit the changes, record the time elapsed in seconds
result_dict.setdefault('Save', []).append( result_dict.setdefault('Save', []).append(
...@@ -45,13 +48,39 @@ def benchmarkAddPerson(result_dict): ...@@ -45,13 +48,39 @@ def benchmarkAddPerson(result_dict):
# Check whether it has been successfully validated # Check whether it has been successfully validated
assert browser.getTransitionMessage() == 'Status changed.' assert browser.getTransitionMessage() == 'Status changed.'
## Go to the new person from the Persons module, showing how to use
## listbox API
# Go to Persons module first (person_module)
browser.mainForm.submitSelectModule(value='/person_module')
# Select all the persons whose Usual Name starts with Foo
browser.mainForm.getListboxControl(2, 2).value = 'Foo%'
result_dict.setdefault('Filter', []).append(
browser.mainForm.timeSubmitInSecond())
# Get the line number
line_number = browser.getListboxPosition("Foo%(counter)d Bar%(counter)d" % \
{'counter': iteration_counter},
column_number=2)
# From the column and line_number, we can now get the Link instance
link = browser.getListboxLink(line_number=line_number, column_number=2)
# Click on the link
link.click()
assert browser.mainForm.getControl(name='field_my_first_name').value == \
'Foo%d' % iteration_counter
if __name__ == '__main__': if __name__ == '__main__':
# Run benchmarkAddPerson ITERATION times and compute the average time it # Run benchmarkAddPerson ITERATION times and compute the average time it
# took for each operation # took for each operation
result_dict = {} result_dict = {}
counter = 0 counter = 0
while counter != ITERATION: while counter != ITERATION:
benchmarkAddPerson(result_dict) benchmarkAddPerson(counter, result_dict)
counter += 1 counter += 1
for title, time_list in result_dict.iteritems(): for title, time_list in result_dict.iteritems():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment