5#include "flutter/fml/message_loop.h"
6#include "flutter/fml/platform/darwin/scoped_nsobject.h"
7#include "flutter/fml/platform/darwin/weak_nsobject.h"
8#include "flutter/fml/task_runner.h"
9#include "flutter/fml/thread.h"
10#include "gtest/gtest.h"
12#if !defined(__has_feature) || !__has_feature(objc_arc)
13#error "This file requires ARC support."
19TEST(WeakNSObjectTestARC, WeakNSObject) {
20 scoped_nsobject<NSObject> p1;
21 WeakNSObject<NSObject> w1;
23 p1.reset(([[NSObject alloc]
init]));
24 WeakNSObjectFactory factory(p1.get());
25 w1 = factory.GetWeakNSObject();
32TEST(WeakNSObjectTestARC, MultipleWeakNSObject) {
33 scoped_nsobject<NSObject> p1;
34 WeakNSObject<NSObject> w1;
35 WeakNSObject<NSObject> w2;
37 p1.reset([[NSObject alloc]
init]);
38 WeakNSObjectFactory factory(p1.get());
39 w1 = factory.GetWeakNSObject();
51TEST(WeakNSObjectTestARC, WeakNSObjectDies) {
52 scoped_nsobject<NSObject> p1([[NSObject alloc]
init]);
53 WeakNSObjectFactory factory(p1.get());
55 WeakNSObject<NSObject> w1 = factory.GetWeakNSObject();
60TEST(WeakNSObjectTestARC, WeakNSObjectReset) {
61 scoped_nsobject<NSObject> p1([[NSObject alloc]
init]);
62 WeakNSObjectFactory factory(p1.get());
63 WeakNSObject<NSObject> w1 = factory.GetWeakNSObject();
71TEST(WeakNSObjectTestARC, WeakNSObjectEmpty) {
72 scoped_nsobject<NSObject> p1;
73 WeakNSObject<NSObject> w1;
75 scoped_nsobject<NSObject> p1([[NSObject alloc]
init]);
77 WeakNSObjectFactory factory(p1.get());
78 w1 = factory.GetWeakNSObject();
85TEST(WeakNSObjectTestARC, WeakNSObjectCopy) {
86 scoped_nsobject<NSObject> p1;
87 WeakNSObject<NSObject> w1;
88 WeakNSObject<NSObject> w2;
90 scoped_nsobject<NSObject> p1([[NSObject alloc]
init]);
91 WeakNSObjectFactory factory(p1.get());
92 w1 = factory.GetWeakNSObject();
103TEST(WeakNSObjectTestARC, WeakNSObjectAssignment) {
104 scoped_nsobject<NSObject> p1;
105 WeakNSObject<NSObject> w1;
106 WeakNSObject<NSObject> w2;
108 scoped_nsobject<NSObject> p1([[NSObject alloc]
init]);
109 WeakNSObjectFactory factory(p1.get());
110 w1 = factory.GetWeakNSObject();
TEST(MallocMapping, EmptyContructor)
#define EXPECT_TRUE(handle)