diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-02 19:20:15 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-02 19:20:15 +0000 |
commit | 23887f04fbf1ddadadea709206b265a3def2eb3a (patch) | |
tree | b93cf25e8cc66180137fea6c5aad4148ec70fd58 /testing | |
parent | 07c3f84910a6bc63a69d5f7fe0725090cf2af1ce (diff) | |
download | chromium_src-23887f04fbf1ddadadea709206b265a3def2eb3a.zip chromium_src-23887f04fbf1ddadadea709206b265a3def2eb3a.tar.gz chromium_src-23887f04fbf1ddadadea709206b265a3def2eb3a.tar.bz2 |
* Cleanup: move base/platform_test.h -> testing/
* Add support for "Debug On Start" switch to MultiprocessTest::SpawnChild
Review URL: http://codereview.chromium.org/13052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'testing')
-rw-r--r-- | testing/gtest.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | testing/platform_test.h | 36 | ||||
-rw-r--r-- | testing/platform_test_mac.mm | 15 |
3 files changed, 57 insertions, 0 deletions
diff --git a/testing/gtest.xcodeproj/project.pbxproj b/testing/gtest.xcodeproj/project.pbxproj index 9498879..809d6c7 100644 --- a/testing/gtest.xcodeproj/project.pbxproj +++ b/testing/gtest.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ B593AFF90EB7D41B00B72887 /* multiprocess_func_list.cc in Sources */ = {isa = PBXBuildFile; fileRef = B593AFF70EB7D41B00B72887 /* multiprocess_func_list.cc */; }; + B5E5A6A00EE4BCCA007808DF /* platform_test_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5E5A69F0EE4BCCA007808DF /* platform_test_mac.mm */; }; E45A2BBC0E47A20200DB1196 /* gtest_main.cc in Sources */ = {isa = PBXBuildFile; fileRef = E45A2BB60E47A20200DB1196 /* gtest_main.cc */; }; E45A2BBD0E47A20200DB1196 /* gtest-death-test.cc in Sources */ = {isa = PBXBuildFile; fileRef = E45A2BB70E47A20200DB1196 /* gtest-death-test.cc */; }; E45A2BBE0E47A20200DB1196 /* gtest-filepath.cc in Sources */ = {isa = PBXBuildFile; fileRef = E45A2BB80E47A20200DB1196 /* gtest-filepath.cc */; }; @@ -23,6 +24,8 @@ 7BED30E00E59F69A00A747DB /* staticlib.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = staticlib.xcconfig; sourceTree = "<group>"; }; B593AFF70EB7D41B00B72887 /* multiprocess_func_list.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = multiprocess_func_list.cc; sourceTree = SOURCE_ROOT; }; B593AFF80EB7D41B00B72887 /* multiprocess_func_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = multiprocess_func_list.h; sourceTree = SOURCE_ROOT; }; + B5E5A69E0EE4BCCA007808DF /* platform_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform_test.h; sourceTree = SOURCE_ROOT; }; + B5E5A69F0EE4BCCA007808DF /* platform_test_mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = platform_test_mac.mm; sourceTree = SOURCE_ROOT; }; D2AAC046055464E500DB518D /* libgtest.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; }; E45A2BB60E47A20200DB1196 /* gtest_main.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gtest_main.cc; sourceTree = "<group>"; }; E45A2BB70E47A20200DB1196 /* gtest-death-test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "gtest-death-test.cc"; sourceTree = "<group>"; }; @@ -64,6 +67,8 @@ E45A2BB60E47A20200DB1196 /* gtest_main.cc */, B593AFF70EB7D41B00B72887 /* multiprocess_func_list.cc */, B593AFF80EB7D41B00B72887 /* multiprocess_func_list.h */, + B5E5A69E0EE4BCCA007808DF /* platform_test.h */, + B5E5A69F0EE4BCCA007808DF /* platform_test_mac.mm */, ); name = Source; path = gtest/src; @@ -137,6 +142,7 @@ E45A2BC10E47A20200DB1196 /* gtest.cc in Sources */, E45A2BBC0E47A20200DB1196 /* gtest_main.cc in Sources */, B593AFF90EB7D41B00B72887 /* multiprocess_func_list.cc in Sources */, + B5E5A6A00EE4BCCA007808DF /* platform_test_mac.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/testing/platform_test.h b/testing/platform_test.h new file mode 100644 index 0000000..6e5e039 --- /dev/null +++ b/testing/platform_test.h @@ -0,0 +1,36 @@ +// Copyright (c) 2006-2008 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 TESTING_PLATFORM_TEST_H_ +#define TESTING_PLATFORM_TEST_H_ + +#include <gtest/gtest.h> + +#if defined(GTEST_OS_MAC) +#ifdef __OBJC__ +@class NSAutoreleasePool; +#else +class NSAutoreleasePool; +#endif + +// The purpose of this class us to provide a hook for platform-specific +// SetUp and TearDown across unit tests. For example, on the Mac, it +// creates and releases an outer AutoreleasePool for each test. For now, it's +// only implemented on the Mac. To enable this for another platform, just +// adjust the #ifdefs and add a platform_test_<platform>.cc implementation file. +class PlatformTest : public testing::Test { + protected: + virtual void SetUp(); + virtual void TearDown(); + + private: + NSAutoreleasePool* pool_; +}; +#else +typedef testing::Test PlatformTest; +#endif // GTEST_OS_MAC + +#endif // TESTING_PLATFORM_TEST_H_ + + diff --git a/testing/platform_test_mac.mm b/testing/platform_test_mac.mm new file mode 100644 index 0000000..e4aaeab --- /dev/null +++ b/testing/platform_test_mac.mm @@ -0,0 +1,15 @@ +// Copyright (c) 2006-2008 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. + +#include "platform_test.h" + +#import <Foundation/Foundation.h> + +void PlatformTest::SetUp() { + pool_ = [[NSAutoreleasePool alloc] init]; +} + +void PlatformTest::TearDown() { + [pool_ drain]; +} |