1# Copyright 2017 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import sys
6
7from telemetry.testing import serially_executed_browser_test_case
8
9
10class FailIfSetUpProcessCalledTwice(
11    serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase):
12  count = 0
13
14  @classmethod
15  def SetUpProcess(cls):
16    cls.count += 1
17    if cls.count >= 2:
18      assert False, 'This should not be called more than once'
19
20  @classmethod
21  def GenerateTestCases_DummyTest(cls, options):
22    del options  # Unused.
23    for i in xrange(0, 3):
24      yield 'Dummy_%i' % i, ()
25
26  def DummyTest(self):
27    pass
28
29
30class FailIfTearDownProcessCalledTwice(
31    serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase):
32  count = 0
33
34  @classmethod
35  def TearDownProcess(cls):
36    cls.count += 1
37    if cls.count >= 2:
38      assert False, 'This should not be called more than once'
39
40  @classmethod
41  def GenerateTestCases_DummyTest(cls, options):
42    del options  # Unused.
43    for i in xrange(0, 3):
44      yield 'Dummy_%i' % i, ()
45
46  def DummyTest(self):
47    pass
48
49
50def load_tests(loader, tests, pattern):
51  del loader, tests, pattern  # Unused.
52  return serially_executed_browser_test_case.LoadAllTestsInModule(
53      sys.modules[__name__])
54