OLD | NEW |
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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 {'type': 'string', 'name': 'p4'}, | 336 {'type': 'string', 'name': 'p4'}, |
337 {'type': 'any', 'name': 'p5'}, | 337 {'type': 'any', 'name': 'p5'}, |
338 {'type': 'object', 'name': 'p6', '$ref': 'TestType'} | 338 {'type': 'object', 'name': 'p6', '$ref': 'TestType'} |
339 ] | 339 ] |
340 } | 340 } |
341 ] | 341 ] |
342 client_api_generator.SynthesizeEventTypes(json_api) | 342 client_api_generator.SynthesizeEventTypes(json_api) |
343 types = json_api['domains'][0]['types'] | 343 types = json_api['domains'][0]['types'] |
344 self.assertListEqual(types, expected_types) | 344 self.assertListEqual(types, expected_types) |
345 | 345 |
| 346 def test_HideHiddenDomains(self): |
| 347 json_api = { |
| 348 'domains': [ |
| 349 { |
| 350 'domain': 'domain', |
| 351 'hidden': True, |
| 352 'commands': [ |
| 353 { |
| 354 'name': 'FooCommand', |
| 355 } |
| 356 ], |
| 357 'events': [ |
| 358 { |
| 359 'name': 'BarEvent', |
| 360 } |
| 361 ] |
| 362 } |
| 363 ] |
| 364 } |
| 365 client_api_generator.HideHiddenDomains(json_api) |
| 366 for command in json_api['domains'][0]['commands']: |
| 367 self.assertTrue(command['hidden']) |
| 368 for event in json_api['domains'][0]['events']: |
| 369 self.assertTrue(command['hidden']) |
| 370 |
346 def test_Generate(self): | 371 def test_Generate(self): |
347 json_api = { | 372 json_api = { |
348 'domains': [ | 373 'domains': [ |
349 { | 374 { |
350 'domain': 'domain', | 375 'domain': 'domain', |
351 'types': [ | 376 'types': [ |
352 { | 377 { |
353 'id': 'TestType', | 378 'id': 'TestType', |
354 'type': 'object', | 379 'type': 'object', |
355 'properties': [ | 380 'properties': [ |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 445 |
421 | 446 |
422 if __name__ == '__main__': | 447 if __name__ == '__main__': |
423 cmdline_parser = argparse.ArgumentParser() | 448 cmdline_parser = argparse.ArgumentParser() |
424 cmdline_parser.add_argument('--stamp') | 449 cmdline_parser.add_argument('--stamp') |
425 args = cmdline_parser.parse_args() | 450 args = cmdline_parser.parse_args() |
426 unittest.main(verbosity=2, exit=False, argv=sys.argv[:1]) | 451 unittest.main(verbosity=2, exit=False, argv=sys.argv[:1]) |
427 if args.stamp: | 452 if args.stamp: |
428 with open(args.stamp, 'a') as f: | 453 with open(args.stamp, 'a') as f: |
429 pass | 454 pass |
OLD | NEW |