summaryrefslogtreecommitdiffstats
path: root/third_party/ocmock/gtest_support.h
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-17 21:09:35 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-17 21:09:35 +0000
commitbd7df6c0301c51904321d90bceb01be475a4c8de (patch)
tree2fb73fb2f41126476dc5f7d7cf0ae359ec30a276 /third_party/ocmock/gtest_support.h
parenta2db976170e467343b8a49a1c8f9453188a1b735 (diff)
downloadchromium_src-bd7df6c0301c51904321d90bceb01be475a4c8de.zip
chromium_src-bd7df6c0301c51904321d90bceb01be475a4c8de.tar.gz
chromium_src-bd7df6c0301c51904321d90bceb01be475a4c8de.tar.bz2
Support for better integration between OCMock and gtest.
- Add a chromium method that will use OCMock's verify support, but add any failure to the gtest failure log and return something that can be asserted in the test. - Update the code using OCMock -verify to use the new util. - Remove the OCMock includes in files that weren't actually using it. TEST=none BUG=none Review URL: http://codereview.chromium.org/7031014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85676 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/ocmock/gtest_support.h')
-rw-r--r--third_party/ocmock/gtest_support.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/third_party/ocmock/gtest_support.h b/third_party/ocmock/gtest_support.h
new file mode 100644
index 0000000..07c3e8c
--- /dev/null
+++ b/third_party/ocmock/gtest_support.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2011 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.
+
+#ifndef THIRD_PARTY_OCMOCK_GTEST_SUPPORT_H_
+#define THIRD_PARTY_OCMOCK_GTEST_SUPPORT_H_
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+@class OCMockObject;
+
+namespace testing {
+namespace internal {
+bool VerifyOCMock(OCMockObject* mock, const char* file, int line);
+} // namespace mac
+} // namespace testing
+
+// Calls -verify of the mock and traps the Objective-C exception that is
+// generated, adding it to the gtest failures and returning true/false
+// for if there was an exception. The result should be used in normal
+// gtest EXECPT_TRUE/ASSERT_TRUE fashion.
+//
+// So code that would do:
+//
+// id mockFoo = [OCMockObject mockForClass:[Foo class]];
+// ...
+// [mockFoo verify];
+//
+// Should instead do:
+//
+// id mockFoo = [OCMockObject mockForClass:[Foo class]];
+// ...
+// EXPECT_OCMOCK_VERIFY(mockFoo);
+//
+#define EXPECT_OCMOCK_VERIFY(m) \
+ EXPECT_TRUE(testing::internal::VerifyOCMock((m), __FILE__, __LINE__))
+#define ASSERT_OCMOCK_VERIFY(m) \
+ ASSERT_TRUE(testing::internal::VerifyOCMock((m), __FILE__, __LINE__))
+
+#endif // THIRD_PARTY_OCMOCK_GTEST_SUPPORT_H_