PuzzleSDK
ReleasePoolTest类 参考

#include <ReleasePoolTest.h>

+ 类 ReleasePoolTest 继承关系图:
+ ReleasePoolTest 的协作图:

Public 成员函数

 CREATE_FUNC (ReleasePoolTest)
 
virtual bool init () override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string title () const
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 ReleasePoolTest.h34 行定义.

成员函数说明

◆ CREATE_FUNC()

ReleasePoolTest::CREATE_FUNC ( ReleasePoolTest  )

◆ init()

bool ReleasePoolTest::init ( )
overridevirtual

在文件 ReleasePoolTest.cpp54 行定义.

55{
56 if (!TestCase::init())
57 {
58 return false;
59 }
60 // title
61 auto label = Label::createWithTTF("AutoreasePool Test", "fonts/arial.ttf", 32);
62 addChild(label, 9999);
63 label->setPosition(Vec2(VisibleRect::center().x, VisibleRect::top().y - 30));
64
65 // reference count should be added when added into auto release pool
66
67 TestObject *obj = new (std::nothrow) TestObject("testobj");
68 obj->autorelease();
69 assert(obj->getReferenceCount() == 1);
70
71 // should retain first before invoking autorelease
72 obj->retain();
73 obj->autorelease();
74 assert(obj->getReferenceCount() == 2);
75
76 // create an autorelease pool in stack
77
78 {
79 AutoreleasePool pool1;
80
81 // can invoke autorelease more than once
82 obj->retain();
83 obj->autorelease();
84 assert(obj->getReferenceCount() == 3);
85 obj->retain();
86 obj->autorelease();
87 assert(obj->getReferenceCount() == 4);
88
89 // retain, release can work together with autorelease pool
90 obj->retain();
91 assert(obj->getReferenceCount() == 5);
92 obj->release();
93 assert(obj->getReferenceCount() == 4);
94 }
95
96 assert(obj->getReferenceCount() == 2);
97
98 // example of using temple autorelease pool
99 {
100 AutoreleasePool pool2;
101 char name[20];
102 for (int i = 0; i < 100; ++i)
103 {
104 snprintf(name, 20, "object%d", i);
105 TestObject *tmpObj = new (std::nothrow) TestObject(name);
106 tmpObj->autorelease();
107 }
108 }
109
110 // object in pool2 should be released
111
112 {
113 new AutoreleasePool;
114 PoolManager::destroyInstance();
115 }
116
117 return true;
118}
static cocos2d::Vec2 top()
Definition: VisibleRect.cpp:57
static cocos2d::Vec2 center()
Definition: VisibleRect.cpp:69

引用了 VisibleRect::center() , 以及 VisibleRect::top().

+ 函数调用图:

该类的文档由以下文件生成: