shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 1 | // Copyright 2008, Google Inc. |
| 2 | // All rights reserved. |
| 3 | // |
| 4 | // Redistribution and use in source and binary forms, with or without |
| 5 | // modification, are permitted provided that the following conditions are |
| 6 | // met: |
| 7 | // |
| 8 | // * Redistributions of source code must retain the above copyright |
| 9 | // notice, this list of conditions and the following disclaimer. |
| 10 | // * Redistributions in binary form must reproduce the above |
| 11 | // copyright notice, this list of conditions and the following disclaimer |
| 12 | // in the documentation and/or other materials provided with the |
| 13 | // distribution. |
| 14 | // * Neither the name of Google Inc. nor the names of its |
| 15 | // contributors may be used to endorse or promote products derived from |
| 16 | // this software without specific prior written permission. |
| 17 | // |
| 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | // |
| 30 | // Author: wan@google.com (Zhanyong Wan) |
| 31 | |
zhanyong.wan | 53e08c4 | 2010-09-14 05:38:21 +0000 | [diff] [blame] | 32 | #include "gmock/gmock-generated-nice-strict.h" |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 33 | |
| 34 | #include <string> |
zhanyong.wan | 53e08c4 | 2010-09-14 05:38:21 +0000 | [diff] [blame] | 35 | #include "gmock/gmock.h" |
| 36 | #include "gtest/gtest.h" |
| 37 | #include "gtest/gtest-spi.h" |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 38 | |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 39 | // This must not be defined inside the ::testing namespace, or it will |
| 40 | // clash with ::testing::Mock. |
| 41 | class Mock { |
| 42 | public: |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 43 | Mock() {} |
| 44 | |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 45 | MOCK_METHOD0(DoThis, void()); |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 46 | |
| 47 | private: |
| 48 | GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock); |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 51 | namespace testing { |
| 52 | namespace gmock_nice_strict_test { |
| 53 | |
| 54 | using testing::internal::string; |
| 55 | using testing::GMOCK_FLAG(verbose); |
| 56 | using testing::HasSubstr; |
zhanyong.wan | 844fa94 | 2013-03-01 01:54:22 +0000 | [diff] [blame^] | 57 | using testing::NaggyMock; |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 58 | using testing::NiceMock; |
| 59 | using testing::StrictMock; |
| 60 | |
zhanyong.wan | 2516f60 | 2010-08-31 18:28:02 +0000 | [diff] [blame] | 61 | #if GTEST_HAS_STREAM_REDIRECTION |
zhanyong.wan | 470df42 | 2010-02-02 22:34:58 +0000 | [diff] [blame] | 62 | using testing::internal::CaptureStdout; |
| 63 | using testing::internal::GetCapturedStdout; |
zhanyong.wan | 2516f60 | 2010-08-31 18:28:02 +0000 | [diff] [blame] | 64 | #endif |
zhanyong.wan | 470df42 | 2010-02-02 22:34:58 +0000 | [diff] [blame] | 65 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 66 | // Defines some mock classes needed by the tests. |
| 67 | |
| 68 | class Foo { |
| 69 | public: |
| 70 | virtual ~Foo() {} |
| 71 | |
| 72 | virtual void DoThis() = 0; |
| 73 | virtual int DoThat(bool flag) = 0; |
| 74 | }; |
| 75 | |
| 76 | class MockFoo : public Foo { |
| 77 | public: |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 78 | MockFoo() {} |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 79 | void Delete() { delete this; } |
| 80 | |
| 81 | MOCK_METHOD0(DoThis, void()); |
| 82 | MOCK_METHOD1(DoThat, int(bool flag)); |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 83 | |
| 84 | private: |
| 85 | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | class MockBar { |
| 89 | public: |
| 90 | explicit MockBar(const string& s) : str_(s) {} |
| 91 | |
| 92 | MockBar(char a1, char a2, string a3, string a4, int a5, int a6, |
| 93 | const string& a7, const string& a8, bool a9, bool a10) { |
| 94 | str_ = string() + a1 + a2 + a3 + a4 + static_cast<char>(a5) + |
| 95 | static_cast<char>(a6) + a7 + a8 + (a9 ? 'T' : 'F') + (a10 ? 'T' : 'F'); |
| 96 | } |
| 97 | |
| 98 | virtual ~MockBar() {} |
| 99 | |
| 100 | const string& str() const { return str_; } |
| 101 | |
| 102 | MOCK_METHOD0(This, int()); |
| 103 | MOCK_METHOD2(That, string(int, bool)); |
| 104 | |
| 105 | private: |
| 106 | string str_; |
zhanyong.wan | 32de5f5 | 2009-12-23 00:13:23 +0000 | [diff] [blame] | 107 | |
| 108 | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockBar); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 109 | }; |
| 110 | |
zhanyong.wan | 2516f60 | 2010-08-31 18:28:02 +0000 | [diff] [blame] | 111 | #if GTEST_HAS_STREAM_REDIRECTION |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 112 | |
| 113 | // Tests that a nice mock generates no warning for uninteresting calls. |
| 114 | TEST(NiceMockTest, NoWarningForUninterestingCall) { |
| 115 | NiceMock<MockFoo> nice_foo; |
| 116 | |
zhanyong.wan | 470df42 | 2010-02-02 22:34:58 +0000 | [diff] [blame] | 117 | CaptureStdout(); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 118 | nice_foo.DoThis(); |
| 119 | nice_foo.DoThat(true); |
zhanyong.wan | 844fa94 | 2013-03-01 01:54:22 +0000 | [diff] [blame^] | 120 | EXPECT_EQ("", GetCapturedStdout()); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | // Tests that a nice mock generates no warning for uninteresting calls |
| 124 | // that delete the mock object. |
| 125 | TEST(NiceMockTest, NoWarningForUninterestingCallAfterDeath) { |
| 126 | NiceMock<MockFoo>* const nice_foo = new NiceMock<MockFoo>; |
| 127 | |
| 128 | ON_CALL(*nice_foo, DoThis()) |
| 129 | .WillByDefault(Invoke(nice_foo, &MockFoo::Delete)); |
| 130 | |
zhanyong.wan | 470df42 | 2010-02-02 22:34:58 +0000 | [diff] [blame] | 131 | CaptureStdout(); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 132 | nice_foo->DoThis(); |
zhanyong.wan | 844fa94 | 2013-03-01 01:54:22 +0000 | [diff] [blame^] | 133 | EXPECT_EQ("", GetCapturedStdout()); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | // Tests that a nice mock generates informational logs for |
| 137 | // uninteresting calls. |
| 138 | TEST(NiceMockTest, InfoForUninterestingCall) { |
| 139 | NiceMock<MockFoo> nice_foo; |
| 140 | |
vladlosev | 76c1c61 | 2010-05-05 19:47:46 +0000 | [diff] [blame] | 141 | const string saved_flag = GMOCK_FLAG(verbose); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 142 | GMOCK_FLAG(verbose) = "info"; |
zhanyong.wan | 470df42 | 2010-02-02 22:34:58 +0000 | [diff] [blame] | 143 | CaptureStdout(); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 144 | nice_foo.DoThis(); |
zhanyong.wan | 844fa94 | 2013-03-01 01:54:22 +0000 | [diff] [blame^] | 145 | EXPECT_THAT(GetCapturedStdout(), |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 146 | HasSubstr("Uninteresting mock function call")); |
| 147 | |
zhanyong.wan | 470df42 | 2010-02-02 22:34:58 +0000 | [diff] [blame] | 148 | CaptureStdout(); |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 149 | nice_foo.DoThat(true); |
zhanyong.wan | 844fa94 | 2013-03-01 01:54:22 +0000 | [diff] [blame^] | 150 | EXPECT_THAT(GetCapturedStdout(), |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 151 | HasSubstr("Uninteresting mock function call")); |
vladlosev | 76c1c61 | 2010-05-05 19:47:46 +0000 | [diff] [blame] | 152 | GMOCK_FLAG(verbose) = saved_flag; |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 153 | } |
| 154 | |
zhanyong.wan | 2516f60 | 2010-08-31 18:28:02 +0000 | [diff] [blame] | 155 | #endif // GTEST_HAS_STREAM_REDIRECTION |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 156 | |
| 157 | // Tests that a nice mock allows expected calls. |
| 158 | TEST(NiceMockTest, AllowsExpectedCall) { |
| 159 | NiceMock<MockFoo> nice_foo; |
| 160 | |
| 161 | EXPECT_CALL(nice_foo, DoThis()); |
| 162 | nice_foo.DoThis(); |
| 163 | } |
| 164 | |
| 165 | // Tests that an unexpected call on a nice mock fails. |
| 166 | TEST(NiceMockTest, UnexpectedCallFails) { |
| 167 | NiceMock<MockFoo> nice_foo; |
| 168 | |
| 169 | EXPECT_CALL(nice_foo, DoThis()).Times(0); |
| 170 | EXPECT_NONFATAL_FAILURE(nice_foo.DoThis(), "called more times than expected"); |
| 171 | } |
| 172 | |
| 173 | // Tests that NiceMock works with a mock class that has a non-default |
| 174 | // constructor. |
| 175 | TEST(NiceMockTest, NonDefaultConstructor) { |
| 176 | NiceMock<MockBar> nice_bar("hi"); |
| 177 | EXPECT_EQ("hi", nice_bar.str()); |
| 178 | |
| 179 | nice_bar.This(); |
| 180 | nice_bar.That(5, true); |
| 181 | } |
| 182 | |
| 183 | // Tests that NiceMock works with a mock class that has a 10-ary |
| 184 | // non-default constructor. |
| 185 | TEST(NiceMockTest, NonDefaultConstructor10) { |
| 186 | NiceMock<MockBar> nice_bar('a', 'b', "c", "d", 'e', 'f', |
| 187 | "g", "h", true, false); |
| 188 | EXPECT_EQ("abcdefghTF", nice_bar.str()); |
| 189 | |
| 190 | nice_bar.This(); |
| 191 | nice_bar.That(5, true); |
| 192 | } |
| 193 | |
vladlosev | 6c54a5e | 2009-10-21 06:15:34 +0000 | [diff] [blame] | 194 | #if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 195 | // Tests that NiceMock<Mock> compiles where Mock is a user-defined |
zhanyong.wan | 844fa94 | 2013-03-01 01:54:22 +0000 | [diff] [blame^] | 196 | // class (as opposed to ::testing::Mock). We had to work around an |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 197 | // MSVC 8.0 bug that caused the symbol Mock used in the definition of |
| 198 | // NiceMock to be looked up in the wrong context, and this test |
| 199 | // ensures that our fix works. |
zhanyong.wan | 93244dc | 2009-09-17 19:11:00 +0000 | [diff] [blame] | 200 | // |
vladlosev | 6c54a5e | 2009-10-21 06:15:34 +0000 | [diff] [blame] | 201 | // We have to skip this test on Symbian and Windows Mobile, as it |
| 202 | // causes the program to crash there, for reasons unclear to us yet. |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 203 | TEST(NiceMockTest, AcceptsClassNamedMock) { |
| 204 | NiceMock< ::Mock> nice; |
| 205 | EXPECT_CALL(nice, DoThis()); |
| 206 | nice.DoThis(); |
| 207 | } |
vladlosev | 6c54a5e | 2009-10-21 06:15:34 +0000 | [diff] [blame] | 208 | #endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 209 | |
zhanyong.wan | 844fa94 | 2013-03-01 01:54:22 +0000 | [diff] [blame^] | 210 | #if GTEST_HAS_STREAM_REDIRECTION |
| 211 | |
| 212 | // Tests that a naggy mock generates warnings for uninteresting calls. |
| 213 | TEST(NaggyMockTest, WarningForUninterestingCall) { |
| 214 | const string saved_flag = GMOCK_FLAG(verbose); |
| 215 | GMOCK_FLAG(verbose) = "warning"; |
| 216 | |
| 217 | NaggyMock<MockFoo> naggy_foo; |
| 218 | |
| 219 | CaptureStdout(); |
| 220 | naggy_foo.DoThis(); |
| 221 | naggy_foo.DoThat(true); |
| 222 | EXPECT_THAT(GetCapturedStdout(), |
| 223 | HasSubstr("Uninteresting mock function call")); |
| 224 | |
| 225 | GMOCK_FLAG(verbose) = saved_flag; |
| 226 | } |
| 227 | |
| 228 | // Tests that a naggy mock generates a warning for an uninteresting call |
| 229 | // that deletes the mock object. |
| 230 | TEST(NaggyMockTest, WarningForUninterestingCallAfterDeath) { |
| 231 | const string saved_flag = GMOCK_FLAG(verbose); |
| 232 | GMOCK_FLAG(verbose) = "warning"; |
| 233 | |
| 234 | NaggyMock<MockFoo>* const naggy_foo = new NaggyMock<MockFoo>; |
| 235 | |
| 236 | ON_CALL(*naggy_foo, DoThis()) |
| 237 | .WillByDefault(Invoke(naggy_foo, &MockFoo::Delete)); |
| 238 | |
| 239 | CaptureStdout(); |
| 240 | naggy_foo->DoThis(); |
| 241 | EXPECT_THAT(GetCapturedStdout(), |
| 242 | HasSubstr("Uninteresting mock function call")); |
| 243 | |
| 244 | GMOCK_FLAG(verbose) = saved_flag; |
| 245 | } |
| 246 | |
| 247 | #endif // GTEST_HAS_STREAM_REDIRECTION |
| 248 | |
| 249 | // Tests that a naggy mock allows expected calls. |
| 250 | TEST(NaggyMockTest, AllowsExpectedCall) { |
| 251 | NaggyMock<MockFoo> naggy_foo; |
| 252 | |
| 253 | EXPECT_CALL(naggy_foo, DoThis()); |
| 254 | naggy_foo.DoThis(); |
| 255 | } |
| 256 | |
| 257 | // Tests that an unexpected call on a naggy mock fails. |
| 258 | TEST(NaggyMockTest, UnexpectedCallFails) { |
| 259 | NaggyMock<MockFoo> naggy_foo; |
| 260 | |
| 261 | EXPECT_CALL(naggy_foo, DoThis()).Times(0); |
| 262 | EXPECT_NONFATAL_FAILURE(naggy_foo.DoThis(), |
| 263 | "called more times than expected"); |
| 264 | } |
| 265 | |
| 266 | // Tests that NaggyMock works with a mock class that has a non-default |
| 267 | // constructor. |
| 268 | TEST(NaggyMockTest, NonDefaultConstructor) { |
| 269 | NaggyMock<MockBar> naggy_bar("hi"); |
| 270 | EXPECT_EQ("hi", naggy_bar.str()); |
| 271 | |
| 272 | naggy_bar.This(); |
| 273 | naggy_bar.That(5, true); |
| 274 | } |
| 275 | |
| 276 | // Tests that NaggyMock works with a mock class that has a 10-ary |
| 277 | // non-default constructor. |
| 278 | TEST(NaggyMockTest, NonDefaultConstructor10) { |
| 279 | NaggyMock<MockBar> naggy_bar('0', '1', "2", "3", '4', '5', |
| 280 | "6", "7", true, false); |
| 281 | EXPECT_EQ("01234567TF", naggy_bar.str()); |
| 282 | |
| 283 | naggy_bar.This(); |
| 284 | naggy_bar.That(5, true); |
| 285 | } |
| 286 | |
| 287 | #if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE |
| 288 | // Tests that NaggyMock<Mock> compiles where Mock is a user-defined |
| 289 | // class (as opposed to ::testing::Mock). We had to work around an |
| 290 | // MSVC 8.0 bug that caused the symbol Mock used in the definition of |
| 291 | // NaggyMock to be looked up in the wrong context, and this test |
| 292 | // ensures that our fix works. |
| 293 | // |
| 294 | // We have to skip this test on Symbian and Windows Mobile, as it |
| 295 | // causes the program to crash there, for reasons unclear to us yet. |
| 296 | TEST(NaggyMockTest, AcceptsClassNamedMock) { |
| 297 | NaggyMock< ::Mock> naggy; |
| 298 | EXPECT_CALL(naggy, DoThis()); |
| 299 | naggy.DoThis(); |
| 300 | } |
| 301 | #endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE |
| 302 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 303 | // Tests that a strict mock allows expected calls. |
| 304 | TEST(StrictMockTest, AllowsExpectedCall) { |
| 305 | StrictMock<MockFoo> strict_foo; |
| 306 | |
| 307 | EXPECT_CALL(strict_foo, DoThis()); |
| 308 | strict_foo.DoThis(); |
| 309 | } |
| 310 | |
| 311 | // Tests that an unexpected call on a strict mock fails. |
| 312 | TEST(StrictMockTest, UnexpectedCallFails) { |
| 313 | StrictMock<MockFoo> strict_foo; |
| 314 | |
| 315 | EXPECT_CALL(strict_foo, DoThis()).Times(0); |
| 316 | EXPECT_NONFATAL_FAILURE(strict_foo.DoThis(), |
| 317 | "called more times than expected"); |
| 318 | } |
| 319 | |
| 320 | // Tests that an uninteresting call on a strict mock fails. |
| 321 | TEST(StrictMockTest, UninterestingCallFails) { |
| 322 | StrictMock<MockFoo> strict_foo; |
| 323 | |
| 324 | EXPECT_NONFATAL_FAILURE(strict_foo.DoThis(), |
| 325 | "Uninteresting mock function call"); |
| 326 | } |
| 327 | |
| 328 | // Tests that an uninteresting call on a strict mock fails, even if |
| 329 | // the call deletes the mock object. |
| 330 | TEST(StrictMockTest, UninterestingCallFailsAfterDeath) { |
| 331 | StrictMock<MockFoo>* const strict_foo = new StrictMock<MockFoo>; |
| 332 | |
| 333 | ON_CALL(*strict_foo, DoThis()) |
| 334 | .WillByDefault(Invoke(strict_foo, &MockFoo::Delete)); |
| 335 | |
| 336 | EXPECT_NONFATAL_FAILURE(strict_foo->DoThis(), |
| 337 | "Uninteresting mock function call"); |
| 338 | } |
| 339 | |
| 340 | // Tests that StrictMock works with a mock class that has a |
| 341 | // non-default constructor. |
| 342 | TEST(StrictMockTest, NonDefaultConstructor) { |
| 343 | StrictMock<MockBar> strict_bar("hi"); |
| 344 | EXPECT_EQ("hi", strict_bar.str()); |
| 345 | |
| 346 | EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true), |
| 347 | "Uninteresting mock function call"); |
| 348 | } |
| 349 | |
| 350 | // Tests that StrictMock works with a mock class that has a 10-ary |
| 351 | // non-default constructor. |
| 352 | TEST(StrictMockTest, NonDefaultConstructor10) { |
| 353 | StrictMock<MockBar> strict_bar('a', 'b', "c", "d", 'e', 'f', |
| 354 | "g", "h", true, false); |
| 355 | EXPECT_EQ("abcdefghTF", strict_bar.str()); |
| 356 | |
| 357 | EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true), |
| 358 | "Uninteresting mock function call"); |
| 359 | } |
| 360 | |
vladlosev | 6c54a5e | 2009-10-21 06:15:34 +0000 | [diff] [blame] | 361 | #if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 362 | // Tests that StrictMock<Mock> compiles where Mock is a user-defined |
zhanyong.wan | 844fa94 | 2013-03-01 01:54:22 +0000 | [diff] [blame^] | 363 | // class (as opposed to ::testing::Mock). We had to work around an |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 364 | // MSVC 8.0 bug that caused the symbol Mock used in the definition of |
| 365 | // StrictMock to be looked up in the wrong context, and this test |
| 366 | // ensures that our fix works. |
zhanyong.wan | 93244dc | 2009-09-17 19:11:00 +0000 | [diff] [blame] | 367 | // |
vladlosev | 6c54a5e | 2009-10-21 06:15:34 +0000 | [diff] [blame] | 368 | // We have to skip this test on Symbian and Windows Mobile, as it |
| 369 | // causes the program to crash there, for reasons unclear to us yet. |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 370 | TEST(StrictMockTest, AcceptsClassNamedMock) { |
zhanyong.wan | 93244dc | 2009-09-17 19:11:00 +0000 | [diff] [blame] | 371 | StrictMock< ::Mock> strict; |
| 372 | EXPECT_CALL(strict, DoThis()); |
| 373 | strict.DoThis(); |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 374 | } |
vladlosev | 6c54a5e | 2009-10-21 06:15:34 +0000 | [diff] [blame] | 375 | #endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE |
zhanyong.wan | 4bd79e4 | 2009-09-16 17:38:08 +0000 | [diff] [blame] | 376 | |
shiqian | e35fdd9 | 2008-12-10 05:08:54 +0000 | [diff] [blame] | 377 | } // namespace gmock_nice_strict_test |
| 378 | } // namespace testing |