OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 from cpp_bundle_generator import CppBundleGenerator |
| 7 from model import Model |
| 8 |
| 9 import json_schema |
| 10 import os |
| 11 import unittest |
| 12 |
| 13 def _createCppBundleGenerator(file_path): |
| 14 json_object = json_schema.Load(file_path) |
| 15 model = Model() |
| 16 model.AddNamespace(json_object[0], file_path) |
| 17 cpp_bundle_generator = CppBundleGenerator( |
| 18 None, model, None, None, 'generated_api_schemas', |
| 19 None, None, None) |
| 20 return (cpp_bundle_generator, model) |
| 21 |
| 22 def _getPlatformIfdefs(cpp_bundle_generator, model): |
| 23 return cpp_bundle_generator._GetPlatformIfdefs( |
| 24 model.namespaces.values()[0].functions.values()[0]) |
| 25 |
| 26 class CppBundleGeneratorTest(unittest.TestCase): |
| 27 def testIfDefsForWinLinux(self): |
| 28 cpp_bundle_generator, model = _createCppBundleGenerator( |
| 29 'test/function_platform_win_linux.json') |
| 30 self.assertEquals( |
| 31 'defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))', |
| 32 _getPlatformIfdefs(cpp_bundle_generator, model)) |
| 33 |
| 34 def testIfDefsForAll(self): |
| 35 cpp_bundle_generator, model = _createCppBundleGenerator( |
| 36 'test/function_platform_all.json') |
| 37 self.assertEquals( |
| 38 'defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || ' |
| 39 'defined(OS_CHROMEOS)', |
| 40 _getPlatformIfdefs(cpp_bundle_generator, model)) |
| 41 |
| 42 def testIfDefsForChromeOS(self): |
| 43 cpp_bundle_generator, model = _createCppBundleGenerator( |
| 44 'test/function_platform_chromeos.json') |
| 45 self.assertEquals( |
| 46 'defined(OS_CHROMEOS)', |
| 47 _getPlatformIfdefs(cpp_bundle_generator, model)) |
| 48 |
| 49 if __name__ == '__main__': |
| 50 unittest.main() |
OLD | NEW |