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

Unified Diff: tools/json_schema_compiler/cpp_type_generator_test.py

Issue 487533005: Add support for references in different paths in apis (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator.py ('k') | tools/json_schema_compiler/dart_generator_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/cpp_type_generator_test.py
diff --git a/tools/json_schema_compiler/cpp_type_generator_test.py b/tools/json_schema_compiler/cpp_type_generator_test.py
index f3a760a2adcf5833aa3165bc87776e5231ae669a..51fcfe94e365bbc6c4d6811a7798087e24a5424a 100755
--- a/tools/json_schema_compiler/cpp_type_generator_test.py
+++ b/tools/json_schema_compiler/cpp_type_generator_test.py
@@ -3,6 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from cpp_namespace_environment import CppNamespaceEnvironment
from cpp_type_generator import CppTypeGenerator
from json_schema import CachedLoad
import model
@@ -51,8 +52,12 @@ class CppTypeGeneratorTest(unittest.TestCase):
def testGenerateIncludesAndForwardDeclarations(self):
m = model.Model()
- m.AddNamespace(self.windows_json[0], 'path/to/windows.json')
- m.AddNamespace(self.tabs_json[0], 'path/to/tabs.json')
+ m.AddNamespace(self.windows_json[0],
+ 'path/to/windows.json',
+ environment=CppNamespaceEnvironment('%(namespace)s'))
+ m.AddNamespace(self.tabs_json[0],
+ 'path/to/tabs.json',
+ environment=CppNamespaceEnvironment('%(namespace)s'))
manager = CppTypeGenerator(m, _FakeSchemaLoader(m))
self.assertEquals('', manager.GenerateIncludes().Render())
@@ -62,7 +67,18 @@ class CppTypeGeneratorTest(unittest.TestCase):
'namespace tabs {\n'
'struct Tab;\n'
'} // namespace tabs',
- manager.GenerateForwardDeclarations('%(namespace)s').Render())
+ manager.GenerateForwardDeclarations().Render())
+
+ m = model.Model()
+ m.AddNamespace(self.windows_json[0],
+ 'path/to/windows.json',
+ environment=CppNamespaceEnvironment(
+ 'foo::bar::%(namespace)s'))
+ m.AddNamespace(self.tabs_json[0],
+ 'path/to/tabs.json',
+ environment=CppNamespaceEnvironment(
+ 'foo::bar::%(namespace)s'))
+ manager = CppTypeGenerator(m, _FakeSchemaLoader(m))
self.assertEquals(
'namespace foo {\n'
'namespace bar {\n'
@@ -71,13 +87,12 @@ class CppTypeGeneratorTest(unittest.TestCase):
'} // namespace tabs\n'
'} // namespace bar\n'
'} // namespace foo',
- manager.GenerateForwardDeclarations('foo::bar::%(namespace)s').Render())
+ manager.GenerateForwardDeclarations().Render())
manager = CppTypeGenerator(self.models.get('permissions'),
_FakeSchemaLoader(m))
self.assertEquals('', manager.GenerateIncludes().Render())
self.assertEquals('', manager.GenerateIncludes().Render())
- self.assertEquals(
- '', manager.GenerateForwardDeclarations('%(namespace)s').Render())
+ self.assertEquals('', manager.GenerateForwardDeclarations().Render())
manager = CppTypeGenerator(self.models.get('content_settings'),
_FakeSchemaLoader(m))
self.assertEquals('', manager.GenerateIncludes().Render())
@@ -96,8 +111,7 @@ class CppTypeGeneratorTest(unittest.TestCase):
self.assertEquals('#include "path/to/browser_action.h"\n'
'#include "path/to/font_settings.h"',
manager.GenerateIncludes().Render())
- self.assertEquals(
- '', manager.GenerateForwardDeclarations('%(namespace)s').Render())
+ self.assertEquals('', manager.GenerateForwardDeclarations().Render())
def testGetCppTypeSimple(self):
manager = CppTypeGenerator(self.models.get('tabs'), _FakeSchemaLoader(None))
@@ -147,8 +161,12 @@ class CppTypeGeneratorTest(unittest.TestCase):
def testGetCppTypeIncludedRef(self):
m = model.Model()
- m.AddNamespace(self.windows_json[0], 'path/to/windows.json')
- m.AddNamespace(self.tabs_json[0], 'path/to/tabs.json')
+ m.AddNamespace(self.windows_json[0],
+ 'path/to/windows.json',
+ environment=CppNamespaceEnvironment('%(namespace)s'))
+ m.AddNamespace(self.tabs_json[0],
+ 'path/to/tabs.json',
+ environment=CppNamespaceEnvironment('%(namespace)s'))
manager = CppTypeGenerator(m, _FakeSchemaLoader(m))
self.assertEquals(
'std::vector<linked_ptr<tabs::Tab> >',
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator.py ('k') | tools/json_schema_compiler/dart_generator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698