Skip to content

Commit 002dcf2

Browse files
PatriceJianghuangwei1024
authored andcommitted
cpp-tests/Bugs add titles & lua bugs/1174 decrease loop count (cocos2d#19205)
* cpp-tests/Bugs add titles & lua bugs/1174 decrease loop count * reduce loop times to 1000
1 parent 503ce50 commit 002dcf2

File tree

19 files changed

+99
-34
lines changed

19 files changed

+99
-34
lines changed

cocos/platform/android/CCFileUtils-android.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ bool FileUtilsAndroid::isDirectoryExistInternal(const std::string& dirPath) cons
229229
{
230230
// find it in apk's assets dir
231231
// Found "assets/" at the beginning of the path and we don't want it
232-
CCLOG("find in apk dirPath(%s)", s);
232+
//CCLOG("find in apk dirPath(%s)", s);
233233
if (dirPath.find(ASSETS_FOLDER_NAME) == 0)
234234
{
235235
s += ASSETS_FOLDER_NAME_LENGTH;

cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8540,6 +8540,75 @@ static int tolua_cocos2d_Vec3_cross(lua_State* tolua_S)
85408540
#endif
85418541
}
85428542

8543+
static int tolua_cocos2d_random01(lua_State* tolua_S)
8544+
{
8545+
lua_pushnumber(tolua_S, CCRANDOM_0_1());
8546+
return 1;
8547+
}
8548+
8549+
static int tolua_cocos2d_Vec2_isLineIntersect(lua_State* tolua_S)
8550+
{
8551+
int argc = lua_gettop(tolua_S);
8552+
8553+
#if COCOS2D_DEBUG >= 1
8554+
tolua_Error tolua_err;
8555+
#endif
8556+
8557+
if (4 == argc)
8558+
{
8559+
#if COCOS2D_DEBUG >= 1
8560+
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
8561+
!tolua_istable(tolua_S, 2, 0, &tolua_err) ||
8562+
!tolua_istable(tolua_S, 3, 0, &tolua_err)||
8563+
!tolua_istable(tolua_S, 4, 0, &tolua_err))
8564+
goto tolua_lerror;
8565+
else
8566+
#endif
8567+
{
8568+
cocos2d::Vec2 x1,y1;
8569+
cocos2d::Vec2 x2,y2;
8570+
8571+
float s =0.0f, t = 0.0f;
8572+
8573+
bool ok = true;
8574+
8575+
ok &= luaval_to_vec2(tolua_S, 1, &x1);
8576+
if (!ok)
8577+
return 0;
8578+
8579+
ok &= luaval_to_vec2(tolua_S, 2, &y1);
8580+
if (!ok)
8581+
return 0;
8582+
8583+
ok &= luaval_to_vec2(tolua_S, 3, &x2);
8584+
if (!ok)
8585+
return 0;
8586+
8587+
ok &= luaval_to_vec2(tolua_S, 4, &y2);
8588+
if (!ok)
8589+
return 0;
8590+
8591+
bool intersects = Vec2::isLineIntersect(x1, y1, x2, y2, &s, &t);
8592+
8593+
lua_pushboolean(tolua_S, intersects);
8594+
lua_pushnumber(tolua_S, s);
8595+
lua_pushnumber(tolua_S, t);
8596+
return 3;
8597+
}
8598+
}else
8599+
{
8600+
lua_pushboolean(tolua_S, false);
8601+
lua_pushnumber(tolua_S, 0);
8602+
lua_pushnumber(tolua_S, 0);
8603+
return 3;
8604+
}
8605+
#if COCOS2D_DEBUG >= 1
8606+
tolua_lerror:
8607+
tolua_error(tolua_S,"#ferror in function 'vec2_isLineIntersect'.",&tolua_err);
8608+
return 0;
8609+
#endif
8610+
}
8611+
85438612
static int tolua_cocos2d_Mat4_multiply(lua_State* tolua_S)
85448613
{
85458614
#if COCOS2D_DEBUG >= 1
@@ -8825,6 +8894,8 @@ int register_all_cocos2dx_math_manual(lua_State* tolua_S)
88258894
tolua_function(tolua_S, "mat4_createTranslation", tolua_cocos2d_Mat4_createTranslation);
88268895
tolua_function(tolua_S, "mat4_createRotation", tolua_cocos2d_Mat4_createRotation);
88278896
tolua_function(tolua_S, "vec3_cross", tolua_cocos2d_Vec3_cross);
8897+
tolua_function(tolua_S, "vec2_isLineIntersect", tolua_cocos2d_Vec2_isLineIntersect);
8898+
tolua_function(tolua_S, "cc_mathutils_random", tolua_cocos2d_random01);
88288899
tolua_endmodule(tolua_S);
88298900
return 0;
88308901
}

cocos/scripting/lua-bindings/script/cocos2d/Cocos2d.lua

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11

22
cc = cc or {}
33

4+
5+
function cc.random()
6+
return cc_mathutils_random()
7+
end
8+
49
function cc.clampf(value, min_inclusive, max_inclusive)
510
-- body
611
local temp = 0
@@ -89,33 +94,7 @@ function cc.pGetDistance(startP,endP)
8994
end
9095

9196
function cc.pIsLineIntersect(A, B, C, D, s, t)
92-
if ((A.x == B.x) and (A.y == B.y)) or ((C.x == D.x) and (C.y == D.y))then
93-
return false, s, t
94-
end
95-
96-
local BAx = B.x - A.x
97-
local BAy = B.y - A.y
98-
local DCx = D.x - C.x
99-
local DCy = D.y - C.y
100-
local ACx = A.x - C.x
101-
local ACy = A.y - C.y
102-
103-
local denom = DCy * BAx - DCx * BAy
104-
s = DCx * ACy - DCy * ACx
105-
t = BAx * ACy - BAy * ACx
106-
107-
if (denom == 0) then
108-
if (s == 0 or t == 0) then
109-
return true, s , t
110-
end
111-
112-
return false, s, t
113-
end
114-
115-
s = s / denom
116-
t = t / denom
117-
118-
return true,s,t
97+
return vec2_isLineIntersect(A, B, C, D)
11998
end
12099

121100
function cc.pPerp(pt)

tests/cpp-tests/Classes/BugsTest/Bug-1159.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Bug1159Layer : public BugsTestBase
3232
public:
3333
virtual bool init() override;
3434
virtual void onExit() override;
35+
virtual std::string title() const override { return "Bug1159";}
3536

3637
void callBack(cocos2d::Ref* sender);
3738

tests/cpp-tests/Classes/BugsTest/Bug-1174.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class Bug1174Layer : public BugsTestBase
3131
{
3232
public:
3333
CREATE_FUNC(Bug1174Layer);
34-
34+
virtual std::string title() const override { return "Bug1174";}
35+
virtual std::string subtitle() const override {return "view console output";}
3536
virtual bool init() override;
3637
};
3738

tests/cpp-tests/Classes/BugsTest/Bug-12847.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Bug12847Layer : public BugsTestBase
3434

3535
virtual bool init() override;
3636

37+
virtual std::string title() const override { return "12874";}
3738
protected:
3839
virtual void update(float dt) override;
3940
virtual void onEnter() override;

tests/cpp-tests/Classes/BugsTest/Bug-14327.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Bug14327Layer : public BugsTestBase, public cocos2d::ui::EditBoxDelegate
3535
CREATE_FUNC(Bug14327Layer);
3636

3737
virtual bool init() override;
38+
virtual std::string title() const override { return "Bug14327";}
3839

3940
virtual void editBoxEditingDidBegin(cocos2d::ui::EditBox* editBox) override;
4041
virtual void editBoxEditingDidEnd(cocos2d::ui::EditBox* editBox) override;

tests/cpp-tests/Classes/BugsTest/Bug-15594.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Bug15594Layer : public BugsTestBase
3232
{
3333
public:
3434
CREATE_FUNC(Bug15594Layer);
35+
virtual std::string title() const override { return "Bug15594";}
3536

3637
virtual bool init() override;
3738
};

tests/cpp-tests/Classes/BugsTest/Bug-15776.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class Bug15776Layer : public BugsTestBase
4141
CREATE_FUNC(Bug15776Layer);
4242

4343
virtual bool init() override;
44-
4544
virtual std::string title() const override;
4645
virtual std::string subtitle() const override;
4746
};

tests/cpp-tests/Classes/BugsTest/Bug-350.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Bug350Layer : public BugsTestBase
3333
CREATE_FUNC(Bug350Layer);
3434

3535
virtual bool init() override;
36+
virtual std::string title() const override { return "Bug350";}
3637
};
3738

3839
#endif // __BUG_350_H__

0 commit comments

Comments
 (0)