diff --git a/tests/cpp-tests/Classes/BaseTest.cpp b/tests/cpp-tests/Classes/BaseTest.cpp index 42a804dc4f..e37514fd62 100644 --- a/tests/cpp-tests/Classes/BaseTest.cpp +++ b/tests/cpp-tests/Classes/BaseTest.cpp @@ -135,8 +135,8 @@ void TestList::addTest(const std::string& testName, std::function c { if (!testName.empty()) { - _childTestNames.push_back(testName); - _testCallbacks.push_back(callback); + _childTestNames.emplace_back(StringUtils::format("%d", static_cast(_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 { 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(_testSuite->getCurrTestIndex() + 1)) + ":" + title()); + } + else + { + _titleLabel->setString(title()); + } + _subtitleLabel->setString(subtitle()); + if (_testSuite && _testSuite->getChildTestCount() < 2) { _priorTestItem->setVisible(false); diff --git a/tests/cpp-tests/Classes/BaseTest.h b/tests/cpp-tests/Classes/BaseTest.h index 4c8a1faac2..6a810e2c4c 100644 --- a/tests/cpp-tests/Classes/BaseTest.h +++ b/tests/cpp-tests/Classes/BaseTest.h @@ -162,6 +162,7 @@ public: virtual void enterNextTest(); virtual void enterPreviousTest(); + int getCurrTestIndex() { return _currTestIndex; } virtual void runThisTest() override; private: diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua index 46be6df7e0..e452ea92d6 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -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")