| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/env python |
| 2 | |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 6 | 5 |
| 7 """A simple main function to print ui action sequences. | 6 """A simple main function to print ui action sequences. |
| 8 | 7 |
| 9 Action sequences are generated using chrome/test/functional/ui_model.py | 8 Action sequences are generated using chrome/test/functional/ui_model.py |
| 10 and are output in the format required by automated_ui_tests build target. | 9 and are output in the format required by automated_ui_tests build target. |
| 11 | 10 |
| 12 Generate 100 command sequences to ui.txt: | 11 Generate 100 command sequences to ui.txt: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 browser = ui_model.UpdateState(browser, action) | 60 browser = ui_model.UpdateState(browser, action) |
| 62 action_tuple = action.split(';') | 61 action_tuple = action.split(';') |
| 63 action_element = doc.createElement(action_tuple[0]) | 62 action_element = doc.createElement(action_tuple[0]) |
| 64 if len(action_tuple) == 2: | 63 if len(action_tuple) == 2: |
| 65 action_element.setAttribute('url', action_tuple[1]) | 64 action_element.setAttribute('url', action_tuple[1]) |
| 66 command.appendChild(action_element) | 65 command.appendChild(action_element) |
| 67 return doc.toprettyxml() | 66 return doc.toprettyxml() |
| 68 | 67 |
| 69 | 68 |
| 70 def ParseCommandLine(): | 69 def ParseCommandLine(): |
| 71 """Parses the command line. | 70 """Returns the list of options and their values, and unparsed args. |
| 72 | |
| 73 Returns: | |
| 74 List of options and their values, and unparsed args. | |
| 75 """ | 71 """ |
| 76 parser = optparse.OptionParser() | 72 parser = optparse.OptionParser() |
| 77 parser.add_option('-o', '--output', dest='output_file', type='string', | 73 parser.add_option('-o', '--output', dest='output_file', type='string', |
| 78 action='store', default='ui_actions.txt', | 74 action='store', default='ui_actions.txt', |
| 79 help='the file to output the command list to') | 75 help='the file to output the command list to') |
| 80 parser.add_option('-c', '--num_commands', dest='num_commands', | 76 parser.add_option('-c', '--num_commands', dest='num_commands', |
| 81 type='int', action='store', default=1, | 77 type='int', action='store', default=1, |
| 82 help='number of commands to output') | 78 help='number of commands to output') |
| 83 parser.add_option('-a', '--actions-per-command', dest='actions_per_command', | 79 parser.add_option('-a', '--actions-per-command', dest='actions_per_command', |
| 84 type='int', action='store', default=25, | 80 type='int', action='store', default=25, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 95 For use as input for automated_ui_tests build target. | 91 For use as input for automated_ui_tests build target. |
| 96 """ | 92 """ |
| 97 options, args = ParseCommandLine() | 93 options, args = ParseCommandLine() |
| 98 command_list = CreateUIActionList(options.actions_per_command, | 94 command_list = CreateUIActionList(options.actions_per_command, |
| 99 options.num_commands, | 95 options.num_commands, |
| 100 options.seed) | 96 options.seed) |
| 101 f = open(options.output_file, 'w') | 97 f = open(options.output_file, 'w') |
| 102 f.write(command_list) | 98 f.write(command_list) |
| 103 f.close() | 99 f.close() |
| 104 print command_list | 100 print command_list |
| 101 return 0 |
| 105 | 102 |
| 106 | 103 |
| 107 if __name__ == '__main__': | 104 if __name__ == '__main__': |
| 108 main() | 105 sys.exit(main()) |
| OLD | NEW |