forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathautoreleasepool_test.h
45 lines (33 loc) · 1.28 KB
/
autoreleasepool_test.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2013 The Flutter 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 FLUTTER_TESTING_AUTORELEASEPOOL_TEST_H_
#define FLUTTER_TESTING_AUTORELEASEPOOL_TEST_H_
#include "flutter/fml/platform/darwin/scoped_nsautorelease_pool.h"
#include "gtest/gtest.h"
namespace flutter::testing {
// GoogleTest mixin that runs the test within the scope of an NSAutoReleasePool.
//
// This can be mixed into test fixture classes that also inherit from gtest's
// ::testing::Test base class.
class AutoreleasePoolTestMixin {
public:
AutoreleasePoolTestMixin() = default;
~AutoreleasePoolTestMixin() = default;
private:
fml::ScopedNSAutoreleasePool autorelease_pool_;
FML_DISALLOW_COPY_AND_ASSIGN(AutoreleasePoolTestMixin);
};
// GoogleTest fixture that runs the test within the scope of an
// NSAutoReleasePool.
class AutoreleasePoolTest : public ::testing::Test,
public AutoreleasePoolTestMixin {
public:
AutoreleasePoolTest() = default;
~AutoreleasePoolTest() = default;
private:
fml::ScopedNSAutoreleasePool autorelease_pool_;
FML_DISALLOW_COPY_AND_ASSIGN(AutoreleasePoolTest);
};
} // namespace flutter::testing
#endif // FLUTTER_TESTING_AUTORELEASEPOOL_TEST_H_