Test automation support: Fixed may not to restore TestList to the original position.

This commit is contained in:
WenhaiLin 2015-04-09 16:46:35 +08:00
parent f502c5900b
commit 8b839edfde
2 changed files with 4 additions and 2 deletions

View File

@ -128,6 +128,7 @@ protected:
TestList::TestList() TestList::TestList()
{ {
_isTestList = true; _isTestList = true;
_shouldRestoreTableOffset = false;
} }
void TestList::addTest(const std::string& testName, std::function<TestBase*()> callback) void TestList::addTest(const std::string& testName, std::function<TestBase*()> callback)
@ -156,7 +157,7 @@ void TestList::runThisTest()
scene->addChild(tableView); scene->addChild(tableView);
tableView->reloadData(); tableView->reloadData();
if (_tableOffset != Vec2::ZERO) if (_shouldRestoreTableOffset)
{ {
tableView->setContentOffset(_tableOffset); tableView->setContentOffset(_tableOffset);
} }
@ -217,7 +218,7 @@ void TestList::tableCellTouched(TableView* table, TableViewCell* cell)
if (test->getChildTestCount() > 0) if (test->getChildTestCount() > 0)
{ {
_tableOffset = table->getContentOffset(); _tableOffset = table->getContentOffset();
_shouldRestoreTableOffset = true;
_cellTouchEnabled = false; _cellTouchEnabled = false;
test->setTestParent(this); test->setTestParent(this);
test->runThisTest(); test->runThisTest();

View File

@ -195,6 +195,7 @@ public:
private: private:
std::vector<std::function<TestBase*()>> _testCallbacks; std::vector<std::function<TestBase*()>> _testCallbacks;
bool _cellTouchEnabled; bool _cellTouchEnabled;
bool _shouldRestoreTableOffset;
cocos2d::Vec2 _tableOffset; cocos2d::Vec2 _tableOffset;
friend class TestController; friend class TestController;
}; };