Move NSAutoreleasePool management into the PlatformTest constructor and
destructor. The pool operations are moving from SetUp and TearDown, which are scoped slightly too narrowly for our needs. Using the constructor and destructor ensures that the pools properly bracket tests. Review URL: http://codereview.chromium.org/174171 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23897 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -56,6 +56,11 @@
|
||||
'sources': [
|
||||
'platform_test_mac.mm'
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
|
||||
],
|
||||
},
|
||||
}],
|
||||
['OS == "mac" or OS == "linux"', {
|
||||
'defines': [
|
||||
|
@ -15,14 +15,14 @@ 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.
|
||||
// operations across unit tests. For example, on the Mac, it creates and
|
||||
// releases an outer NSAutoreleasePool for each test case. 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();
|
||||
PlatformTest();
|
||||
virtual ~PlatformTest();
|
||||
|
||||
private:
|
||||
NSAutoreleasePool* pool_;
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
void PlatformTest::SetUp() {
|
||||
pool_ = [[NSAutoreleasePool alloc] init];
|
||||
PlatformTest::PlatformTest()
|
||||
: pool_([[NSAutoreleasePool alloc] init]) {
|
||||
}
|
||||
|
||||
void PlatformTest::TearDown() {
|
||||
[pool_ drain];
|
||||
PlatformTest::~PlatformTest() {
|
||||
[pool_ release];
|
||||
}
|
||||
|
Reference in New Issue
Block a user