diff options
-rw-r--r-- | testing/coverage_util_ios.cc | 15 | ||||
-rw-r--r-- | testing/coverage_util_ios.h | 17 | ||||
-rw-r--r-- | testing/gtest.gyp | 11 | ||||
-rw-r--r-- | testing/platform_test_ios.mm | 18 |
4 files changed, 60 insertions, 1 deletions
diff --git a/testing/coverage_util_ios.cc b/testing/coverage_util_ios.cc new file mode 100644 index 0000000..15ac1b4 --- /dev/null +++ b/testing/coverage_util_ios.cc @@ -0,0 +1,15 @@ +// Copyright 2014 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. + +extern "C" void __gcov_flush(); + +namespace coverage_util { + +void FlushCoverageDataIfNecessary() { +#if defined(ENABLE_TEST_CODE_COVERAGE) + __gcov_flush(); +#endif +} + +} // namespace coverage_util diff --git a/testing/coverage_util_ios.h b/testing/coverage_util_ios.h new file mode 100644 index 0000000..702811a --- /dev/null +++ b/testing/coverage_util_ios.h @@ -0,0 +1,17 @@ +// Copyright 2014 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_COVERAGE_UTIL_IOS_H_ +#define TESTING_COVERAGE_UTIL_IOS_H_ + +namespace coverage_util { + +// Flushes .gcda coverage files if ENABLE_TEST_CODE_COVERAGE is defined. iOS 7 +// does not call any code at the "end" of an app so flushing should be +// performed manually. +void FlushCoverageDataIfNecessary(); + +} // namespace coverage_util + +#endif // TESTING_COVERAGE_UTIL_IOS_H_ diff --git a/testing/gtest.gyp b/testing/gtest.gyp index 69b2bf5..e2dc66a 100644 --- a/testing/gtest.gyp +++ b/testing/gtest.gyp @@ -66,7 +66,6 @@ 'sources': [ 'gtest_mac.h', 'gtest_mac.mm', - 'platform_test_mac.mm' ], 'link_settings': { 'libraries': [ @@ -74,6 +73,11 @@ ], }, }], + ['OS == "mac"', { + 'sources': [ + 'platform_test_mac.mm', + ], + }], ['OS == "ios"', { 'dependencies' : [ '<(DEPTH)/testing/iossim/iossim.gyp:iossim#host', @@ -105,6 +109,11 @@ }], ], }, + 'sources': [ + 'coverage_util_ios.cc', + 'coverage_util_ios.h', + 'platform_test_ios.mm', + ], }], ['OS=="ios" and asan==1', { 'direct_dependent_settings': { diff --git a/testing/platform_test_ios.mm b/testing/platform_test_ios.mm new file mode 100644 index 0000000..5162c1d --- /dev/null +++ b/testing/platform_test_ios.mm @@ -0,0 +1,18 @@ +// Copyright 2014 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> + +#include "coverage_util_ios.h" + +PlatformTest::PlatformTest() + : pool_([[NSAutoreleasePool alloc] init]) { +} + +PlatformTest::~PlatformTest() { + [pool_ release]; + coverage_util::FlushCoverageDataIfNecessary(); +} |