platform_test.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef TESTING_PLATFORM_TEST_H_
  5. #define TESTING_PLATFORM_TEST_H_
  6. #include <gtest/gtest.h>
  7. #if defined(GTEST_OS_MAC)
  8. #include <objc/objc.h>
  9. // The purpose of this class us to provide a hook for platform-specific
  10. // operations across unit tests. For example, on the Mac, it creates and
  11. // releases an outer NSAutoreleasePool for each test case. For now, it's only
  12. // implemented on the Mac. To enable this for another platform, just adjust
  13. // the #ifdefs and add a platform_test_<platform>.cc implementation file.
  14. class PlatformTest : public testing::Test {
  15. public:
  16. ~PlatformTest() override;
  17. protected:
  18. PlatformTest();
  19. private:
  20. // |pool_| is a NSAutoreleasePool, but since this header may be imported from
  21. // files built with Objective-C ARC that forbids explicit usage of
  22. // NSAutoreleasePools, it is declared as id here.
  23. id pool_;
  24. };
  25. #else
  26. typedef testing::Test PlatformTest;
  27. #endif // GTEST_OS_MAC
  28. #endif // TESTING_PLATFORM_TEST_H_