From eba954b410e933181abf0fac33921ba14d5474b4 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Fri, 6 Jun 2014 17:17:43 +0800 Subject: [PATCH 1/2] Add bytecode and encrypted files test cases for Lua --- .../lua-tests/project/Classes/AppDelegate.cpp | 4 +- .../ByteCodeAndEncryptTest.luac | Bin 0 -> 1181 bytes .../ByteCodeEncryptTest.lua | 104 ++++++++++++++++++ .../src/ByteCodeEncryptTest/ByteCodeTest.luac | Bin 0 -> 1120 bytes tests/lua-tests/src/controller.lua | 91 +++++++-------- tests/lua-tests/src/mainMenu.lua | 2 + 6 files changed, 156 insertions(+), 45 deletions(-) create mode 100644 tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeAndEncryptTest.luac create mode 100644 tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeEncryptTest.lua create mode 100644 tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeTest.luac diff --git a/tests/lua-tests/project/Classes/AppDelegate.cpp b/tests/lua-tests/project/Classes/AppDelegate.cpp index cbcd0f6821..3bad5648b8 100644 --- a/tests/lua-tests/project/Classes/AppDelegate.cpp +++ b/tests/lua-tests/project/Classes/AppDelegate.cpp @@ -47,9 +47,11 @@ bool AppDelegate::applicationDidFinishLaunching() // register lua engine LuaEngine* pEngine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); + + LuaStack* stack = pEngine->getLuaStack(); + stack->setXXTEAKeyAndSign("2dxLua", strlen("2dxLua"), "XXTEA", strlen("XXTEA")); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID ||CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) - LuaStack* stack = pEngine->getLuaStack(); register_assetsmanager_test_sample(stack->getLuaState()); #endif diff --git a/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeAndEncryptTest.luac b/tests/lua-tests/src/ByteCodeEncryptT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?lJ6Uq#@v3N30)Wzxy_eiDN&e$`ky~I0V|xE-9bSWL!n7PS;23g8G5%0WFe8X zKTck%u?CV3?l~HOntQxvPhJw=8|#tcYjdSfKXW7CIx8m&b`*yhPrd^U@|GmXUzcmh z@5~(?(`j ((ByteCodeEncryptEnum.TEST_MAX_COUNT + 1) * LINE_SPACE - winSize.height) then + menu:setPosition(0, ((ByteCodeEncryptEnum.TEST_MAX_COUNT + 1) * LINE_SPACE - winSize.height)) + return + end + + menu:setPosition(curPosx, nextPosy) + beginPos = {x = location.x, y = location.y} + end + + local listener = cc.EventListenerTouchAllAtOnce:create() + listener:registerScriptHandler(onTouchesBegan,cc.Handler.EVENT_TOUCHES_BEGAN ) + listener:registerScriptHandler(onTouchesMoved,cc.Handler.EVENT_TOUCH_MOVED ) + + local eventDispatcher = layer:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layer) + + return layer +end +------------------------------------- +-- ByteCodeEncrypt Test +------------------------------------- +function ByteCodeEncryptTestMain() + local scene = cc.Scene:create() + + scene:addChild(byteCodeEncryptMainLayer()) + scene:addChild(CreateBackMenuItem()) + + return scene +end diff --git a/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeTest.luac b/tests/lua-tests/src/ByteCodeEncryptTest/ByteCodeTest.luac new file mode 100644 index 0000000000000000000000000000000000000000..9f782fc43131398463295b51dad5ec5dba9d60ed GIT binary patch literal 1120 zcmZvc&2HQ_5XWaok(9`_O(${fG!C#AV;$rY2P$-mfH7hlz>drI>l_2BSL`;EsHD1 z5*fSRCuljvlI>eS*zVn8Ue)fbcCE7)F1%}pP_?z&_}cfb4qdP6djEJC+?#IZzG>@z zxd>A?gb$T(|B?tB@KpSP5noU_i*aSt3S)WP6Xphc*MeBLlQZ%&$t-8IDt3^hkc$i^ zavw@2m`%veHOmFX2_p_Az@ehn1&3E0@!CJS^%rsjcO}X~ZQ_n%>MoA*`4(6~eQ}OC zjbCudZNh0){6JX9C2`e={KTdDMWT65yh0ionTIKHC2xPixLYX_X}2BYBYSL>B(v{)L>Rd-vEG#qUNt zvnl1Pk<2q7?dw@>e6k0aP8H*;4WiG77y@j+W2Aolb^fs=V}<&-Q|Mzv+?g!3W>9a`BK(uiLum`qR$0!45xG5r0~RW;+U_CSgQHJg9qD z1^3B^W;#95@2hh+-y%hQ@@;JTUU8Z09132#s5D%yR)6#4boTNi2^$kI_bJOp 320 then - local searchPaths = {} - table.insert(searchPaths, "hd") - fileUtils:setSearchPaths(searchPaths) -end local targetPlatform = cc.Application:getInstance():getTargetPlatform() -local resPrefix = "" -if cc.PLATFORM_OS_IPAD == targetPlatform or cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_MAC == targetPlatform then - resPrefix = "" -else - resPrefix = "res/" -end -local searchPaths = fileUtils:getSearchPaths() -table.insert(searchPaths, 1, resPrefix) -table.insert(searchPaths, 1, resPrefix .. "cocosbuilderRes") +local dd = glView:getDesignResolutionSize() if screenSize.height > 320 then - table.insert(searchPaths, 1, resPrefix .. "hd") - table.insert(searchPaths, 1, resPrefix .. "ccs-res") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/Images") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ArmatureComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/AttributeComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/BackgroundComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/EffectComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/LoadSceneEdtiorFileTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ParticleComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/SpriteComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TmxMapComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/UIComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TriggerTest") -else - table.insert(searchPaths, 1, resPrefix .. "ccs-res/Images") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ArmatureComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/AttributeComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/BackgroundComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/EffectComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/LoadSceneEdtiorFileTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ParticleComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/SpriteComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TmxMapComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/UIComponentTest") - table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TriggerTest") + local resourceSize = {width = 960, height = 640} + local rate = resourceSize.height/screenSize.height + cc.Director:getInstance():setContentScaleFactor(resourceSize.height/designSize.height); +end +glView:setDesignResolutionSize(designSize.width, designSize.height, 0); + +local function addSearchPath(resPrefix, height) + if height > 320 then + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/ArmatureComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/AttributeComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/BackgroundComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/EffectComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/LoadSceneEdtiorFileTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/ParticleComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/SpriteComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/TmxMapComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/UIComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/TriggerTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/Images") + fileUtils:addSearchPath(resPrefix .. "ccs-res/hd") + fileUtils:addSearchPath(resPrefix .. "ccs-res") + fileUtils:addSearchPath(resPrefix .. "hd") + fileUtils:addSearchPath("hd") + else + fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/ArmatureComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/AttributeComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/BackgroundComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/EffectComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/LoadSceneEdtiorFileTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/ParticleComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/SpriteComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/TmxMapComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/UIComponentTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/TriggerTest") + fileUtils:addSearchPath(resPrefix .. "ccs-res/Images") + end + + fileUtils:addSearchPath("cocosbuilderRes") + fileUtils:addSearchPath(resPrefix) end -fileUtils:setSearchPaths(searchPaths) +addSearchPath("res/", screenSize.height) +addSearchPath("", screenSize.height) + + +require "src/mainMenu" local scene = cc.Scene:create() scene:addChild(CreateTestMenu()) diff --git a/tests/lua-tests/src/mainMenu.lua b/tests/lua-tests/src/mainMenu.lua index 8d2241a1f4..ce3f86c60c 100644 --- a/tests/lua-tests/src/mainMenu.lua +++ b/tests/lua-tests/src/mainMenu.lua @@ -15,6 +15,7 @@ require "src/ActionsProgressTest/ActionsProgressTest" require "src/ActionsTest/ActionsTest" require "src/AssetsManagerTest/AssetsManagerTest" require "src/BugsTest/BugsTest" +require "src/ByteCodeEncryptTest/ByteCodeEncryptTest" require "src/ClickAndMoveTest/ClickAndMoveTest" require "src/CocosDenshionTest/CocosDenshionTest" require "src/CocoStudioTest/CocoStudioTest" @@ -70,6 +71,7 @@ local _allTests = { { isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain }, { isSupported = false, name = "Box2dTestBed" , create_func= Box2dTestBedMain }, { isSupported = true, name = "BugsTest" , create_func= BugsTestMain }, + { isSupported = true, name = "ByteCodeEncryptTest" , create_func= ByteCodeEncryptTestMain }, { isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain }, { isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest }, { isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain }, From f6f75e88101832d4c6a90f9b730c1720b86dfd4a Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Tue, 10 Jun 2014 10:01:08 +0800 Subject: [PATCH 2/2] Update controller.lua --- tests/lua-tests/src/controller.lua | 91 +++++++++++++++--------------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/tests/lua-tests/src/controller.lua b/tests/lua-tests/src/controller.lua index 34b34b3924..d5f4d0469e 100644 --- a/tests/lua-tests/src/controller.lua +++ b/tests/lua-tests/src/controller.lua @@ -3,68 +3,65 @@ collectgarbage("setpause", 100) collectgarbage("setstepmul", 5000) - +require "src/mainMenu" ---------------- + + -- run local glView = cc.Director:getInstance():getOpenGLView() - local screenSize = glView:getFrameSize() local designSize = {width = 480, height = 320} local fileUtils = cc.FileUtils:getInstance() +if screenSize.height > 320 then + local searchPaths = {} + table.insert(searchPaths, "hd") + fileUtils:setSearchPaths(searchPaths) +end local targetPlatform = cc.Application:getInstance():getTargetPlatform() +local resPrefix = "" +if cc.PLATFORM_OS_IPAD == targetPlatform or cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_MAC == targetPlatform then + resPrefix = "" +else + resPrefix = "res/" +end -local dd = glView:getDesignResolutionSize() +local searchPaths = fileUtils:getSearchPaths() +table.insert(searchPaths, 1, resPrefix) +table.insert(searchPaths, 1, resPrefix .. "cocosbuilderRes") if screenSize.height > 320 then - local resourceSize = {width = 960, height = 640} - local rate = resourceSize.height/screenSize.height - cc.Director:getInstance():setContentScaleFactor(resourceSize.height/designSize.height); -end -glView:setDesignResolutionSize(designSize.width, designSize.height, 0); - -local function addSearchPath(resPrefix, height) - if height > 320 then - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/ArmatureComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/AttributeComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/BackgroundComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/EffectComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/LoadSceneEdtiorFileTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/ParticleComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/SpriteComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/TmxMapComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/UIComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/scenetest/TriggerTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd/Images") - fileUtils:addSearchPath(resPrefix .. "ccs-res/hd") - fileUtils:addSearchPath(resPrefix .. "ccs-res") - fileUtils:addSearchPath(resPrefix .. "hd") - fileUtils:addSearchPath("hd") - else - fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/ArmatureComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/AttributeComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/BackgroundComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/EffectComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/LoadSceneEdtiorFileTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/ParticleComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/SpriteComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/TmxMapComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/UIComponentTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/scenetest/TriggerTest") - fileUtils:addSearchPath(resPrefix .. "ccs-res/Images") - end - - fileUtils:addSearchPath("cocosbuilderRes") - fileUtils:addSearchPath(resPrefix) + table.insert(searchPaths, 1, resPrefix .. "hd") + table.insert(searchPaths, 1, resPrefix .. "ccs-res") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/Images") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ArmatureComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/AttributeComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/BackgroundComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/EffectComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/LoadSceneEdtiorFileTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ParticleComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/SpriteComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TmxMapComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/UIComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TriggerTest") +else + table.insert(searchPaths, 1, resPrefix .. "ccs-res/Images") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ArmatureComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/AttributeComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/BackgroundComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/EffectComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/LoadSceneEdtiorFileTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ParticleComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/SpriteComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TmxMapComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/UIComponentTest") + table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TriggerTest") end -addSearchPath("res/", screenSize.height) -addSearchPath("", screenSize.height) - - -require "src/mainMenu" +fileUtils:setSearchPaths(searchPaths) local scene = cc.Scene:create() scene:addChild(CreateTestMenu())