PuzzleSDK
NodeNameTest类 参考

#include <NodeTest.h>

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

Public 成员函数

 CREATE_FUNC (NodeNameTest)
 
virtual std::string title () const override
 
virtual std::string subtitle () const override
 
virtual void onEnter () override
 
virtual void onExit () override
 
void test (float dt)
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
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
 

额外继承的成员函数

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

详细描述

在文件 NodeTest.h321 行定义.

成员函数说明

◆ CREATE_FUNC()

NodeNameTest::CREATE_FUNC ( NodeNameTest  )

◆ onEnter()

void NodeNameTest::onEnter ( )
overridevirtual

重载 TestCase .

在文件 NodeTest.cpp1251 行定义.

1252{
1254
1255 this->scheduleOnce(CC_CALLBACK_1(NodeNameTest::test, this), 0.05f, "test_key");
1256}
void test(float dt)
Definition: NodeTest.cpp:1263
virtual void onEnter() override
Definition: BaseTest.cpp:430

引用了 TestCase::onEnter() , 以及 test().

+ 函数调用图:

◆ onExit()

void NodeNameTest::onExit ( )
overridevirtual

在文件 NodeTest.cpp1258 行定义.

1259{
1260 TestCocosNodeDemo::onExit();
1261}

◆ subtitle()

std::string NodeNameTest::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 NodeTest.cpp1246 行定义.

1247{
1248 return "see console";
1249}

◆ test()

void NodeNameTest::test ( float  dt)

在文件 NodeTest.cpp1263 行定义.

1264{
1265 auto parent = Node::create();
1266
1267 // setName(), getName() and getChildByName()
1268 char name[20];
1269 for (int i = 0; i < 10; ++i)
1270 {
1271 sprintf(name, "node%d", i);
1272 auto node = Node::create();
1273 node->setName(name);
1274 parent->addChild(node);
1275 }
1276
1277 for (int i = 0; i < 10; ++i)
1278 {
1279 sprintf(name, "node%d", i);
1280 auto node = parent->getChildByName(name);
1281 log("find child: %s", node->getName().c_str());
1282 }
1283
1284 // enumerateChildren()
1285 // name = regular expression
1286 int i = 0;
1287 parent = Node::create();
1288 for (int i = 0; i < 100; ++i)
1289 {
1290 auto node = Node::create();
1291 sprintf(name, "node%d", i);
1292 node->setName(name);
1293 parent->addChild(node);
1294 }
1295
1296 i = 0;
1297 parent->enumerateChildren("node[[:digit:]]+", [&i](Node* node) -> bool {
1298 ++i;
1299 return false;
1300 });
1301 CCAssert(i == 100, "");
1302
1303 i = 0;
1304 parent->enumerateChildren("node[[:digit:]]+", [&i](Node* node) -> bool {
1305 ++i;
1306 return true;
1307 });
1308 CCAssert(i == 1, "");
1309
1310 // enumerateChildren
1311 // name = node[[digit]]+/node
1312
1313 parent = Node::create();
1314 for (int i = 0; i < 10; ++i)
1315 {
1316 auto node = Node::create();
1317 sprintf(name, "node%d", i);
1318 node->setName(name);
1319 parent->addChild(node);
1320
1321 for (int j = 0; j < 10; ++j)
1322 {
1323 auto child = Node::create();
1324 child->setName("node");
1325 node->addChild(child);
1326 }
1327 }
1328
1329 i = 0;
1330 parent->enumerateChildren("node1/node", [&i](Node* node) -> bool {
1331 ++i;
1332 return false;
1333 });
1334 CCAssert(i == 10, "");
1335
1336 i = 0;
1337 parent->enumerateChildren("node1/node", [&i](Node* node) -> bool {
1338 ++i;
1339 return true;
1340 });
1341 CCAssert(i == 1, "");
1342
1343 // search from root
1344 parent = Node::create();
1345 for (int i = 0; i < 10; ++i)
1346 {
1347 auto node = Node::create();
1348 sprintf(name, "node%d", i);
1349 node->setName(name);
1350 parent->addChild(node);
1351
1352 for (int j = 0; j < 10; ++j)
1353 {
1354 auto child = Node::create();
1355 child->setName("node");
1356 node->addChild(child);
1357 }
1358 }
1359
1360 i = 0;
1361 parent->enumerateChildren("node[[:digit:]]+/node", [&i](Node* node) -> bool {
1362 ++i;
1363 return false;
1364 });
1365 CCAssert(i == 100, "");
1366
1367 i = 0;
1368 parent->enumerateChildren("node[[:digit:]]+/node", [&i](Node* node) -> bool {
1369 ++i;
1370 return true;
1371 });
1372 CCAssert(i == 1, "");
1373
1374 // search from parent
1375 // name is xxx/..
1376 i = 0;
1377 parent->getChildByName("node1")->enumerateChildren("node[[:digit:]]+/node/..", [&i](Node* node) -> bool {
1378 ++i;
1379 return true;
1380 });
1381 CCAssert(i == 1, "");
1382
1383 i = 0;
1384 parent->getChildByName("node1")->enumerateChildren("node[[:digit:]]+/node/..", [&i](Node* node) -> bool {
1385 ++i;
1386 return false;
1387 });
1388 CCAssert(i == 100, "");
1389
1390 // name = //xxx : search recursively
1391 parent = Node::create();
1392 for (int j = 0; j < 10; j++)
1393 {
1394 auto node = Node::create();
1395 sprintf(name, "node%d", j);
1396 node->setName(name);
1397 parent->addChild(node);
1398
1399 for (int k = 0; k < 10; ++k)
1400 {
1401 auto child = Node::create();
1402 sprintf(name, "node%d", k);
1403 child->setName(name);
1404 node->addChild(child);
1405 }
1406 }
1407
1408 i = 0;
1409 parent->enumerateChildren("//node[[:digit:]]+", [&i](Node* node) -> bool {
1410 ++i;
1411 return false;
1412 });
1413 CCAssert(i == 110, ""); // 100(children) + 10(parent)
1414
1415 i = 0;
1416 parent->enumerateChildren("//node[[:digit:]]+", [&i](Node* node) -> bool {
1417 ++i;
1418 return true;
1419 });
1420 CCAssert(i == 1, "");
1421
1422 i = 0;
1423 parent->getChildByName("node1")->enumerateChildren("//node[[:digit:]]+/..", [&i](Node* node) -> bool {
1424 ++i;
1425 return false;
1426 });
1427 CCAssert(i == 110, "");
1428
1429 // utils::findChildren()
1430
1431 parent = Node::create();
1432 for (int i = 0; i < 50; ++i)
1433 {
1434 auto child = Node::create();
1435 child->setName("node");
1436 parent->addChild(child);
1437 }
1438 auto findChildren = utils::findChildren(*parent, "node");
1439 CCAssert(findChildren.size() == 50, "");
1440}

被这些函数引用 onEnter().

+ 这是这个函数的调用关系图:

◆ title()

std::string NodeNameTest::title ( ) const
overridevirtual

重载 TestCocosNodeDemo .

在文件 NodeTest.cpp1241 行定义.

1242{
1243 return "getName()/setName()/getChildByName()/enumerateChildren()";
1244}

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