forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_apps_test.py
122 lines (104 loc) · 4.23 KB
/
test_apps_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Unittests for test_apps.py."""
import mock
import unittest
import test_apps
import test_runner_test
_TEST_APP_PATH = '/path/to/test_app.app'
_HOST_APP_PATH = '/path/to/host_app.app'
_BUNDLE_ID = 'org.chromium.gtest.test-app'
_MODULE_NAME = 'test_app'
_XCTEST_PATH = '/PlugIns/boringssl_ssl_tests_module.xctest'
class GetGTestFilterTest(test_runner_test.TestCase):
"""Tests for test_runner.get_gtest_filter."""
def test_correct(self):
"""Ensures correctness of filter."""
tests = [
'test.1',
'test.2',
]
expected = 'test.1:test.2'
self.assertEqual(test_apps.get_gtest_filter(tests), expected)
def test_correct_inverted(self):
"""Ensures correctness of inverted filter."""
tests = [
'test.1',
'test.2',
]
expected = '-test.1:test.2'
self.assertEqual(test_apps.get_gtest_filter(tests, invert=True), expected)
class DeviceXCTestUnitTestsAppTest(test_runner_test.TestCase):
"""Tests to test methods of SimulatorXCTestUnitTestsApp."""
@mock.patch('test_apps.get_bundle_id', return_value=_BUNDLE_ID)
@mock.patch(
'test_apps.DeviceXCTestUnitTestsApp._xctest_path',
return_value=_XCTEST_PATH)
@mock.patch('os.path.exists', return_value=True)
def test_fill_xctestrun_node(self, *args):
"""Tests fill_xctestrun_node method."""
test_app = test_apps.DeviceXCTestUnitTestsApp(_TEST_APP_PATH)
expected_xctestrun_node = {
'TestTargetName': {
'CommandLineArguments': [
'--enable-run-ios-unittests-with-xctest',
'--gmock_verbose=error'
],
'IsAppHostedTestBundle': True,
'TestBundlePath': '__TESTHOST__%s' % _XCTEST_PATH,
'TestHostBundleIdentifier': _BUNDLE_ID,
'TestHostPath': '%s' % _TEST_APP_PATH,
'TestingEnvironmentVariables': {
'DYLD_INSERT_LIBRARIES':
'__TESTHOST__/Frameworks/libXCTestBundleInject.dylib',
'DYLD_LIBRARY_PATH':
'__PLATFORMS__/iPhoneOS.platform/Developer/Library',
'DYLD_FRAMEWORK_PATH':
'__PLATFORMS__/iPhoneOS.platform/Developer/'
'Library/Frameworks',
'XCInjectBundleInto':
'__TESTHOST__/%s' % _MODULE_NAME
}
}
}
xctestrun_node = test_app.fill_xctestrun_node()
self.assertEqual(xctestrun_node, expected_xctestrun_node)
class SimulatorXCTestUnitTestsAppTest(test_runner_test.TestCase):
"""Tests to test methods of SimulatorXCTestUnitTestsApp."""
@mock.patch('test_apps.get_bundle_id', return_value=_BUNDLE_ID)
@mock.patch(
'test_apps.SimulatorXCTestUnitTestsApp._xctest_path',
return_value=_XCTEST_PATH)
@mock.patch('os.path.exists', return_value=True)
def test_fill_xctestrun_node(self, *args):
"""Tests fill_xctestrun_node method."""
test_app = test_apps.SimulatorXCTestUnitTestsApp(_TEST_APP_PATH)
expected_xctestrun_node = {
'TestTargetName': {
'CommandLineArguments': [
'--enable-run-ios-unittests-with-xctest',
'--gmock_verbose=error'
],
'IsAppHostedTestBundle': True,
'TestBundlePath': '__TESTHOST__%s' % _XCTEST_PATH,
'TestHostBundleIdentifier': _BUNDLE_ID,
'TestHostPath': '%s' % _TEST_APP_PATH,
'TestingEnvironmentVariables': {
'DYLD_INSERT_LIBRARIES':
'__PLATFORMS__/iPhoneSimulator.platform/Developer/usr/lib/'
'libXCTestBundleInject.dylib',
'DYLD_LIBRARY_PATH':
'__PLATFORMS__/iPhoneSimulator.platform/Developer/Library',
'DYLD_FRAMEWORK_PATH':
'__PLATFORMS__/iPhoneSimulator.platform/Developer/'
'Library/Frameworks',
'XCInjectBundleInto':
'__TESTHOST__/%s' % _MODULE_NAME
}
}
}
xctestrun_node = test_app.fill_xctestrun_node()
self.assertEqual(xctestrun_node, expected_xctestrun_node)
if __name__ == '__main__':
unittest.main()