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

Side by Side Diff: mojo/python/tests/validation_unittest.py

Issue 951573002: Add validation test cases for struct versioning. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « mojo/public/js/validation_unittests.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 logging 5 import logging
6 import os 6 import os
7 import os.path 7 import os.path
8 8
9 import mojo_unittest 9 import mojo_unittest
10 import validation_test_interfaces_mojom 10 import validation_test_interfaces_mojom
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 expect_file = filename[:-4] + 'expected' 60 expect_file = filename[:-4] + 'expected'
61 expected_error = open( 61 expected_error = open(
62 os.path.join(data_dir, expect_file), 'r').read().strip(); 62 os.path.join(data_dir, expect_file), 'r').read().strip();
63 success = expected_error == 'PASS' 63 success = expected_error == 'PASS'
64 return (filename, data, success) 64 return (filename, data, success)
65 65
66 @staticmethod 66 @staticmethod
67 def GetData(prefix): 67 def GetData(prefix):
68 data_dir = os.path.join(paths.src_root, 'mojo', 'public', 'interfaces', 68 data_dir = os.path.join(paths.src_root, 'mojo', 'public', 'interfaces',
69 'bindings', 'tests', 'data', 'validation') 69 'bindings', 'tests', 'data', 'validation')
70
71 # TODO(qsr, yzshen): Skipping some struct versioning tests.
72 skipped_tests = ["conformance_mthd11_num_bytes_version_mismatch_1.data"]
73
70 return [ValidationTest.ParseData(data_dir, x) for x in os.listdir(data_dir) 74 return [ValidationTest.ParseData(data_dir, x) for x in os.listdir(data_dir)
71 if x.startswith(prefix) and x.endswith('.data')] 75 if x.startswith(prefix) and x.endswith('.data') and
76 x not in skipped_tests]
72 77
73 def runTest(self, prefix, message_receiver): 78 def runTest(self, prefix, message_receiver):
74 for (filename, data, expected) in ValidationTest.GetData(prefix): 79 for (filename, data, expected) in ValidationTest.GetData(prefix):
75 self.assertEquals(len(data.error_message), 0) 80 self.assertEquals(len(data.error_message), 0)
76 handles = [HandleMock() for _ in xrange(data.num_handles)] 81 handles = [HandleMock() for _ in xrange(data.num_handles)]
77 message = messaging.Message(data.data, handles) 82 message = messaging.Message(data.data, handles)
78 self.assertEquals(message_receiver.Accept(message), expected, 83 self.assertEquals(message_receiver.Accept(message), expected,
79 'Unexpected result for test: %s' % filename) 84 'Unexpected result for test: %s' % filename)
80 85
81 def testConformance(self): 86 def testConformance(self):
82 manager = validation_test_interfaces_mojom.ConformanceTestInterface.manager 87 manager = validation_test_interfaces_mojom.ConformanceTestInterface.manager
83 proxy = manager._InternalProxy(SinkMessageReceiver(), None) 88 proxy = manager._InternalProxy(SinkMessageReceiver(), None)
84 stub = manager._Stub(proxy) 89 stub = manager._Stub(proxy)
85 self.runTest('conformance_', stub) 90 self.runTest('conformance_', stub)
OLDNEW
« no previous file with comments | « mojo/public/js/validation_unittests.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698