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

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator_unittest.py

Issue 1418453017: Fix some minor bugs related to imports in the new mojom bindings generator. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix tests. Created 5 years, 1 month 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
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 unittest 5 import unittest
6 import module 6 import module
7 7
8 try: 8 try:
9 import mojom_translator 9 import mojom_translator
10 from generated import mojom_files_mojom 10 from generated import mojom_files_mojom
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 349
350 # Translate should create the imports. 350 # Translate should create the imports.
351 translator = mojom_translator.FileTranslator(graph, 'a.mojom') 351 translator = mojom_translator.FileTranslator(graph, 'a.mojom')
352 translator.Translate() 352 translator.Translate()
353 353
354 struct = translator.UserDefinedFromTypeRef( 354 struct = translator.UserDefinedFromTypeRef(
355 mojom_types_mojom.Type( 355 mojom_types_mojom.Type(
356 type_reference=mojom_types_mojom.TypeReference( 356 type_reference=mojom_types_mojom.TypeReference(
357 type_key=type_key))) 357 type_key=type_key)))
358 358
359 self.assertIsNone(struct.module) 359 self.assertEquals(
360 translator._imports['root/c.mojom']['module'], struct.module)
360 self.assertEquals(translator._imports['root/c.mojom'], struct.imported_from) 361 self.assertEquals(translator._imports['root/c.mojom'], struct.imported_from)
361 362
362 def test_interface(self): 363 def test_interface(self):
363 file_name = 'a.mojom' 364 file_name = 'a.mojom'
364 mojom_interface = mojom_types_mojom.MojomInterface( 365 mojom_interface = mojom_types_mojom.MojomInterface(
365 decl_data=mojom_types_mojom.DeclarationData( 366 decl_data=mojom_types_mojom.DeclarationData(
366 source_file_info=mojom_types_mojom.SourceFileInfo( 367 source_file_info=mojom_types_mojom.SourceFileInfo(
367 file_name=file_name)), 368 file_name=file_name)),
368 interface_name='AnInterface') 369 interface_name='AnInterface')
369 mojom_method = mojom_types_mojom.MojomMethod( 370 mojom_method = mojom_types_mojom.MojomMethod(
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 result2 = t.KindFromMojom(mojom_type) 687 result2 = t.KindFromMojom(mojom_type)
687 self.assertIs(result, result2) 688 self.assertIs(result, result2)
688 689
689 # Nullable type reference 690 # Nullable type reference
690 mojom_type.type_reference.nullable = True 691 mojom_type.type_reference.nullable = True
691 nullable_result = t.KindFromMojom(mojom_type) 692 nullable_result = t.KindFromMojom(mojom_type)
692 self.assertTrue(module.IsNullableKind(nullable_result)) 693 self.assertTrue(module.IsNullableKind(nullable_result))
693 694
694 if __name__ == '__main__': 695 if __name__ == '__main__':
695 unittest.main() 696 unittest.main()
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/generate/mojom_translator.py ('k') | mojo/public/tools/bindings/run_code_generators.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698