| OLD | NEW |
| 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 | 6 |
| 7 import fieldtrial_to_struct | 7 import fieldtrial_to_struct |
| 8 import os | 8 import os |
| 9 | 9 |
| 10 | 10 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 ], | 201 ], |
| 202 }, | 202 }, |
| 203 ] | 203 ] |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 self.maxDiff = None | 207 self.maxDiff = None |
| 208 self.assertEqual(expected, result) | 208 self.assertEqual(expected, result) |
| 209 | 209 |
| 210 def test_FieldTrialToStructMain(self): | 210 def test_FieldTrialToStructMain(self): |
| 211 schema = ( | 211 schema = ('../../components/variations/field_trial_config/' |
| 212 '../../chrome/common/variations/fieldtrial_testing_config_schema.json') | 212 'field_trial_testing_config_schema.json') |
| 213 test_output_filename = 'test_output' | 213 test_output_filename = 'test_output' |
| 214 fieldtrial_to_struct.main([ | 214 fieldtrial_to_struct.main([ |
| 215 '--schema=' + schema, | 215 '--schema=' + schema, |
| 216 '--output=' + test_output_filename, | 216 '--output=' + test_output_filename, |
| 217 '--platform=win', | 217 '--platform=win', |
| 218 '--year=2015', | 218 '--year=2015', |
| 219 'unittest_data/test_config.json' | 219 'unittest_data/test_config.json' |
| 220 ]) | 220 ]) |
| 221 header_filename = test_output_filename + '.h' | 221 header_filename = test_output_filename + '.h' |
| 222 with open(header_filename, 'r') as header: | 222 with open(header_filename, 'r') as header: |
| 223 test_header = header.read() | 223 test_header = header.read() |
| 224 with open('unittest_data/expected_output.h', 'r') as expected: | 224 with open('unittest_data/expected_output.h', 'r') as expected: |
| 225 expected_header = expected.read() | 225 expected_header = expected.read() |
| 226 self.assertEqual(expected_header, test_header) | 226 self.assertEqual(expected_header, test_header) |
| 227 os.unlink(header_filename) | 227 os.unlink(header_filename) |
| 228 | 228 |
| 229 cc_filename = test_output_filename + '.cc' | 229 cc_filename = test_output_filename + '.cc' |
| 230 with open(cc_filename, 'r') as cc: | 230 with open(cc_filename, 'r') as cc: |
| 231 test_cc = cc.read() | 231 test_cc = cc.read() |
| 232 with open('unittest_data/expected_output.cc', 'r') as expected: | 232 with open('unittest_data/expected_output.cc', 'r') as expected: |
| 233 expected_cc = expected.read() | 233 expected_cc = expected.read() |
| 234 self.assertEqual(expected_cc, test_cc) | 234 self.assertEqual(expected_cc, test_cc) |
| 235 os.unlink(cc_filename) | 235 os.unlink(cc_filename) |
| 236 | 236 |
| 237 if __name__ == '__main__': | 237 if __name__ == '__main__': |
| 238 unittest.main() | 238 unittest.main() |
| OLD | NEW |