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

Side by Side Diff: headless/lib/browser/client_api_generator_unittest.py

Issue 1907533002: headless: Implement DevTools events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add parameters to all events Created 4 years, 8 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 | « headless/lib/browser/client_api_generator.py ('k') | headless/lib/browser/domain_cc.template » ('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 4
5 import argparse 5 import argparse
6 import client_api_generator 6 import client_api_generator
7 import shutil 7 import shutil
8 import sys 8 import sys
9 import tempfile 9 import tempfile
10 import unittest 10 import unittest
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 {'type': 'string', 'name': 'r4'}, 293 {'type': 'string', 'name': 'r4'},
294 {'type': 'any', 'name': 'r5'}, 294 {'type': 'any', 'name': 'r5'},
295 {'type': 'object', 'name': 'r6', '$ref': 'TestType'} 295 {'type': 'object', 'name': 'r6', '$ref': 'TestType'}
296 ], 296 ],
297 } 297 }
298 ] 298 ]
299 client_api_generator.SynthesizeCommandTypes(json_api) 299 client_api_generator.SynthesizeCommandTypes(json_api)
300 types = json_api['domains'][0]['types'] 300 types = json_api['domains'][0]['types']
301 self.assertListEqual(types, expected_types) 301 self.assertListEqual(types, expected_types)
302 302
303 def test_SynthesizeEventTypes(self):
304 json_api = {
305 'domains': [
306 {
307 'domain': 'domain',
308 'events': [
309 {
310 'name': 'TestEvent',
311 'parameters': [
312 {'name': 'p1', 'type': 'number'},
313 {'name': 'p2', 'type': 'integer'},
314 {'name': 'p3', 'type': 'boolean'},
315 {'name': 'p4', 'type': 'string'},
316 {'name': 'p5', 'type': 'any'},
317 {'name': 'p6', 'type': 'object', '$ref': 'TestType'},
318 ]
319 },
320 {
321 'name': 'TestEventWithNoParams',
322 }
323 ]
324 }
325 ]
326 }
327 expected_types = [
328 {
329 'type': 'object',
330 'id': 'TestEventParams',
331 'description': 'Parameters for the TestEvent event.',
332 'properties': [
333 {'type': 'number', 'name': 'p1'},
334 {'type': 'integer', 'name': 'p2'},
335 {'type': 'boolean', 'name': 'p3'},
336 {'type': 'string', 'name': 'p4'},
337 {'type': 'any', 'name': 'p5'},
338 {'type': 'object', 'name': 'p6', '$ref': 'TestType'}
339 ]
340 },
341 {
342 'type': 'object',
343 'id': 'TestEventWithNoParamsParams',
344 'description': 'Parameters for the TestEventWithNoParams event.',
345 'properties': [],
346 }
347 ]
348 client_api_generator.SynthesizeEventTypes(json_api)
349 types = json_api['domains'][0]['types']
350 self.assertListEqual(types, expected_types)
351
303 def test_Generate(self): 352 def test_Generate(self):
304 json_api = { 353 json_api = {
305 'domains': [ 354 'domains': [
306 { 355 {
307 'domain': 'domain', 356 'domain': 'domain',
308 'types': [ 357 'types': [
309 { 358 {
310 'id': 'TestType', 359 'id': 'TestType',
311 'type': 'object', 360 'type': 'object',
312 'properties': [ 361 'properties': [
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 426
378 427
379 if __name__ == '__main__': 428 if __name__ == '__main__':
380 cmdline_parser = argparse.ArgumentParser() 429 cmdline_parser = argparse.ArgumentParser()
381 cmdline_parser.add_argument('--stamp') 430 cmdline_parser.add_argument('--stamp')
382 args = cmdline_parser.parse_args() 431 args = cmdline_parser.parse_args()
383 unittest.main(verbosity=2, exit=False, argv=sys.argv[:1]) 432 unittest.main(verbosity=2, exit=False, argv=sys.argv[:1])
384 if args.stamp: 433 if args.stamp:
385 with open(args.stamp, 'a') as f: 434 with open(args.stamp, 'a') as f:
386 pass 435 pass
OLDNEW
« no previous file with comments | « headless/lib/browser/client_api_generator.py ('k') | headless/lib/browser/domain_cc.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698