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

Side by Side Diff: tools/json_schema_compiler/cpp_bundle_generator_test.py

Issue 1558413002: 'linux' platform should exclude 'chromeos' in json compiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add tests. Created 4 years, 11 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
Devlin 2016/01/13 17:54:33 update
Shu Chen 2016/01/14 02:39:09 Done.
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()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698