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

Side by Side Diff: testing/gmock/test/gmock_leak_test.py

Issue 6241018: Pull in gmock through DEPS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/testing
Patch Set: don't use svn mirror for now Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2009, Google Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are
8 # met:
9 #
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following disclaimer
14 # in the documentation and/or other materials provided with the
15 # distribution.
16 # * Neither the name of Google Inc. nor the names of its
17 # contributors may be used to endorse or promote products derived from
18 # this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 """Tests that leaked mock objects can be caught be Google Mock."""
33
34 __author__ = 'wan@google.com (Zhanyong Wan)'
35
36
37 import gmock_test_utils
38
39
40 PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_leak_test_')
41 TEST_WITH_EXPECT_CALL = [PROGRAM_PATH, '--gtest_filter=*ExpectCall*']
42 TEST_WITH_ON_CALL = [PROGRAM_PATH, '--gtest_filter=*OnCall*']
43 TEST_MULTIPLE_LEAKS = [PROGRAM_PATH, '--gtest_filter=*MultipleLeaked*']
44
45
46 class GMockLeakTest(gmock_test_utils.TestCase):
47
48 def testCatchesLeakedMockByDefault(self):
49 self.assertNotEqual(
50 0,
51 gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL).exit_code)
52 self.assertNotEqual(
53 0,
54 gmock_test_utils.Subprocess(TEST_WITH_ON_CALL).exit_code)
55
56 def testDoesNotCatchLeakedMockWhenDisabled(self):
57 self.assertEquals(
58 0,
59 gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +
60 ['--gmock_catch_leaked_mocks=0']).exit_code)
61 self.assertEquals(
62 0,
63 gmock_test_utils.Subprocess(TEST_WITH_ON_CALL +
64 ['--gmock_catch_leaked_mocks=0']).exit_code)
65
66 def testCatchesLeakedMockWhenEnabled(self):
67 self.assertNotEqual(
68 0,
69 gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +
70 ['--gmock_catch_leaked_mocks']).exit_code)
71 self.assertNotEqual(
72 0,
73 gmock_test_utils.Subprocess(TEST_WITH_ON_CALL +
74 ['--gmock_catch_leaked_mocks']).exit_code)
75
76 def testCatchesLeakedMockWhenEnabledWithExplictFlagValue(self):
77 self.assertNotEqual(
78 0,
79 gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +
80 ['--gmock_catch_leaked_mocks=1']).exit_code)
81
82 def testCatchesMultipleLeakedMocks(self):
83 self.assertNotEqual(
84 0,
85 gmock_test_utils.Subprocess(TEST_MULTIPLE_LEAKS +
86 ['--gmock_catch_leaked_mocks']).exit_code)
87
88
89 if __name__ == '__main__':
90 gmock_test_utils.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698