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

Side by Side Diff: build/android/pylib/base/test_dispatcher_unittest.py

Issue 23205011: [Android] Move getting the list of devices out of test_dispatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated unit tests Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/base/test_dispatcher.py ('k') | build/android/pylib/gtest/setup.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Unittests for test_dispatcher.py.""" 5 """Unittests for test_dispatcher.py."""
6 6
7 import os 7 import os
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 runners = test_dispatcher._CreateRunners(MockRunnerException, ['0', '1']) 160 runners = test_dispatcher._CreateRunners(MockRunnerException, ['0', '1'])
161 with self.assertRaises(TestException): 161 with self.assertRaises(TestException):
162 test_dispatcher._RunAllTests(runners, self.test_collection_factory, 0) 162 test_dispatcher._RunAllTests(runners, self.test_collection_factory, 0)
163 163
164 164
165 class TestShard(unittest.TestCase): 165 class TestShard(unittest.TestCase):
166 """Tests test_dispatcher.RunTests with sharding.""" 166 """Tests test_dispatcher.RunTests with sharding."""
167 @staticmethod 167 @staticmethod
168 def _RunShard(runner_factory): 168 def _RunShard(runner_factory):
169 return test_dispatcher.RunTests( 169 return test_dispatcher.RunTests(
170 ['a', 'b', 'c'], runner_factory, False, None, shard=True) 170 ['a', 'b', 'c'], runner_factory, ['0', '1'], shard=True)
171 171
172 def testShard(self): 172 def testShard(self):
173 results, exit_code = TestShard._RunShard(MockRunner) 173 results, exit_code = TestShard._RunShard(MockRunner)
174 self.assertEqual(len(results.GetPass()), 3) 174 self.assertEqual(len(results.GetPass()), 3)
175 self.assertEqual(exit_code, 0) 175 self.assertEqual(exit_code, 0)
176 176
177 def testFailing(self): 177 def testFailing(self):
178 results, exit_code = TestShard._RunShard(MockRunnerFail) 178 results, exit_code = TestShard._RunShard(MockRunnerFail)
179 self.assertEqual(len(results.GetPass()), 0) 179 self.assertEqual(len(results.GetPass()), 0)
180 self.assertEqual(len(results.GetFail()), 3) 180 self.assertEqual(len(results.GetFail()), 3)
181 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE) 181 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE)
182 182
183 def testNoTests(self): 183 def testNoTests(self):
184 results, exit_code = test_dispatcher.RunTests( 184 results, exit_code = test_dispatcher.RunTests(
185 [], MockRunner, False, None, shard=True) 185 [], MockRunner, ['0', '1'], shard=True)
186 self.assertEqual(len(results.GetAll()), 0) 186 self.assertEqual(len(results.GetAll()), 0)
187 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE) 187 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE)
188 188
189 189
190 class TestReplicate(unittest.TestCase): 190 class TestReplicate(unittest.TestCase):
191 """Tests test_dispatcher.RunTests with replication.""" 191 """Tests test_dispatcher.RunTests with replication."""
192 @staticmethod 192 @staticmethod
193 def _RunReplicate(runner_factory): 193 def _RunReplicate(runner_factory):
194 return test_dispatcher.RunTests( 194 return test_dispatcher.RunTests(
195 ['a', 'b', 'c'], runner_factory, False, None, shard=False) 195 ['a', 'b', 'c'], runner_factory, ['0', '1'], shard=False)
196 196
197 def testReplicate(self): 197 def testReplicate(self):
198 results, exit_code = TestReplicate._RunReplicate(MockRunner) 198 results, exit_code = TestReplicate._RunReplicate(MockRunner)
199 # We expect 6 results since each test should have been run on every device 199 # We expect 6 results since each test should have been run on every device
200 self.assertEqual(len(results.GetPass()), 6) 200 self.assertEqual(len(results.GetPass()), 6)
201 self.assertEqual(exit_code, 0) 201 self.assertEqual(exit_code, 0)
202 202
203 def testFailing(self): 203 def testFailing(self):
204 results, exit_code = TestReplicate._RunReplicate(MockRunnerFail) 204 results, exit_code = TestReplicate._RunReplicate(MockRunnerFail)
205 self.assertEqual(len(results.GetPass()), 0) 205 self.assertEqual(len(results.GetPass()), 0)
206 self.assertEqual(len(results.GetFail()), 6) 206 self.assertEqual(len(results.GetFail()), 6)
207 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE) 207 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE)
208 208
209 def testNoTests(self): 209 def testNoTests(self):
210 results, exit_code = test_dispatcher.RunTests( 210 results, exit_code = test_dispatcher.RunTests(
211 [], MockRunner, False, None, shard=False) 211 [], MockRunner, ['0', '1'], shard=False)
212 self.assertEqual(len(results.GetAll()), 0) 212 self.assertEqual(len(results.GetAll()), 0)
213 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE) 213 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE)
214 214
215 215
216 if __name__ == '__main__': 216 if __name__ == '__main__':
217 unittest.main() 217 unittest.main()
OLDNEW
« no previous file with comments | « build/android/pylib/base/test_dispatcher.py ('k') | build/android/pylib/gtest/setup.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698