1#!/usr/bin/env python
2# Copyright 2014 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import unittest
7
8from pylib.gtest import test_package
9
10# pylint: disable=W0212
11
12
13class TestPackageTest(unittest.TestCase):
14
15  def testParseGTestListTests_simple(self):
16    raw_output = [
17      'TestCaseOne.',
18      '  testOne',
19      '  testTwo',
20      'TestCaseTwo.',
21      '  testThree',
22      '  testFour',
23    ]
24    actual = test_package.TestPackage._ParseGTestListTests(raw_output)
25    expected = [
26      'TestCaseOne.testOne',
27      'TestCaseOne.testTwo',
28      'TestCaseTwo.testThree',
29      'TestCaseTwo.testFour',
30    ]
31    self.assertEqual(expected, actual)
32
33  def testParseGTestListTests_typeParameterized_old(self):
34    raw_output = [
35      'TPTestCase/WithTypeParam/0.',
36      '  testOne',
37      '  testTwo',
38    ]
39    actual = test_package.TestPackage._ParseGTestListTests(raw_output)
40    expected = [
41      'TPTestCase/WithTypeParam/0.testOne',
42      'TPTestCase/WithTypeParam/0.testTwo',
43    ]
44    self.assertEqual(expected, actual)
45
46  def testParseGTestListTests_typeParameterized_new(self):
47    raw_output = [
48      'TPTestCase/WithTypeParam/0.  # TypeParam = TypeParam0',
49      '  testOne',
50      '  testTwo',
51    ]
52    actual = test_package.TestPackage._ParseGTestListTests(raw_output)
53    expected = [
54      'TPTestCase/WithTypeParam/0.testOne',
55      'TPTestCase/WithTypeParam/0.testTwo',
56    ]
57    self.assertEqual(expected, actual)
58
59  def testParseGTestListTests_valueParameterized_old(self):
60    raw_output = [
61      'VPTestCase.',
62      '  testWithValueParam/0',
63      '  testWithValueParam/1',
64    ]
65    actual = test_package.TestPackage._ParseGTestListTests(raw_output)
66    expected = [
67      'VPTestCase.testWithValueParam/0',
68      'VPTestCase.testWithValueParam/1',
69    ]
70    self.assertEqual(expected, actual)
71
72  def testParseGTestListTests_valueParameterized_new(self):
73    raw_output = [
74      'VPTestCase.',
75      '  testWithValueParam/0  # GetParam() = 0',
76      '  testWithValueParam/1  # GetParam() = 1',
77    ]
78    actual = test_package.TestPackage._ParseGTestListTests(raw_output)
79    expected = [
80      'VPTestCase.testWithValueParam/0',
81      'VPTestCase.testWithValueParam/1',
82    ]
83    self.assertEqual(expected, actual)
84
85
86if __name__ == '__main__':
87  unittest.main(verbosity=2)
88
89