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> >', |