2014-10-14 21:34:55 +08:00
|
|
|
require "helper"
|
|
|
|
require "testResource"
|
|
|
|
require "VisibleRect"
|
2014-03-10 15:32:48 +08:00
|
|
|
|
2014-10-14 21:34:55 +08:00
|
|
|
require "AccelerometerTest/AccelerometerTest"
|
|
|
|
require "ActionManagerTest/ActionManagerTest"
|
|
|
|
require "ActionsEaseTest/ActionsEaseTest"
|
|
|
|
require "ActionsProgressTest/ActionsProgressTest"
|
|
|
|
require "ActionsTest/ActionsTest"
|
|
|
|
require "AssetsManagerTest/AssetsManagerTest"
|
2014-10-16 10:28:52 +08:00
|
|
|
require "AssetsManagerExTest/AssetsManagerExTest"
|
2014-10-14 21:34:55 +08:00
|
|
|
require "BillBoardTest/BillBoardTest"
|
|
|
|
require "BugsTest/BugsTest"
|
|
|
|
require "Camera3DTest/Camera3DTest"
|
|
|
|
require "ClickAndMoveTest/ClickAndMoveTest"
|
|
|
|
require "CocosDenshionTest/CocosDenshionTest"
|
2015-09-21 14:02:42 +08:00
|
|
|
require "ComponentTest/main"
|
2014-10-14 21:34:55 +08:00
|
|
|
require "CurrentLanguageTest/CurrentLanguageTest"
|
|
|
|
require "DrawPrimitivesTest/DrawPrimitivesTest"
|
|
|
|
require "EffectsTest/EffectsTest"
|
|
|
|
require "EffectsAdvancedTest/EffectsAdvancedTest"
|
|
|
|
require "ExtensionTest/ExtensionTest"
|
|
|
|
require "FontTest/FontTest"
|
|
|
|
require "IntervalTest/IntervalTest"
|
|
|
|
require "KeypadTest/KeypadTest"
|
|
|
|
require "LabelTest/LabelTest"
|
|
|
|
require "LabelTestNew/LabelTestNew"
|
|
|
|
require "LayerTest/LayerTest"
|
2014-10-18 00:13:22 +08:00
|
|
|
require "LightTest/LightTest"
|
2014-10-14 21:34:55 +08:00
|
|
|
require "MenuTest/MenuTest"
|
|
|
|
require "MotionStreakTest/MotionStreakTest"
|
|
|
|
require "NewEventDispatcherTest/NewEventDispatcherTest"
|
|
|
|
require "NodeTest/NodeTest"
|
|
|
|
require "OpenGLTest/OpenGLTest"
|
|
|
|
require "ParallaxTest/ParallaxTest"
|
|
|
|
require "ParticleTest/ParticleTest"
|
2015-02-15 15:56:20 +08:00
|
|
|
require "Particle3DTest/Particle3DTest"
|
2014-10-14 21:34:55 +08:00
|
|
|
require "RenderTextureTest/RenderTextureTest"
|
|
|
|
require "RotateWorldTest/RotateWorldTest"
|
|
|
|
require "Sprite3DTest/Sprite3DTest"
|
|
|
|
require "SpriteTest/SpriteTest"
|
|
|
|
require "SceneTest/SceneTest"
|
|
|
|
require "SpineTest/SpineTest"
|
2015-04-08 10:03:50 +08:00
|
|
|
require "TerrainTest/TerrainTest"
|
2015-06-06 14:20:16 +08:00
|
|
|
require "TextInputTest/TextInputTest"
|
2014-10-14 21:34:55 +08:00
|
|
|
require "Texture2dTest/Texture2dTest"
|
|
|
|
require "TileMapTest/TileMapTest"
|
|
|
|
require "TouchesTest/TouchesTest"
|
|
|
|
require "TransitionsTest/TransitionsTest"
|
|
|
|
require "UserDefaultTest/UserDefaultTest"
|
2015-06-25 17:36:57 +08:00
|
|
|
require "VibrateTest/VibrateTest"
|
2014-10-14 21:34:55 +08:00
|
|
|
require "ZwoptexTest/ZwoptexTest"
|
|
|
|
require "LuaBridgeTest/LuaBridgeTest"
|
|
|
|
require "XMLHttpRequestTest/XMLHttpRequestTest"
|
|
|
|
require "PhysicsTest/PhysicsTest"
|
|
|
|
require "CaptureScreenTest/CaptureScreenTest"
|
|
|
|
require "VideoPlayerTest/VideoPlayerTest"
|
|
|
|
require "FastTiledMapTest/FastTiledMapTest"
|
|
|
|
require "NewAudioEngineTest/NewAudioEngineTest"
|
2015-04-17 14:08:47 +08:00
|
|
|
require "WebViewTest/WebViewTest"
|
2015-04-28 18:19:57 +08:00
|
|
|
require "SpritePolygonTest/SpritePolygonTest"
|
2015-05-15 09:28:03 +08:00
|
|
|
require "Physics3DTest/Physics3DTest"
|
2015-05-19 16:52:39 +08:00
|
|
|
require "Scene3DTest/Scene3DTest"
|
2015-05-27 15:37:59 +08:00
|
|
|
require "MaterialSystemTest/MaterialSystemTest"
|
2015-06-02 18:37:57 +08:00
|
|
|
require "NavMeshTest/NavMeshTest"
|
2014-03-10 15:32:48 +08:00
|
|
|
|
|
|
|
local LINE_SPACE = 40
|
|
|
|
|
|
|
|
local CurPos = {x = 0, y = 0}
|
|
|
|
local BeginPos = {x = 0, y = 0}
|
|
|
|
|
2014-09-14 22:54:48 +08:00
|
|
|
local audioEndineSupported = false
|
|
|
|
local currPlatform = cc.Application:getInstance():getTargetPlatform()
|
2014-10-17 17:53:33 +08:00
|
|
|
if (cc.PLATFORM_OS_WINDOWS == currPlatform or cc.PLATFORM_OS_MAC == currPlatform or cc.PLATFORM_OS_IPHONE == currPlatform or cc.PLATFORM_OS_IPAD == currPlatform or cc.PLATFORM_OS_ANDROID == currPlatform) then
|
2014-09-14 22:54:48 +08:00
|
|
|
audioEndineSupported = true
|
|
|
|
end
|
2014-03-10 15:32:48 +08:00
|
|
|
|
2016-04-28 09:49:55 +08:00
|
|
|
local assetManagerSupported = true;
|
|
|
|
if (currPlatform == cc.PLATFORM_OS_TIZEN) then
|
|
|
|
assetManagerSupported = false;
|
|
|
|
end
|
|
|
|
|
|
|
|
local luaByteCodeSupported = true;
|
|
|
|
if (currPlatform == cc.PLATFORM_OS_TIZEN) then
|
|
|
|
luaByteCodeSupported = false;
|
|
|
|
end
|
|
|
|
|
2014-03-10 15:32:48 +08:00
|
|
|
local _allTests = {
|
|
|
|
{ isSupported = true, name = "Accelerometer" , create_func= AccelerometerMain },
|
|
|
|
{ isSupported = true, name = "ActionManagerTest" , create_func = ActionManagerTestMain },
|
|
|
|
{ isSupported = true, name = "ActionsEaseTest" , create_func = EaseActionsTest },
|
|
|
|
{ isSupported = true, name = "ActionsProgressTest" , create_func = ProgressActionsTest },
|
|
|
|
{ isSupported = true, name = "ActionsTest" , create_func = ActionsTest },
|
2016-04-28 09:49:55 +08:00
|
|
|
{ isSupported = assetManagerSupported, name = "AssetsManagerTest" , create_func = AssetsManagerTestMain },
|
2014-10-16 10:28:52 +08:00
|
|
|
{ isSupported = true, name = "AssetsManagerExTest" , create_func = AssetsManagerExTestMain },
|
2014-09-14 22:54:48 +08:00
|
|
|
{ isSupported = audioEndineSupported, name = "AudioEngineTest", create_func = AudioEngineTest},
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain },
|
|
|
|
{ isSupported = false, name = "Box2dTestBed" , create_func= Box2dTestBedMain },
|
2014-09-29 09:43:22 +08:00
|
|
|
{ isSupported = true, name = "BillBoardTest" , create_func= BillBoardTestMain},
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "BugsTest" , create_func= BugsTestMain },
|
2014-09-26 16:00:57 +08:00
|
|
|
{ isSupported = true, name = "Camera3DTest" , create_func= Camera3DTestMain },
|
2014-07-04 16:24:00 +08:00
|
|
|
{ isSupported = true, name = "CaptureScreenTest" , create_func = CaptureScreenTestMain },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain },
|
|
|
|
{ isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest },
|
|
|
|
{ isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain },
|
2015-09-21 14:02:42 +08:00
|
|
|
{ isSupported = true, name = "ComponentTest" , create_func = ComponentTestMain },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = false, name = "CurlTest" , create_func= CurlTestMain },
|
|
|
|
{ isSupported = true, name = "CurrentLanguageTest" , create_func= CurrentLanguageTestMain },
|
|
|
|
{ isSupported = true, name = "DrawPrimitivesTest" , create_func= DrawPrimitivesTest },
|
|
|
|
{ isSupported = true, name = "EffectsTest" , create_func = EffectsTest },
|
|
|
|
{ isSupported = true, name = "EffectAdvancedTest" , create_func = EffectAdvancedTestMain },
|
|
|
|
{ isSupported = true, name = "ExtensionsTest" , create_func= ExtensionsTestMain },
|
2014-07-11 17:21:55 +08:00
|
|
|
{ isSupported = true, name = "FastTiledMapTest" , create_func = FastTiledMapTestMain},
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "FontTest" , create_func = FontTestMain },
|
|
|
|
{ isSupported = true, name = "IntervalTest" , create_func = IntervalTestMain },
|
|
|
|
{ isSupported = true, name = "KeypadTest" , create_func= KeypadTestMain },
|
|
|
|
{ isSupported = true, name = "LabelTest" , create_func = LabelTest },
|
|
|
|
{ isSupported = true, name = "LabelTestNew" , create_func = LabelTestNew },
|
|
|
|
{ isSupported = true, name = "LayerTest" , create_func = LayerTestMain },
|
2014-10-18 00:13:22 +08:00
|
|
|
{ isSupported = true, name = "LightTest" , create_func = LightTestMain },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "LuaBridgeTest" , create_func = LuaBridgeMainTest },
|
2015-05-27 15:37:59 +08:00
|
|
|
{ isSupported = true, name = "MaterialSystemTest" , create_func = MaterialSystemTest },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "MenuTest" , create_func = MenuTestMain },
|
|
|
|
{ isSupported = true, name = "MotionStreakTest" , create_func = MotionStreakTest },
|
|
|
|
{ isSupported = false, name = "MutiTouchTest" , create_func= MutiTouchTestMain },
|
2015-06-02 18:37:57 +08:00
|
|
|
{ isSupported = true, name = "NavMeshTest" , create_func = NavMeshTest },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "NewEventDispatcherTest" , create_func = NewEventDispatcherTest },
|
|
|
|
{ isSupported = true, name = "NodeTest" , create_func = CocosNodeTest },
|
|
|
|
{ isSupported = true, name = "OpenGLTest" , create_func= OpenGLTestMain },
|
|
|
|
{ isSupported = true, name = "ParallaxTest" , create_func = ParallaxTestMain },
|
|
|
|
{ isSupported = true, name = "ParticleTest" , create_func = ParticleTest },
|
2015-02-28 11:31:15 +08:00
|
|
|
{ isSupported = true, name = "Particle3D (PU)" , create_func = Particle3DTest },
|
2015-02-15 15:56:20 +08:00
|
|
|
{ isSupported = true, name = "PhysicsTest" , create_func = PhysicsTest },
|
2015-05-15 09:28:03 +08:00
|
|
|
{ isSupported = true, name = "Physics3DTest" , create_func = Physics3DTest },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "RenderTextureTest" , create_func = RenderTextureTestMain },
|
|
|
|
{ isSupported = true, name = "RotateWorldTest" , create_func = RotateWorldTest },
|
|
|
|
{ isSupported = true, name = "SceneTest" , create_func = SceneTestMain },
|
2015-05-19 16:52:39 +08:00
|
|
|
{ isSupported = true, name = "Scene3DTest" , create_func= Scene3DTestMain },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "SpineTest" , create_func = SpineTestMain },
|
|
|
|
{ isSupported = false, name = "SchdulerTest" , create_func= SchdulerTestMain },
|
2015-05-19 16:52:39 +08:00
|
|
|
{ isSupported = false, name = "ShaderTest" , create_func= ShaderTestMain },
|
2014-05-20 18:09:04 +08:00
|
|
|
{ isSupported = true, name = "Sprite3DTest" , create_func = Sprite3DTest },
|
2015-04-08 10:03:50 +08:00
|
|
|
{ isSupported = true, name = "TerrainTest" , create_func = TerrainTest },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "SpriteTest" , create_func = SpriteTest },
|
2015-04-28 18:19:57 +08:00
|
|
|
{ isSupported = true, name = "SpritePolygonTest" , create_func = SpritePolygonTest },
|
2015-06-06 14:20:16 +08:00
|
|
|
{ isSupported = true, name = "TextInputTest" , create_func= TextInputTestMain },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "Texture2DTest" , create_func = Texture2dTestMain },
|
|
|
|
{ isSupported = false, name = "TextureCacheTest" , create_func= TextureCacheTestMain },
|
|
|
|
{ isSupported = true, name = "TileMapTest" , create_func = TileMapTestMain },
|
|
|
|
{ isSupported = true, name = "TouchesTest" , create_func = TouchesTest },
|
|
|
|
{ isSupported = true, name = "TransitionsTest" , create_func = TransitionsTest },
|
|
|
|
{ isSupported = true, name = "UserDefaultTest" , create_func= UserDefaultTestMain },
|
2014-07-08 15:17:46 +08:00
|
|
|
{ isSupported = true, name = "VideoPlayerTest" , create_func= VideoPlayerTestMain },
|
2015-04-17 14:08:47 +08:00
|
|
|
{ isSupported = true, name = "WebViewTest" , create_func= WebViewTestMain },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "XMLHttpRequestTest" , create_func = XMLHttpRequestTestMain },
|
2015-06-25 17:36:57 +08:00
|
|
|
{ isSupported = true, name = "VibrateTest" , create_func = VibrateTestMain },
|
2014-03-10 15:32:48 +08:00
|
|
|
{ isSupported = true, name = "ZwoptexTest" , create_func = ZwoptexTestMain }
|
|
|
|
}
|
|
|
|
|
|
|
|
local TESTS_COUNT = table.getn(_allTests)
|
|
|
|
|
|
|
|
-- create scene
|
|
|
|
local function CreateTestScene(nIdx)
|
|
|
|
cc.Director:getInstance():purgeCachedData()
|
|
|
|
local scene = _allTests[nIdx].create_func()
|
|
|
|
return scene
|
|
|
|
end
|
|
|
|
-- create menu
|
|
|
|
function CreateTestMenu()
|
|
|
|
local menuLayer = cc.Layer:create()
|
|
|
|
|
|
|
|
local function closeCallback()
|
|
|
|
cc.Director:getInstance():endToLua()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function menuCallback(tag)
|
|
|
|
print(tag)
|
|
|
|
local Idx = tag - 10000
|
|
|
|
local testScene = CreateTestScene(Idx)
|
|
|
|
if testScene then
|
|
|
|
cc.Director:getInstance():replaceScene(testScene)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- add close menu
|
|
|
|
local s = cc.Director:getInstance():getWinSize()
|
|
|
|
local CloseItem = cc.MenuItemImage:create(s_pPathClose, s_pPathClose)
|
|
|
|
CloseItem:registerScriptTapHandler(closeCallback)
|
|
|
|
CloseItem:setPosition(cc.p(s.width - 30, s.height - 30))
|
|
|
|
|
|
|
|
local CloseMenu = cc.Menu:create()
|
|
|
|
CloseMenu:setPosition(0, 0)
|
|
|
|
CloseMenu:addChild(CloseItem)
|
|
|
|
menuLayer:addChild(CloseMenu)
|
2014-03-14 17:38:58 +08:00
|
|
|
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
|
|
|
|
if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then
|
|
|
|
CloseMenu:setVisible(false)
|
|
|
|
end
|
2014-03-10 15:32:48 +08:00
|
|
|
|
|
|
|
-- add menu items for tests
|
|
|
|
local MainMenu = cc.Menu:create()
|
|
|
|
local index = 0
|
|
|
|
local obj = nil
|
|
|
|
for index, obj in pairs(_allTests) do
|
2014-04-11 15:25:18 +08:00
|
|
|
local testLabel = cc.Label:createWithTTF(obj.name, s_arialPath, 24)
|
2014-03-12 17:51:34 +08:00
|
|
|
testLabel:setAnchorPoint(cc.p(0.5, 0.5))
|
2014-03-10 15:32:48 +08:00
|
|
|
local testMenuItem = cc.MenuItemLabel:create(testLabel)
|
|
|
|
if not obj.isSupported then
|
|
|
|
testMenuItem:setEnabled(false)
|
|
|
|
end
|
2014-07-08 15:17:46 +08:00
|
|
|
|
2016-12-07 11:12:38 +08:00
|
|
|
if obj.name == "WebViewTest"
|
|
|
|
or obj.name == "VibrateTest"
|
|
|
|
or obj.name == "VideoPlayerTest" then
|
2015-04-17 14:08:47 +08:00
|
|
|
if cc.PLATFORM_OS_IPHONE ~= targetPlatform and cc.PLATFORM_OS_ANDROID ~= targetPlatform then
|
|
|
|
testMenuItem:setEnabled(false)
|
|
|
|
end
|
2015-05-15 09:28:03 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
if obj.name == "Physics3DTest" and nil == cc.Physics3DComponent then
|
|
|
|
testMenuItem:setEnabled(false)
|
|
|
|
end
|
2015-04-17 14:08:47 +08:00
|
|
|
|
2015-06-02 18:37:57 +08:00
|
|
|
if obj.name == "NavMeshTest" and nil == cc.NavMesh then
|
|
|
|
testMenuItem:setEnabled(false)
|
|
|
|
end
|
|
|
|
|
2014-03-10 15:32:48 +08:00
|
|
|
testMenuItem:registerScriptTapHandler(menuCallback)
|
|
|
|
testMenuItem:setPosition(cc.p(s.width / 2, (s.height - (index) * LINE_SPACE)))
|
|
|
|
MainMenu:addChild(testMenuItem, index + 10000, index + 10000)
|
|
|
|
end
|
|
|
|
|
|
|
|
MainMenu:setContentSize(cc.size(s.width, (TESTS_COUNT + 1) * (LINE_SPACE)))
|
|
|
|
MainMenu:setPosition(CurPos.x, CurPos.y)
|
|
|
|
menuLayer:addChild(MainMenu)
|
|
|
|
|
|
|
|
-- handling touch events
|
|
|
|
local function onTouchBegan(touch, event)
|
|
|
|
BeginPos = touch:getLocation()
|
|
|
|
-- CCTOUCHBEGAN event must return true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
local function onTouchMoved(touch, event)
|
|
|
|
local location = touch:getLocation()
|
|
|
|
local nMoveY = location.y - BeginPos.y
|
|
|
|
local curPosx, curPosy = MainMenu:getPosition()
|
|
|
|
local nextPosy = curPosy + nMoveY
|
|
|
|
local winSize = cc.Director:getInstance():getWinSize()
|
|
|
|
if nextPosy < 0 then
|
|
|
|
MainMenu:setPosition(0, 0)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if nextPosy > ((TESTS_COUNT + 1) * LINE_SPACE - winSize.height) then
|
|
|
|
MainMenu:setPosition(0, ((TESTS_COUNT + 1) * LINE_SPACE - winSize.height))
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
MainMenu:setPosition(curPosx, nextPosy)
|
|
|
|
BeginPos = {x = location.x, y = location.y}
|
|
|
|
CurPos = {x = curPosx, y = nextPosy}
|
|
|
|
end
|
|
|
|
|
|
|
|
local listener = cc.EventListenerTouchOneByOne:create()
|
|
|
|
listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
|
|
|
|
listener:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED )
|
|
|
|
local eventDispatcher = menuLayer:getEventDispatcher()
|
|
|
|
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, menuLayer)
|
|
|
|
|
|
|
|
return menuLayer
|
|
|
|
end
|