Merge pull request #13447 from WenhaiLin/v3.8-refine-testcases

Test cases:improve small problems.
This commit is contained in:
子龙山人 2015-08-19 09:46:13 +08:00
commit e3c88533fe
3 changed files with 22 additions and 14 deletions

View File

@ -135,8 +135,8 @@ void TestList::addTest(const std::string& testName, std::function<TestBase*()> c
{
if (!testName.empty())
{
_childTestNames.push_back(testName);
_testCallbacks.push_back(callback);
_childTestNames.emplace_back(StringUtils::format("%d", static_cast<int>(_childTestNames.size() + 1)) + ":" + testName);
_testCallbacks.emplace_back(callback);
}
}
@ -193,7 +193,7 @@ void TestList::runThisTest()
auto autoTestItem = MenuItemLabel::create(autoTestLabel, [&](Ref* sender){
TestController::getInstance()->startAutoTest();
});
autoTestItem->setPosition(Vec2(VisibleRect::right().x - 70, VisibleRect::bottom().y + 25));
autoTestItem->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + 50));
auto menu = Menu::create(closeItem, autoTestItem, nullptr);
menu->setPosition(Vec2::ZERO);
@ -262,8 +262,8 @@ void TestSuite::addTestCase(const std::string& testName, std::function<Scene*()>
{
if (!testName.empty() && callback)
{
_childTestNames.push_back(testName);
_testCallbacks.push_back(callback);
_childTestNames.emplace_back(testName);
_testCallbacks.emplace_back(callback);
}
}
@ -432,14 +432,21 @@ void TestCase::onEnter()
{
Scene::onEnter();
_titleLabel->setString(title());
_subtitleLabel->setString(subtitle());
if (_testSuite == nullptr)
{
setTestSuite(TestController::getInstance()->getCurrTestSuite());
}
if (_testSuite)
{
_titleLabel->setString(StringUtils::format("%d", static_cast<int>(_testSuite->getCurrTestIndex() + 1)) + ":" + title());
}
else
{
_titleLabel->setString(title());
}
_subtitleLabel->setString(subtitle());
if (_testSuite && _testSuite->getChildTestCount() < 2)
{
_priorTestItem->setVisible(false);

View File

@ -162,6 +162,7 @@ public:
virtual void enterNextTest();
virtual void enterPreviousTest();
int getCurrTestIndex() { return _currTestIndex; }
virtual void runThisTest() override;
private:

View File

@ -1395,12 +1395,12 @@ function UITextFieldTest:initExtend()
if eventType == ccui.TextFiledEventType.attach_with_ime then
local textField = sender
local screenSize = cc.Director:getInstance():getWinSize()
textField:runAction(cc.MoveBy:create(0.225,cc.p(0, textField:getContentSize().height / 2.0)))
textField:runAction(cc.MoveBy:create(0.225,cc.p(0, 20)))
self._displayValueLabel:setString("attach with IME")
elseif eventType == ccui.TextFiledEventType.detach_with_ime then
local textField = sender
local screenSize = cc.Director:getInstance():getWinSize()
textField:runAction(cc.MoveBy:create(0.175, cc.p(0, textField:getContentSize().height / -2.0)))
textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20)))
self._displayValueLabel:setString("detach with IME")
elseif eventType == ccui.TextFiledEventType.insert_text then
self._displayValueLabel:setString("insert words")
@ -1465,13 +1465,13 @@ function UITextFieldMaxLengthTest:initExtend()
if eventType == ccui.TextFiledEventType.attach_with_ime then
local textField = sender
local screenSize = cc.Director:getInstance():getWinSize()
textField:runAction(cc.MoveTo:create(0.225,cc.p(screenSize.width / 2.0, screenSize.height / 2.0 + textField:getContentSize().height / 2.0)))
textField:runAction(cc.MoveBy:create(0.225,cc.p(0, 20)))
local info = string.format("attach with IME max length %d",textField:getMaxLength())
self._displayValueLabel:setString(info)
elseif eventType == ccui.TextFiledEventType.detach_with_ime then
local textField = sender
local screenSize = cc.Director:getInstance():getWinSize()
textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0)))
textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20)))
local info = string.format("detach with IME max length %d",textField:getMaxLength())
self._displayValueLabel:setString(info)
elseif eventType == ccui.TextFiledEventType.insert_text then
@ -1543,12 +1543,12 @@ function UITextFieldPasswordTest:initExtend()
if eventType == ccui.TextFiledEventType.attach_with_ime then
local textField = sender
local screenSize = cc.Director:getInstance():getWinSize()
textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0)))
textField:runAction(cc.MoveBy:create(0.175, cc.p(0, 20)))
self._displayValueLabel:setString("detach with IME password")
elseif eventType == ccui.TextFiledEventType.detach_with_ime then
local textField = sender
local screenSize = cc.Director:getInstance():getWinSize()
textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0)))
textField:runAction(cc.MoveBy:create(0.175, cc.p(0, -20)))
self._displayValueLabel:setString("detach with IME password")
elseif eventType == ccui.TextFiledEventType.insert_text then
self._displayValueLabel:setString("insert words password")