enable tests (#19702)

This commit is contained in:
Arnold 2019-05-14 09:00:27 +08:00 committed by minggo
parent 3d314f29ea
commit e52a35708e
5 changed files with 196 additions and 223 deletions

View File

@ -94,7 +94,6 @@ list(APPEND GAME_HEADER
Classes/LabelTest/LabelTestNew.h
# Classes/LabelTest/LabelTest.h
Classes/Particle3DTest/Particle3DTest.h
# Classes/AllocatorTest/AllocatorTest.h
Classes/VibrateTest/VibrateTest.h
Classes/ClippingNodeTest/ClippingNodeTest.h
Classes/UserDefaultTest/UserDefaultTest.h
@ -214,7 +213,6 @@ list(APPEND GAME_SOURCE
Classes/ActionsEaseTest/ActionsEaseTest.cpp
Classes/ActionsProgressTest/ActionsProgressTest.cpp
Classes/ActionsTest/ActionsTest.cpp
# Classes/AllocatorTest/AllocatorTest.cpp
Classes/AppDelegate.cpp
Classes/BaseTest.cpp
Classes/BillBoardTest/BillBoardTest.cpp

View File

@ -1,43 +0,0 @@
#pragma once
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "../BaseTest.h"
#include "base/allocator/CCAllocatorStrategyPool.h"
DEFINE_TEST_SUITE(AllocatorTests);
class AllocatorTest : public TestCase
{
public:
CREATE_FUNC(AllocatorTest);
AllocatorTest();
virtual ~AllocatorTest();
virtual std::string title() const override;
};

View File

@ -39,8 +39,8 @@ NewRendererTests::NewRendererTests()
ADD_TEST_CASE(CaptureNodeTest);
ADD_TEST_CASE(BugAutoCulling);
ADD_TEST_CASE(RendererBatchQuadTri);
// ADD_TEST_CASE(RendererUniformBatch); // TODO shouldn't call OpenGL API directly
// ADD_TEST_CASE(RendererUniformBatch2);
ADD_TEST_CASE(RendererUniformBatch);
ADD_TEST_CASE(RendererUniformBatch2);
ADD_TEST_CASE(NonBatchSprites);
};
@ -629,149 +629,164 @@ std::string RendererBatchQuadTri::subtitle() const
// RendererUniformBatch
//
//RendererUniformBatch::RendererUniformBatch()
//{
// Size s = Director::getInstance()->getWinSize();
//
// auto glBlurState = createBlurGLProgramState();
// auto glSepiaState = createSepiaGLProgramState();
//
// auto x_inc = s.width / 20;
// auto y_inc = s.height / 6;
//
// for (int y=0; y<6; ++y)
// {
// for (int x=0; x<20; ++x)
// {
// auto sprite = Sprite::create("Images/grossini.png");
// sprite->setPosition(Vec2(x * x_inc, y * y_inc));
// sprite->setScale(0.4);
// addChild(sprite);
//
// if (y>=4) {
// sprite->setGLProgramState(glSepiaState);
// } else if(y>=2) {
// sprite->setGLProgramState(glBlurState);
// }
// }
// }
//}
//
//GLProgramState* RendererUniformBatch::createBlurGLProgramState()
//{
// const std::string shaderName("Shaders/example_Blur.fsh");
// // outline shader
// auto fileUtiles = FileUtils::getInstance();
// auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName);
// auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath);
// auto glprogram = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, fragSource.c_str());
// auto glprogramstate = (glprogram == nullptr ? nullptr : GLProgramState::getOrCreateWithGLProgram(glprogram));
//
// glprogramstate->setUniformVec2("resolution", Vec2(85,121));
// glprogramstate->setUniformFloat("blurRadius", 10);
// glprogramstate->setUniformFloat("sampleNum", 5);
//
// return glprogramstate;
//}
//
//GLProgramState* RendererUniformBatch::createSepiaGLProgramState()
//{
// const std::string shaderName("Shaders/example_Sepia.fsh");
//
// // outline shader
// auto fileUtiles = FileUtils::getInstance();
// auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName);
// auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath);
// auto glprogram = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, fragSource.c_str());
// auto glprogramstate = (glprogram == nullptr ? nullptr : GLProgramState::getOrCreateWithGLProgram(glprogram));
//
// return glprogramstate;
//}
//
//std::string RendererUniformBatch::title() const
//{
// return "RendererUniformBatch";
//}
//
//std::string RendererUniformBatch::subtitle() const
//{
// return "Only 9 draw calls should appear";
//}
//
//
RendererUniformBatch::RendererUniformBatch()
{
Size s = Director::getInstance()->getWinSize();
auto blurState = createBlurProgramState();
auto sepiaState = createSepiaProgramState();
auto x_inc = s.width / 20;
auto y_inc = s.height / 6;
for (int y=0; y<6; ++y)
{
for (int x=0; x<20; ++x)
{
auto sprite = Sprite::create("Images/grossini.png");
sprite->setPosition(Vec2(x * x_inc, y * y_inc));
sprite->setScale(0.4);
addChild(sprite);
if (y>=4) {
sprite->setProgramState(sepiaState);
} else if(y>=2) {
sprite->setProgramState(blurState);
}
}
}
}
cocos2d::backend::ProgramState* RendererUniformBatch::createBlurProgramState()
{
const std::string shaderName("Shaders/example_Blur.fsh");
// outline shader
auto fileUtiles = FileUtils::getInstance();
auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName);
auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath);
auto programState = new backend::ProgramState(positionTextureColor_vert, fragSource.c_str());
backend::UniformLocation loc = programState->getUniformLocation("resolution");
auto resolution = Vec2(85, 121);
programState->setUniform(loc, &resolution, sizeof(resolution));
loc = programState->getUniformLocation("blurRadius");
float blurRadius = 10.0f;
programState->setUniform(loc, &blurRadius, sizeof(blurRadius));
loc = programState->getUniformLocation("sampleNum");
float sampleNum = 5.0f;
programState->setUniform(loc, &sampleNum, sizeof(sampleNum));
return programState;
}
cocos2d::backend::ProgramState* RendererUniformBatch::createSepiaProgramState()
{
const std::string shaderName("Shaders/example_Sepia.fsh");
// outline shader
auto fileUtiles = FileUtils::getInstance();
auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName);
auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath);
auto glprogram = new backend::ProgramState(positionTextureColor_vert, fragSource.c_str());
return glprogram;
}
std::string RendererUniformBatch::title() const
{
return "RendererUniformBatch";
}
std::string RendererUniformBatch::subtitle() const
{
return "Only 9 draw calls should appear";
}
////
//// RendererUniformBatch2
////
//
//RendererUniformBatch2::RendererUniformBatch2()
//{
// Size s = Director::getInstance()->getWinSize();
//
// auto glBlurState = createBlurGLProgramState();
// auto glSepiaState = createSepiaGLProgramState();
//
// auto x_inc = s.width / 20;
// auto y_inc = s.height / 6;
//
// for (int y=0; y<6; ++y)
// {
// for (int x=0; x<20; ++x)
// {
// auto sprite = Sprite::create("Images/grossini.png");
// sprite->setPosition(Vec2(x * x_inc, y * y_inc));
// sprite->setScale(0.4);
// addChild(sprite);
//
// auto r = CCRANDOM_0_1();
// if (r < 0.33)
// sprite->setGLProgramState(glSepiaState);
// else if (r < 0.66)
// sprite->setGLProgramState(glBlurState);
// }
// }
//}
//
//GLProgramState* RendererUniformBatch2::createBlurGLProgramState()
//{
// const std::string shaderName("Shaders/example_Blur.fsh");
//
// // outline shader
// auto fileUtiles = FileUtils::getInstance();
// auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName);
// auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath);
// auto glprogram = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, fragSource.c_str());
// auto glprogramstate = (glprogram == nullptr ? nullptr : GLProgramState::getOrCreateWithGLProgram(glprogram));
//
// glprogramstate->setUniformVec2("resolution", Vec2(85,121));
// glprogramstate->setUniformFloat("blurRadius", 10);
// glprogramstate->setUniformFloat("sampleNum", 5);
//
// return glprogramstate;
//}
//
//GLProgramState* RendererUniformBatch2::createSepiaGLProgramState()
//{
// const std::string shaderName("Shaders/example_Sepia.fsh");
//
// // outline shader
// auto fileUtiles = FileUtils::getInstance();
// auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName);
// auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath);
// auto glprogram = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, fragSource.c_str());
// auto glprogramstate = (glprogram == nullptr ? nullptr : GLProgramState::getOrCreateWithGLProgram(glprogram));
//
// return glprogramstate;
//}
//
//std::string RendererUniformBatch2::title() const
//{
// return "RendererUniformBatch 2";
//}
//
//std::string RendererUniformBatch2::subtitle() const
//{
// return "Mixing different shader states should work ok";
//}
RendererUniformBatch2::RendererUniformBatch2()
{
Size s = Director::getInstance()->getWinSize();
auto blurState = createBlurProgramState();
auto sepiaState = createSepiaProgramState();
auto x_inc = s.width / 20;
auto y_inc = s.height / 6;
for (int y=0; y<6; ++y)
{
for (int x=0; x<20; ++x)
{
auto sprite = Sprite::create("Images/grossini.png");
sprite->setPosition(Vec2(x * x_inc, y * y_inc));
sprite->setScale(0.4);
addChild(sprite);
auto r = CCRANDOM_0_1();
if (r < 0.33)
sprite->setProgramState(sepiaState);
else if (r < 0.66)
sprite->setProgramState(blurState);
}
}
}
backend::ProgramState* RendererUniformBatch2::createBlurProgramState()
{
const std::string shaderName("Shaders/example_Blur.fsh");
// outline shader
auto fileUtiles = FileUtils::getInstance();
auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName);
auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath);
auto programState = new backend::ProgramState(positionTextureColor_vert, fragSource.c_str());
backend::UniformLocation loc = programState->getUniformLocation("resolution");
auto resolution = Vec2(85, 121);
programState->setUniform(loc, &resolution, sizeof(resolution));
loc = programState->getUniformLocation("blurRadius");
float blurRadius = 10.0f;
programState->setUniform(loc, &blurRadius, sizeof(blurRadius));
loc = programState->getUniformLocation("sampleNum");
float sampleNum = 5.0f;
programState->setUniform(loc, &sampleNum, sizeof(sampleNum));
return programState;
}
backend::ProgramState* RendererUniformBatch2::createSepiaProgramState()
{
const std::string shaderName("Shaders/example_Sepia.fsh");
// outline shader
auto fileUtiles = FileUtils::getInstance();
auto fragmentFullPath = fileUtiles->fullPathForFilename(shaderName);
auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath);
auto glprogram = new backend::ProgramState(positionTextureColor_vert, fragSource.c_str());
return glprogram;
}
std::string RendererUniformBatch2::title() const
{
return "RendererUniformBatch 2";
}
std::string RendererUniformBatch2::subtitle() const
{
return "Mixing different shader states should work ok";
}
NonBatchSprites::NonBatchSprites()
{
@ -791,9 +806,13 @@ NonBatchSprites::NonBatchSprites()
{
sprite = Sprite::create("Images/grossini_dance_01.png");
}
if (!sprite) break;
sprite->setScale(0.1f, 0.1f);
float x = ((float)std::rand()) / RAND_MAX;
float y = ((float)std::rand()) / RAND_MAX;
sprite->runAction(RepeatForever::create(RotateBy::create(1, 45)));
sprite->setPosition(Vec2(x * s.width, y * s.height));
parent->addChild(sprite);

View File

@ -190,33 +190,32 @@ protected:
RendererBatchQuadTri();
};
//TODO: minggo
//class RendererUniformBatch : public MultiSceneTest
//{
//public:
// CREATE_FUNC(RendererUniformBatch);
// virtual std::string title() const override;
// virtual std::string subtitle() const override;
//protected:
// RendererUniformBatch();
//
// cocos2d::GLProgramState* createBlurGLProgramState();
// cocos2d::GLProgramState* createSepiaGLProgramState();
//};
//
//class RendererUniformBatch2 : public MultiSceneTest
//{
//public:
// CREATE_FUNC(RendererUniformBatch2);
// virtual std::string title() const override;
// virtual std::string subtitle() const override;
//protected:
// RendererUniformBatch2();
//
// cocos2d::GLProgramState* createBlurGLProgramState();
// cocos2d::GLProgramState* createSepiaGLProgramState();
//};
class RendererUniformBatch : public MultiSceneTest
{
public:
CREATE_FUNC(RendererUniformBatch);
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
RendererUniformBatch();
cocos2d::backend::ProgramState* createBlurProgramState();
cocos2d::backend::ProgramState* createSepiaProgramState();
};
class RendererUniformBatch2 : public MultiSceneTest
{
public:
CREATE_FUNC(RendererUniformBatch2);
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
RendererUniformBatch2();
cocos2d::backend::ProgramState* createBlurProgramState();
cocos2d::backend::ProgramState* createSepiaProgramState();
};
class NonBatchSprites : public MultiSceneTest
{

View File

@ -32,16 +32,16 @@ UILayoutTests::UILayoutTests()
ADD_TEST_CASE(UILayoutTest);
ADD_TEST_CASE(UILayoutTest_Color);
ADD_TEST_CASE(UILayoutTest_Gradient);
// ADD_TEST_CASE(UILayoutTest_BackGroundImage); // failed assertion `When depth and stencil are used together, the tex...
// ADD_TEST_CASE(UILayoutTest_BackGroundImage_Scale9);
// ADD_TEST_CASE(UILayoutTest_Layout_Linear_Vertical);
// ADD_TEST_CASE(UILayoutTest_Layout_Linear_Horizontal);
// ADD_TEST_CASE(UILayoutTest_Layout_Relative_Align_Parent);
// ADD_TEST_CASE(UILayoutTest_Layout_Relative_Location);
// ADD_TEST_CASE(UILayoutTest_Layout_Scaled_Widget);
// ADD_TEST_CASE(UILayoutComponentTest);
// ADD_TEST_CASE(UILayoutComponent_Berth_Test);
// ADD_TEST_CASE(UILayoutComponent_Berth_Stretch_Test);
ADD_TEST_CASE(UILayoutTest_BackGroundImage);
ADD_TEST_CASE(UILayoutTest_BackGroundImage_Scale9);
ADD_TEST_CASE(UILayoutTest_Layout_Linear_Vertical);
ADD_TEST_CASE(UILayoutTest_Layout_Linear_Horizontal);
ADD_TEST_CASE(UILayoutTest_Layout_Relative_Align_Parent);
ADD_TEST_CASE(UILayoutTest_Layout_Relative_Location);
ADD_TEST_CASE(UILayoutTest_Layout_Scaled_Widget);
ADD_TEST_CASE(UILayoutComponentTest);
ADD_TEST_CASE(UILayoutComponent_Berth_Test);
ADD_TEST_CASE(UILayoutComponent_Berth_Stretch_Test);
}
// UILayoutTest