2013-08-14 21:35:55 +08:00
|
|
|
require "Cocos2d"
|
|
|
|
require "Cocos2dConstants"
|
|
|
|
require "Opengl"
|
|
|
|
require "OpenglConstants"
|
2013-11-11 17:03:43 +08:00
|
|
|
require "StudioConstants"
|
2012-08-24 10:07:15 +08:00
|
|
|
require "luaScript/helper"
|
|
|
|
require "luaScript/testResource"
|
2013-08-15 15:51:22 +08:00
|
|
|
require "luaScript/VisibleRect"
|
2013-04-07 16:20:43 +08:00
|
|
|
|
2013-08-20 13:44:37 +08:00
|
|
|
require "luaScript/AccelerometerTest/AccelerometerTest"
|
2013-08-14 21:35:55 +08:00
|
|
|
require "luaScript/ActionManagerTest/ActionManagerTest"
|
|
|
|
require "luaScript/ActionsEaseTest/ActionsEaseTest"
|
|
|
|
require "luaScript/ActionsProgressTest/ActionsProgressTest"
|
2013-04-07 16:20:43 +08:00
|
|
|
require "luaScript/ActionsTest/ActionsTest"
|
2013-10-22 16:14:49 +08:00
|
|
|
require "luaScript/AssetsManagerTest/AssetsManagerTest"
|
2013-08-15 15:51:22 +08:00
|
|
|
require "luaScript/BugsTest/BugsTest"
|
|
|
|
require "luaScript/ClickAndMoveTest/ClickAndMoveTest"
|
|
|
|
require "luaScript/CocosDenshionTest/CocosDenshionTest"
|
2013-11-07 10:16:02 +08:00
|
|
|
require "luaScript/CocoStudioTest/CocoStudioTest"
|
2013-08-15 15:51:22 +08:00
|
|
|
require "luaScript/CurrentLanguageTest/CurrentLanguageTest"
|
|
|
|
require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest"
|
|
|
|
require "luaScript/EffectsTest/EffectsTest"
|
|
|
|
require "luaScript/EffectsAdvancedTest/EffectsAdvancedTest"
|
2013-08-20 13:44:37 +08:00
|
|
|
require "luaScript/ExtensionTest/ExtensionTest"
|
2013-08-16 10:12:46 +08:00
|
|
|
require "luaScript/FontTest/FontTest"
|
|
|
|
require "luaScript/IntervalTest/IntervalTest"
|
|
|
|
require "luaScript/KeypadTest/KeypadTest"
|
|
|
|
require "luaScript/LabelTest/LabelTest"
|
2013-12-18 11:39:43 +08:00
|
|
|
require "luaScript/LabelTestNew/LabelTestNew"
|
2013-08-16 10:12:46 +08:00
|
|
|
require "luaScript/LayerTest/LayerTest"
|
2013-08-20 13:44:37 +08:00
|
|
|
require "luaScript/MenuTest/MenuTest"
|
2013-04-07 16:20:43 +08:00
|
|
|
require "luaScript/MotionStreakTest/MotionStreakTest"
|
2013-12-22 22:10:21 +08:00
|
|
|
require "luaScript/NewEventDispatcherTest/NewEventDispatcherTest"
|
2013-04-07 16:20:43 +08:00
|
|
|
require "luaScript/NodeTest/NodeTest"
|
2013-08-20 13:44:37 +08:00
|
|
|
require "luaScript/OpenGLTest/OpenGLTest"
|
2013-04-07 16:20:43 +08:00
|
|
|
require "luaScript/ParallaxTest/ParallaxTest"
|
2013-08-20 13:44:37 +08:00
|
|
|
require "luaScript/ParticleTest/ParticleTest"
|
|
|
|
require "luaScript/PerformanceTest/PerformanceTest"
|
|
|
|
require "luaScript/RenderTextureTest/RenderTextureTest"
|
|
|
|
require "luaScript/RotateWorldTest/RotateWorldTest"
|
|
|
|
require "luaScript/SpriteTest/SpriteTest"
|
2013-04-07 16:20:43 +08:00
|
|
|
require "luaScript/SceneTest/SceneTest"
|
2013-12-24 11:55:53 +08:00
|
|
|
require "luaScript/SpineTest/SpineTest"
|
2013-04-07 16:20:43 +08:00
|
|
|
require "luaScript/Texture2dTest/Texture2dTest"
|
2013-08-20 13:44:37 +08:00
|
|
|
require "luaScript/TileMapTest/TileMapTest"
|
|
|
|
require "luaScript/TouchesTest/TouchesTest"
|
|
|
|
require "luaScript/TransitionsTest/TransitionsTest"
|
2013-04-07 16:20:43 +08:00
|
|
|
require "luaScript/UserDefaultTest/UserDefaultTest"
|
2013-08-20 13:44:37 +08:00
|
|
|
require "luaScript/ZwoptexTest/ZwoptexTest"
|
2013-09-11 09:48:24 +08:00
|
|
|
require "luaScript/LuaBridgeTest/LuaBridgeTest"
|
2013-10-31 22:06:34 +08:00
|
|
|
require "luaScript/XMLHttpRequestTest/XMLHttpRequestTest"
|
2013-08-20 13:44:37 +08:00
|
|
|
|
2012-08-23 16:10:50 +08:00
|
|
|
|
|
|
|
local LINE_SPACE = 40
|
|
|
|
|
|
|
|
local CurPos = {x = 0, y = 0}
|
|
|
|
local BeginPos = {x = 0, y = 0}
|
|
|
|
|
2013-04-07 15:56:05 +08:00
|
|
|
|
|
|
|
local _allTests = {
|
2013-07-11 13:38:25 +08:00
|
|
|
{ isSupported = true, name = "Accelerometer" , create_func= AccelerometerMain },
|
2013-04-07 16:06:53 +08:00
|
|
|
{ isSupported = true, name = "ActionManagerTest" , create_func = ActionManagerTestMain },
|
2013-07-11 13:38:25 +08:00
|
|
|
{ isSupported = true, name = "ActionsEaseTest" , create_func = EaseActionsTest },
|
|
|
|
{ isSupported = true, name = "ActionsProgressTest" , create_func = ProgressActionsTest },
|
|
|
|
{ isSupported = true, name = "ActionsTest" , create_func = ActionsTest },
|
2013-10-22 16:14:49 +08:00
|
|
|
{ isSupported = true, name = "AssetsManagerTest" , create_func = AssetsManagerTestMain },
|
2013-04-07 16:06:53 +08:00
|
|
|
{ isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain },
|
|
|
|
{ isSupported = false, name = "Box2dTestBed" , create_func= Box2dTestBedMain },
|
2013-07-11 13:38:25 +08:00
|
|
|
{ isSupported = true, name = "BugsTest" , create_func= BugsTestMain },
|
|
|
|
{ isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain },
|
|
|
|
{ isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest },
|
2013-04-07 16:06:53 +08:00
|
|
|
{ isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain },
|
2013-11-07 10:16:02 +08:00
|
|
|
{ isSupported = true, name = "CocoStudioTest" , create_func = CocoStudioTestMain },
|
2013-04-07 16:06:53 +08:00
|
|
|
{ isSupported = false, name = "CurlTest" , create_func= CurlTestMain },
|
2013-04-07 16:34:07 +08:00
|
|
|
{ isSupported = true, name = "CurrentLanguageTest" , create_func= CurrentLanguageTestMain },
|
2013-07-24 10:15:16 +08:00
|
|
|
{ isSupported = true, name = "DrawPrimitivesTest" , create_func= DrawPrimitivesTest },
|
2013-07-11 13:38:25 +08:00
|
|
|
{ isSupported = true, name = "EffectsTest" , create_func = EffectsTest },
|
|
|
|
{ isSupported = true, name = "EffectAdvancedTest" , create_func = EffectAdvancedTestMain },
|
2013-05-24 11:42:27 +08:00
|
|
|
{ isSupported = true, name = "ExtensionsTest" , create_func= ExtensionsTestMain },
|
2013-07-11 13:38:25 +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 },
|
2013-12-18 11:39:43 +08:00
|
|
|
{ isSupported = true, name = "LabelTestNew" , create_func = LabelTestNew },
|
2013-07-11 13:38:25 +08:00
|
|
|
{ isSupported = true, name = "LayerTest" , create_func = LayerTestMain },
|
2013-10-31 15:20:53 +08:00
|
|
|
{ isSupported = true, name = "LuaBridgeTest" , create_func = LuaBridgeMainTest },
|
2013-07-11 13:38:25 +08:00
|
|
|
{ isSupported = true, name = "MenuTest" , create_func = MenuTestMain },
|
|
|
|
{ isSupported = true, name = "MotionStreakTest" , create_func = MotionStreakTest },
|
2013-06-19 16:40:02 +08:00
|
|
|
{ isSupported = false, name = "MutiTouchTest" , create_func= MutiTouchTestMain },
|
2013-12-22 22:10:21 +08:00
|
|
|
{ isSupported = true, name = "NewEventDispatcherTest" , create_func = NewEventDispatcherTest },
|
2013-07-11 13:38:25 +08:00
|
|
|
{ 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 },
|
|
|
|
{ isSupported = true, name = "PerformanceTest" , create_func= PerformanceTestMain },
|
|
|
|
{ isSupported = true, name = "RenderTextureTest" , create_func = RenderTextureTestMain },
|
|
|
|
{ isSupported = true, name = "RotateWorldTest" , create_func = RotateWorldTest },
|
|
|
|
{ isSupported = true, name = "SceneTest" , create_func = SceneTestMain },
|
2013-12-24 11:55:53 +08:00
|
|
|
{ isSupported = true, name = "SpineTest" , create_func = SpineTestMain },
|
2013-07-11 13:38:25 +08:00
|
|
|
{ isSupported = false, name = "SchdulerTest" , create_func= SchdulerTestMain },
|
|
|
|
{ isSupported = false, name = "ShaderTest" , create_func= ShaderTestMain },
|
|
|
|
{ isSupported = true, name = "SpriteTest" , create_func = SpriteTest },
|
|
|
|
{ isSupported = false, name = "TextInputTest" , create_func= TextInputTestMain },
|
|
|
|
{ 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 },
|
2013-10-31 22:06:34 +08:00
|
|
|
{ isSupported = true, name = "XMLHttpRequestTest" , create_func = XMLHttpRequestTestMain },
|
2013-10-31 15:20:53 +08:00
|
|
|
{ isSupported = true, name = "ZwoptexTest" , create_func = ZwoptexTestMain }
|
2013-04-07 15:56:05 +08:00
|
|
|
}
|
|
|
|
|
2013-04-07 16:06:53 +08:00
|
|
|
local TESTS_COUNT = table.getn(_allTests)
|
|
|
|
|
2012-08-23 16:10:50 +08:00
|
|
|
-- create scene
|
|
|
|
local function CreateTestScene(nIdx)
|
2013-08-14 21:35:55 +08:00
|
|
|
cc.Director:getInstance():purgeCachedData()
|
2013-12-18 11:39:43 +08:00
|
|
|
local scene = _allTests[nIdx].create_func()
|
2013-04-05 16:13:04 +08:00
|
|
|
return scene
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|
|
|
|
-- create menu
|
|
|
|
function CreateTestMenu()
|
2013-08-14 21:35:55 +08:00
|
|
|
local menuLayer = cc.Layer:create()
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
local function closeCallback()
|
2013-08-14 21:35:55 +08:00
|
|
|
cc.Director:getInstance():endToLua()
|
2013-04-05 16:13:04 +08:00
|
|
|
end
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
local function menuCallback(tag)
|
2012-09-11 17:13:20 +08:00
|
|
|
print(tag)
|
2013-04-05 16:13:04 +08:00
|
|
|
local Idx = tag - 10000
|
|
|
|
local testScene = CreateTestScene(Idx)
|
|
|
|
if testScene then
|
2013-08-14 21:35:55 +08:00
|
|
|
cc.Director:getInstance():replaceScene(testScene)
|
2013-04-05 16:13:04 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- add close menu
|
2013-08-14 21:35:55 +08:00
|
|
|
local s = cc.Director:getInstance():getWinSize()
|
|
|
|
local CloseItem = cc.MenuItemImage:create(s_pPathClose, s_pPathClose)
|
2013-04-05 16:13:04 +08:00
|
|
|
CloseItem:registerScriptTapHandler(closeCallback)
|
2013-08-14 21:35:55 +08:00
|
|
|
CloseItem:setPosition(cc.p(s.width - 30, s.height - 30))
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-08-14 21:35:55 +08:00
|
|
|
local CloseMenu = cc.Menu:create()
|
2012-08-23 16:10:50 +08:00
|
|
|
CloseMenu:setPosition(0, 0)
|
2013-04-05 16:13:04 +08:00
|
|
|
CloseMenu:addChild(CloseItem)
|
|
|
|
menuLayer:addChild(CloseMenu)
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
-- add menu items for tests
|
2013-08-14 21:35:55 +08:00
|
|
|
local MainMenu = cc.Menu:create()
|
2013-04-07 15:56:05 +08:00
|
|
|
local index = 0
|
|
|
|
local obj = nil
|
|
|
|
for index, obj in pairs(_allTests) do
|
2013-08-14 21:35:55 +08:00
|
|
|
local testLabel = cc.LabelTTF:create(obj.name, "Arial", 24)
|
|
|
|
local testMenuItem = cc.MenuItemLabel:create(testLabel)
|
2013-04-07 16:06:53 +08:00
|
|
|
if not obj.isSupported then
|
|
|
|
testMenuItem:setEnabled(false)
|
|
|
|
end
|
2013-04-05 16:13:04 +08:00
|
|
|
testMenuItem:registerScriptTapHandler(menuCallback)
|
2013-08-14 21:35:55 +08:00
|
|
|
testMenuItem:setPosition(cc.p(s.width / 2, (s.height - (index) * LINE_SPACE)))
|
2012-08-27 11:43:47 +08:00
|
|
|
MainMenu:addChild(testMenuItem, index + 10000, index + 10000)
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|
|
|
|
|
2013-08-14 21:35:55 +08:00
|
|
|
MainMenu:setContentSize(cc.size(s.width, (TESTS_COUNT + 1) * (LINE_SPACE)))
|
2013-04-05 16:13:04 +08:00
|
|
|
MainMenu:setPosition(CurPos.x, CurPos.y)
|
|
|
|
menuLayer:addChild(MainMenu)
|
2012-08-23 16:10:50 +08:00
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
-- handling touch events
|
2012-08-23 16:10:50 +08:00
|
|
|
local function onTouchBegan(x, y)
|
2013-04-05 16:13:04 +08:00
|
|
|
BeginPos = {x = x, y = y}
|
2012-08-23 16:10:50 +08:00
|
|
|
-- CCTOUCHBEGAN event must return true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
local function onTouchMoved(x, y)
|
|
|
|
local nMoveY = y - BeginPos.y
|
2013-08-23 16:12:59 +08:00
|
|
|
local curPosx, curPosy = MainMenu:getPosition()
|
2013-04-05 16:13:04 +08:00
|
|
|
local nextPosy = curPosy + nMoveY
|
2013-08-14 21:35:55 +08:00
|
|
|
local winSize = cc.Director:getInstance():getWinSize()
|
2013-04-05 16:13:04 +08:00
|
|
|
if nextPosy < 0 then
|
|
|
|
MainMenu:setPosition(0, 0)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-04-07 16:06:53 +08:00
|
|
|
if nextPosy > ((TESTS_COUNT + 1) * LINE_SPACE - winSize.height) then
|
|
|
|
MainMenu:setPosition(0, ((TESTS_COUNT + 1) * LINE_SPACE - winSize.height))
|
2013-04-05 16:13:04 +08:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
MainMenu:setPosition(curPosx, nextPosy)
|
|
|
|
BeginPos = {x = x, y = y}
|
|
|
|
CurPos = {x = curPosx, y = nextPosy}
|
2012-08-23 16:10:50 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
local function onTouch(eventType, x, y)
|
2013-03-01 17:09:42 +08:00
|
|
|
if eventType == "began" then
|
2012-08-23 16:10:50 +08:00
|
|
|
return onTouchBegan(x, y)
|
2013-03-01 17:09:42 +08:00
|
|
|
elseif eventType == "moved" then
|
2012-08-23 16:10:50 +08:00
|
|
|
return onTouchMoved(x, y)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-04-05 16:13:04 +08:00
|
|
|
menuLayer:setTouchEnabled(true)
|
2012-08-23 16:10:50 +08:00
|
|
|
menuLayer:registerScriptTouchHandler(onTouch)
|
|
|
|
|
|
|
|
return menuLayer
|
|
|
|
end
|