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

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/generate.py

Issue 2652163002: bluetooth: Improve GATT disconnected error message. (Closed)
Patch Set: Merge TOT Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/script-tests/server/device-disconnects-before.js » ('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 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 """Generator script for Web Bluetooth LayoutTests. 4 """Generator script for Web Bluetooth LayoutTests.
5 5
6 For each script-tests/X.js creates the following test files depending on the 6 For each script-tests/X.js creates the following test files depending on the
7 contents of X.js 7 contents of X.js
8 - getPrimaryService/X.html 8 - getPrimaryService/X.html
9 - getPrimaryServices/X.html 9 - getPrimaryServices/X.html
10 - getPrimaryServices/X-with-uuid.html 10 - getPrimaryServices/X-with-uuid.html
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 # Generate Test Files 89 # Generate Test Files
90 for template in available_templates: 90 for template in available_templates:
91 # Read template 91 # Read template
92 template_file_handle = open(template) 92 template_file_handle = open(template)
93 template_file_data = template_file_handle.read().decode('utf-8') 93 template_file_data = template_file_handle.read().decode('utf-8')
94 template_file_handle.close() 94 template_file_handle.close()
95 95
96 template_name = os.path.splitext(os.path.basename(template))[0] 96 template_name = os.path.splitext(os.path.basename(template))[0]
97 97
98 result = re.search(r'CALLS\(\[(.*?)\]\)', template_file_data, re.MULTILI NE 98 # Find function names in multiline pattern: CALLS( [ function_name,funct ion_name2[UUID] ])
99 | re.DOTALL) 99 result = re.search(
100 r'CALLS\(' + # CALLS(
101 r'[^\[]*' + # Any characters not [, allowing for new lines.
102 r'\[' + # [
103 r'(.*?)' + # group matching: function_name(), function_name2[UUID]
104 r'\]\)', # adjacent closing characters: ])
105 template_file_data, re.MULTILINE | re.DOTALL)
100 106
101 if result is None: 107 if result is None:
102 raise Exception('Template must contain \'CALLS\' tokens') 108 raise Exception('Template must contain \'CALLS\' tokens')
103 109
104 new_test_file_data = base_template_file_data.replace('TEST', 110 new_test_file_data = base_template_file_data.replace('TEST',
105 template_file_data) 111 template_file_data)
106 # Replace CALLS([...]) with CALLS so that we don't have to replace the 112 # Replace CALLS([...]) with CALLS so that we don't have to replace the
107 # CALLS([...]) for every new test file. 113 # CALLS([...]) for every new test file.
108 new_test_file_data = new_test_file_data.replace(result.group(), 'CALLS') 114 new_test_file_data = new_test_file_data.replace(result.group(), 'CALLS')
109 115
(...skipping 29 matching lines...) Expand all
139 # Create or open test file 145 # Create or open test file
140 test_file_handle = open(generated_test.path, 'wb') 146 test_file_handle = open(generated_test.path, 'wb')
141 147
142 # Write contents 148 # Write contents
143 test_file_handle.write(generated_test.data.encode('utf-8')) 149 test_file_handle.write(generated_test.data.encode('utf-8'))
144 test_file_handle.close() 150 test_file_handle.close()
145 151
146 152
147 if __name__ == '__main__': 153 if __name__ == '__main__':
148 sys.exit(main()) 154 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/script-tests/server/device-disconnects-before.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698