7#include "flutter/fml/platform/darwin/scoped_nsautorelease_pool.h"
8#include "flutter/fml/platform/darwin/scoped_nsobject.h"
9#include "gtest/gtest.h"
17void IS_INITIALIZED(
T&) {}
19TEST(ScopedNSObjectTest, ScopedNSObject) {
21 ASSERT_TRUE(p1.get());
22 ASSERT_EQ(1u, [p1 retainCount]);
24 ASSERT_EQ(p1.get(), p2.get());
25 ASSERT_EQ(2u, [p1 retainCount]);
27 ASSERT_EQ(nil, p2.get());
28 ASSERT_EQ(1u, [p1 retainCount]);
31 ASSERT_EQ(p1.get(), p3.
get());
32 ASSERT_EQ(2u, [p1 retainCount]);
34 ASSERT_EQ(p1.get(), p3.
get());
35 ASSERT_EQ(2u, [p1 retainCount]);
37 ASSERT_EQ(1u, [p1 retainCount]);
39 ASSERT_EQ(2u, [p1 retainCount]);
40 ASSERT_TRUE(p1 == p1.get());
41 ASSERT_TRUE(p1 == p1);
42 ASSERT_FALSE(p1 != p1);
43 ASSERT_FALSE(p1 != p1.get());
45 ASSERT_TRUE(p1 != p5);
46 ASSERT_TRUE(p1 != p5.get());
47 ASSERT_FALSE(p1 == p5);
48 ASSERT_FALSE(p1 == p5.get());
51 ASSERT_EQ(3u, [p6 retainCount]);
55 ASSERT_EQ(nil, p6.
get());
56 ASSERT_EQ(3u, [p1 retainCount]);
58 ASSERT_EQ(2u, [p1 retainCount]);
63 ASSERT_EQ(1u, [p8 retainCount]);
65 ASSERT_FALSE(p7.get());
71TEST(ScopedNSObjectTest, FailToCreateScopedNSObjectAutoreleasePool) {
76TEST(ScopedNSObjectTest, ScopedNSObjectInContainer) {
79 ASSERT_EQ(1u, [
p retainCount]);
81 std::vector<fml::scoped_nsobject<id>> objects;
83 ASSERT_EQ(2u, [
p retainCount]);
84 ASSERT_EQ(
p.get(), objects[0].get());
86 ASSERT_TRUE(objects[1].
get());
87 ASSERT_EQ(1u, [objects[1] retainCount]);
89 ASSERT_EQ(1u, [
p retainCount]);
92TEST(ScopedNSObjectTest, ScopedNSObjectFreeFunctions) {
95 ASSERT_TRUE(o1 == p1);
96 ASSERT_FALSE(o1 != p1);
98 ASSERT_TRUE(o1 != p2);
99 ASSERT_FALSE(o1 == p2);
102 ASSERT_EQ(o2, p1.get());
103 ASSERT_EQ(o1, p2.get());
#define TEST(S, s, D, expected)
void swap(sk_sp< T > &a, sk_sp< T > &b)
T get() const __attribute((ns_returns_not_retained))
NST autorelease() __attribute((ns_returns_not_retained))
const myers::Point & get(const myers::Segment &)