PuzzleSDK
TestList类 参考

#include <BaseTest.h>

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

Public 成员函数

 TestList ()
 
void addTest (const std::string &testName, std::function< TestBase *()> callback)
 
virtual void runThisTest () override
 
virtual void tableCellTouched (cocos2d::extension::TableView *table, cocos2d::extension::TableViewCell *cell) override
 
virtual cocos2d::extension::TableViewCell * tableCellAtIndex (cocos2d::extension::TableView *table, ssize_t idx) override
 
virtual cocos2d::Size tableCellSizeForIndex (cocos2d::extension::TableView *table, ssize_t idx) override
 
virtual ssize_t numberOfCellsInTableView (cocos2d::extension::TableView *table) override
 
virtual void scrollViewDidScroll (cocos2d::extension::ScrollView *view) override
 
virtual void scrollViewDidZoom (cocos2d::extension::ScrollView *view) override
 
- Public 成员函数 继承自 TestBase
virtual ~TestBase ()
 
void backsUpOneLevel ()
 
bool isTestList ()
 
ssize_t getChildTestCount ()
 
void setTestParent (TestBase *parent)
 
TestBasegetTestParent ()
 
void setTestName (const std::string &testName)
 
std::string getTestName () const
 

Private 属性

std::vector< std::function< TestBase *()> > _testCallbacks
 
bool _cellTouchEnabled
 
bool _shouldRestoreTableOffset
 
cocos2d::Vec2 _tableOffset
 

友元

class TestController
 

额外继承的成员函数

- Protected 成员函数 继承自 TestBase
 TestBase ()
 
- Protected 属性 继承自 TestBase
std::string _testName
 
TestBase_parentTest
 
bool _isTestList
 
std::vector< std::string > _childTestNames
 

详细描述

An instance of TestList is a means for displaying hierarchical lists of TestSuite.

在文件 BaseTest.h182 行定义.

构造及析构函数说明

◆ TestList()

TestList::TestList ( )

在文件 BaseTest.cpp129 行定义.

130{
131 _isTestList = true;
133}
bool _isTestList
Definition: BaseTest.h:150
bool _shouldRestoreTableOffset
Definition: BaseTest.h:203

引用了 TestBase::_isTestList , 以及 _shouldRestoreTableOffset.

成员函数说明

◆ addTest()

void TestList::addTest ( const std::string &  testName,
std::function< TestBase *()>  callback 
)

在文件 BaseTest.cpp135 行定义.

136{
137 if (!testName.empty())
138 {
139 _childTestNames.emplace_back(StringUtils::format("%d", static_cast<int>(_childTestNames.size() + 1)) + ":" + testName);
140 _testCallbacks.emplace_back(callback);
141 }
142}
std::vector< std::string > _childTestNames
Definition: BaseTest.h:151
std::vector< std::function< TestBase *()> > _testCallbacks
Definition: BaseTest.h:201

引用了 TestBase::_childTestNames , 以及 _testCallbacks.

被这些函数引用 RootTests::RootTests() , 以及 UITests::UITests().

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

◆ numberOfCellsInTableView()

ssize_t TestList::numberOfCellsInTableView ( cocos2d::extension::TableView *  table)
overridevirtual

在文件 BaseTest.cpp253 行定义.

254{
255 return _childTestNames.size();
256}

引用了 TestBase::_childTestNames.

◆ runThisTest()

void TestList::runThisTest ( )
overridevirtual

重载 TestBase .

在文件 BaseTest.cpp144 行定义.

145{
146 _cellTouchEnabled = true;
147 auto director = Director::getInstance();
148 auto scene = Scene::create();
149
150 auto visibleSize = director->getVisibleSize();
151 auto origin = director->getVisibleOrigin();
152
153 auto tableView = TestCustomTableView::create(this, Size(400, visibleSize.height));
154 tableView->setPosition(origin.x + (visibleSize.width - 400) / 2, origin.y);
155 tableView->setDirection(ScrollView::Direction::VERTICAL);
156 tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
157 tableView->setDelegate(this);
158 scene->addChild(tableView);
159 tableView->reloadData();
160
162 {
163 tableView->setContentOffset(_tableOffset);
164 }
165
166 if (_parentTest)
167 {
168 //Add back button.
169 TTFConfig ttfConfig("fonts/arial.ttf", 20);
170 auto label = Label::createWithTTF(ttfConfig, "Back");
171
172 auto menuItem = MenuItemLabel::create(label, std::bind(&TestBase::backsUpOneLevel, this));
173 auto menu = Menu::create(menuItem, nullptr);
174
175 menu->setPosition(Vec2::ZERO);
176 menuItem->setPosition(Vec2(VisibleRect::right().x - 50, VisibleRect::bottom().y + 25));
177
178 scene->addChild(menu, 1);
179 }
180 else
181 {
182 //Add close and "Start AutoTest" button.
183 auto closeItem = MenuItemImage::create(s_pathClose, s_pathClose, [](Ref* sender){
186 Director::getInstance()->end();
187 });
188 closeItem->setPosition(VisibleRect::right().x - 30, VisibleRect::top().y - 30);
189
190 auto autoTestLabel = Label::createWithTTF("Start AutoTest","fonts/arial.ttf",16);
191 auto autoTestItem = MenuItemLabel::create(autoTestLabel, [&](Ref* sender){
193 });
194 autoTestItem->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + 50));
195
196 auto menu = Menu::create(closeItem, autoTestItem, nullptr);
197 menu->setPosition(Vec2::ZERO);
198 scene->addChild(menu, 1);
199 }
200
201 director->replaceScene(scene);
202}
void backsUpOneLevel()
Definition: BaseTest.cpp:47
TestBase * _parentTest
Definition: BaseTest.h:149
void startAutoTest()
Definition: controller.cpp:157
static void destroyInstance()
Definition: controller.cpp:470
void stopAutoTest()
Definition: controller.cpp:168
static TestController * getInstance()
Definition: controller.cpp:458
static TestCustomTableView * create(TableViewDataSource *dataSource, Size size)
Definition: BaseTest.cpp:60
cocos2d::Vec2 _tableOffset
Definition: BaseTest.h:204
bool _cellTouchEnabled
Definition: BaseTest.h:202
static cocos2d::Vec2 top()
Definition: VisibleRect.cpp:57
static cocos2d::Vec2 bottom()
Definition: VisibleRect.cpp:63
static cocos2d::Vec2 left()
Definition: VisibleRect.cpp:45
static cocos2d::Vec2 right()
Definition: VisibleRect.cpp:51
static const char s_pathClose[]
Definition: testResource.h:55

引用了 _cellTouchEnabled, TestBase::_parentTest, _shouldRestoreTableOffset, _tableOffset, TestBase::backsUpOneLevel(), VisibleRect::bottom(), TestCustomTableView::create(), TestController::destroyInstance(), TestController::getInstance(), VisibleRect::left(), VisibleRect::right(), s_pathClose, TestController::startAutoTest(), TestController::stopAutoTest() , 以及 VisibleRect::top().

被这些函数引用 TestController::TestController().

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

◆ scrollViewDidScroll()

virtual void TestList::scrollViewDidScroll ( cocos2d::extension::ScrollView *  view)
inlineoverridevirtual

在文件 BaseTest.h197 行定义.

197{}

◆ scrollViewDidZoom()

virtual void TestList::scrollViewDidZoom ( cocos2d::extension::ScrollView *  view)
inlineoverridevirtual

在文件 BaseTest.h198 行定义.

198{}

◆ tableCellAtIndex()

TableViewCell * TestList::tableCellAtIndex ( cocos2d::extension::TableView *  table,
ssize_t  idx 
)
overridevirtual

在文件 BaseTest.cpp228 行定义.

229{
230 auto cell = table->dequeueCell();
231 if (!cell)
232 {
233 cell = TableViewCell::create();
234 auto label = Label::createWithTTF(_childTestNames[idx], "fonts/arial.ttf", 20.0f);
235 label->setTag(TABEL_LABEL_TAG);
236 label->setPosition(200, 15);
237 cell->addChild(label);
238 }
239 else
240 {
241 auto label = (Label*)cell->getChildByTag(TABEL_LABEL_TAG);
242 label->setString(_childTestNames[idx]);
243 }
244
245 return cell;
246}
#define TABEL_LABEL_TAG
Definition: BaseTest.cpp:33

引用了 TestBase::_childTestNames , 以及 TABEL_LABEL_TAG.

◆ tableCellSizeForIndex()

Size TestList::tableCellSizeForIndex ( cocos2d::extension::TableView *  table,
ssize_t  idx 
)
overridevirtual

在文件 BaseTest.cpp248 行定义.

249{
250 return Size(400, 30);
251}

◆ tableCellTouched()

void TestList::tableCellTouched ( cocos2d::extension::TableView *  table,
cocos2d::extension::TableViewCell *  cell 
)
overridevirtual

在文件 BaseTest.cpp204 行定义.

205{
207 {
208 auto index = cell->getIdx();
209 if (_testCallbacks[index])
210 {
211 auto test = _testCallbacks[index]();
212 if (test->getChildTestCount() > 0)
213 {
214 _tableOffset = table->getContentOffset();
216 _cellTouchEnabled = false;
217 test->setTestParent(this);
218 test->runThisTest();
219 }
220 else
221 {
222 delete test;
223 }
224 }
225 }
226}

引用了 _cellTouchEnabled, _shouldRestoreTableOffset, _tableOffset , 以及 _testCallbacks.

友元及相关函数文档

◆ TestController

friend class TestController
friend

在文件 BaseTest.h205 行定义.

类成员变量说明

◆ _cellTouchEnabled

bool TestList::_cellTouchEnabled
private

在文件 BaseTest.h202 行定义.

被这些函数引用 runThisTest() , 以及 tableCellTouched().

◆ _shouldRestoreTableOffset

bool TestList::_shouldRestoreTableOffset
private

在文件 BaseTest.h203 行定义.

被这些函数引用 runThisTest(), tableCellTouched() , 以及 TestList().

◆ _tableOffset

cocos2d::Vec2 TestList::_tableOffset
private

在文件 BaseTest.h204 行定义.

被这些函数引用 runThisTest() , 以及 tableCellTouched().

◆ _testCallbacks

std::vector<std::function<TestBase*()> > TestList::_testCallbacks
private

在文件 BaseTest.h201 行定义.

被这些函数引用 addTest(), tableCellTouched() , 以及 TestController::traverseTestList().


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