提交 8fa05594 编写于 作者: X xia-liyun

format code:zhanghanlin9@huawei.com

Signed-off-by: Nxia-liyun <xialiyun@huawei.com>
Change-Id: I9923661a13f8e3858759e71a5b4238afcdfc6222
上级 0c8289e5
...@@ -38,20 +38,20 @@ ...@@ -38,20 +38,20 @@
#include "service.h" #include "service.h"
#include "samgr_lite.h" #include "samgr_lite.h"
#define TEST_APP_ID "com.permission.test" const char[] TEST_APP_ID = "com.permission.test";
#define TEST_APP_ID2 "com.permission.test2" const char[] TEST_APP_ID2 = "com.permission.test2";
#define SUBTEST_APP_ID "com.permission.subtest" const char[] SUBTEST_APP_ID = "com.permission.subtest";
#define TEST_APP_SHORT "a" const char[] TEST_APP_SHORT = "a";
#define TEST_APP_LONG "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" const char[] TEST_APP_LONG = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
#define TEST_APP_PATH "/storage/app/etc/permissions/com.permission.test" const char[] TEST_APP_PATH = "/storage/app/etc/permissions/com.permission.test";
#define TEST_APP_INVALID "com.permission.!@#$%^&*()_+" const char[] TEST_APP_INVALID = "com.permission.!@#$%^&*()_+";
#define TEST_APP_NOT_EXIST "com.permission.onetwothree" const char[] TEST_APP_NOT_EXIST = "com.permission.onetwothree";
#define PERMISSION_UNDEFINED "ohos.permission.TEST" const char[] PERMISSION_UNDEFINED = "ohos.permission.TEST";
#define PERMISSION_TOOLONG "ohos.permission.balabalabalabalabalabalabalabalabalabala" const char[] PERMISSION_TOOLONG = "ohos.permission.balabalabalabalabalabalabalabalabalabala";
#define PERMISSION_EMPTY "" const char[] PERMISSION_EMPTY = "";
#define PERMISSION_UNSUPPORTED "!@#$%^&*()_+" const char[] PERMISSION_UNSUPPORTED = "!@#$%^&*()_+";
#define ETC_PREFIX "/storage/app/etc" const char[] ETC_PREFIX = "/storage/app/etc";
#define PERMISSION_PREFIX "/storage/app/etc/permissions" const char[] PERMISSION_PREFIX = "/storage/app/etc/permissions";
const int SLEEP_TIME = 5; const int SLEEP_TIME = 5;
const int TEST_TASKID = 1000; const int TEST_TASKID = 1000;
...@@ -67,19 +67,19 @@ const int MAX_PID = 0x7fffffff; ...@@ -67,19 +67,19 @@ const int MAX_PID = 0x7fffffff;
const int MIN_PID = 0; const int MIN_PID = 0;
const int ABNORMAL_PKG_NUM = 5; const int ABNORMAL_PKG_NUM = 5;
const int DIR_MODE = 777; const int DIR_MODE = 777;
const int FLAG_NOT_EXIST=123; const int FLAG_NOT_EXIST = 123;
const int PERFORMANCE_RUN_TIMES=10000; const int PERFORMANCE_RUN_TIMES = 10000;
const int MILLISECOND=1000; const int MILLISECOND = 1000;
int IsUserGrant(const char* pname); int IsUserGrant(const char *pname);
int CheckPermData(const PermissionTrans* pt, const PermissionSaved* ps, int CheckPermData(const PermissionTrans *pt, const PermissionSaved *ps,
const PermissionSaved* pre, int len, int plen); const PermissionSaved *pre, int len, int plen);
void ClrPers(PermissionSaved* &permissions); void ClrPers(PermissionSaved *&permissions);
void CheckAppPermission(const char *identifier, int expRet, int expNum, const PermissionTrans* installPers, void CheckAppPermission(const char *identifier, int expRet, int expNum, const PermissionTrans *installPers,
const PermissionSaved* lastPers = nullptr, int lastLen = 0); const PermissionSaved *lastPers = nullptr, int lastLen = 0);
void SubTestWithoutCheck(const char *identifier, int taskID); void SubTestWithoutCheck(const char *identifier, int taskID);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
#include "ActsPMSTest.h" #include "ActsPMSTest.h"
#include<sys/time.h> #include <sys/time.h>
using namespace std; using namespace std;
using namespace testing::ext; using namespace testing::ext;
...@@ -68,13 +68,14 @@ static PermissionTrans g_systemPers[] = { ...@@ -68,13 +68,14 @@ static PermissionTrans g_systemPers[] = {
}, },
}; };
class ActsPMSUpdatePermissionTest:public testing::Test{ class ActsPMSUpdatePermissionTest : public testing::Test
{
protected: protected:
static void SetUpTestCase(void) static void SetUpTestCase(void)
{ {
CreateAppDir(); CreateAppDir();
IUnknown *iUnknown = SAMGR_GetInstance()->GetFeatureApi(PERMISSION_SERVICE, PERM_INNER); IUnknown *iUnknown = SAMGR_GetInstance()->GetFeatureApi(PERMISSION_SERVICE, PERM_INNER);
iUnknown->QueryInterface(iUnknown, DEFAULT_VERSION, (void **) &g_interface); iUnknown->QueryInterface(iUnknown, DEFAULT_VERSION, (void **)&g_interface);
setuid(0); setuid(0);
} }
static void TearDownTestCase(void) {} static void TearDownTestCase(void) {}
...@@ -92,8 +93,8 @@ protected: ...@@ -92,8 +93,8 @@ protected:
long GetCurrentTimeMillis() long GetCurrentTimeMillis()
{ {
struct timeval current; struct timeval current;
gettimeofday(&current,NULL); gettimeofday(&current, NULL);
return current.tv_sec*MILLISECOND+current.tv_usec/MILLISECOND; return current.tv_sec * MILLISECOND + current.tv_usec / MILLISECOND;
} }
/** /**
...@@ -105,22 +106,23 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_001, Function | Med ...@@ -105,22 +106,23 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_001, Function | Med
{ {
SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL); SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL);
PermissionSaved *permissions=NULL; PermissionSaved *permissions = NULL;
int permNum=0; int permNum = 0;
int ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); int ret = g_interface->QueryPermission(TEST_APP_ID, &permissions, &permNum);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "query ret=" << ret << endl;
EXPECT_EQ(permNum,SYS_PERM_NUM)<<"permNum ="<<permNum<<endl; EXPECT_EQ(permNum, SYS_PERM_NUM) << "permNum =" << permNum << endl;
if(permissions!=NULL){ if (permissions != NULL)
EXPECT_EQ(permissions[0].flags,PMS_FLAG_DEFAULT)<<"flags ="<<permissions[0].flags<<endl; {
EXPECT_EQ(permissions[0].flags, PMS_FLAG_DEFAULT) << "flags =" << permissions[0].flags << endl;
} }
ClrPers(permissions); ClrPers(permissions);
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,g_systemPers[0].name,PMS_FLAG_DEFAULT); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, g_systemPers[0].name, PMS_FLAG_DEFAULT);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "update perms flag ret =" << ret << endl;
ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); ret = g_interface->QueryPermission(TEST_APP_ID, &permissions, &permNum);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "query ret=" << ret << endl;
EXPECT_EQ(permNum,SYS_PERM_NUM)<<"permNum ="<<permNum<<endl; EXPECT_EQ(permNum, SYS_PERM_NUM) << "permNum =" << permNum << endl;
ClrPers(permissions); ClrPers(permissions);
UnLoadPermissions(TEST_TASKID); UnLoadPermissions(TEST_TASKID);
...@@ -136,22 +138,23 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_002, Function | Med ...@@ -136,22 +138,23 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_002, Function | Med
{ {
SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL); SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL);
PermissionSaved *permissions=NULL; PermissionSaved *permissions = NULL;
int permNum=0; int permNum = 0;
int ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); int ret = g_interface->QueryPermission(TEST_APP_ID, &permissions, &permNum);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "query ret=" << ret << endl;
EXPECT_EQ(permNum,SYS_PERM_NUM)<<"permNum ="<<permNum<<endl; EXPECT_EQ(permNum, SYS_PERM_NUM) << "permNum =" << permNum << endl;
if(permissions!=NULL){ if (permissions != NULL)
EXPECT_EQ(permissions[0].flags,PMS_FLAG_DEFAULT)<<"flags ="<<permissions[0].flags<<endl; {
EXPECT_EQ(permissions[0].flags, PMS_FLAG_DEFAULT) << "flags =" << permissions[0].flags << endl;
} }
ClrPers(permissions); ClrPers(permissions);
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,g_systemPers[0].name,PMS_FLAG_USER_FIXED); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, g_systemPers[0].name, PMS_FLAG_USER_FIXED);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "update perms flag ret =" << ret << endl;
ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); ret = g_interface->QueryPermission(TEST_APP_ID, &permissions, &permNum);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "query ret=" << ret << endl;
EXPECT_EQ(permNum,SYS_PERM_NUM)<<"permNum ="<<permNum<<endl; EXPECT_EQ(permNum, SYS_PERM_NUM) << "permNum =" << permNum << endl;
ClrPers(permissions); ClrPers(permissions);
UnLoadPermissions(TEST_TASKID); UnLoadPermissions(TEST_TASKID);
...@@ -167,27 +170,28 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_003, Function | Med ...@@ -167,27 +170,28 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_003, Function | Med
{ {
SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL); SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL);
PermissionSaved *permissions=NULL; PermissionSaved *permissions = NULL;
int permNum=0; int permNum = 0;
int ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); int ret = g_interface->QueryPermission(TEST_APP_ID, &permissions, &permNum);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "query ret=" << ret << endl;
EXPECT_EQ(permNum,SYS_PERM_NUM)<<"permNum ="<<permNum<<endl; EXPECT_EQ(permNum, SYS_PERM_NUM) << "permNum =" << permNum << endl;
if(permissions!=NULL){ if (permissions != NULL)
EXPECT_EQ(permissions[0].flags,PMS_FLAG_DEFAULT)<<"flags ="<<permissions[0].flags<<endl; {
EXPECT_EQ(permissions[0].flags, PMS_FLAG_DEFAULT) << "flags =" << permissions[0].flags << endl;
} }
ClrPers(permissions); ClrPers(permissions);
//pkg name not exist // pkg name not exist
ret=g_interface->UpdatePermissionFlags(TEST_APP_NOT_EXIST,g_systemPers[0].name,PMS_FLAG_USER_FIXED); ret = g_interface->UpdatePermissionFlags(TEST_APP_NOT_EXIST, g_systemPers[0].name, PMS_FLAG_USER_FIXED);
EXPECT_EQ(ret,PERM_ERRORCODE_FILE_NOT_EXIST)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_FILE_NOT_EXIST) << "update perms flag ret =" << ret << endl;
//pkg perm not exist // pkg perm not exist
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,PERMISSION_UNDEFINED,PMS_FLAG_USER_FIXED); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, PERMISSION_UNDEFINED, PMS_FLAG_USER_FIXED);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "update perms flag ret =" << ret << endl;
//pkg flag not exist // pkg flag not exist
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,g_systemPers[0].name,FLAG_NOT_EXIST); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, g_systemPers[0].name, FLAG_NOT_EXIST);
EXPECT_EQ(ret,PERM_ERRORCODE_INVALID_PARAMS)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_INVALID_PARAMS) << "update perms flag ret =" << ret << endl;
ClrPers(permissions); ClrPers(permissions);
UnLoadPermissions(TEST_TASKID); UnLoadPermissions(TEST_TASKID);
...@@ -203,27 +207,28 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_004, Function | Med ...@@ -203,27 +207,28 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_004, Function | Med
{ {
SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL); SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL);
PermissionSaved *permissions=NULL; PermissionSaved *permissions = NULL;
int permNum=0; int permNum = 0;
int ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); int ret = g_interface->QueryPermission(TEST_APP_ID, &permissions, &permNum);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "query ret=" << ret << endl;
EXPECT_EQ(permNum,SYS_PERM_NUM)<<"permNum ="<<permNum<<endl; EXPECT_EQ(permNum, SYS_PERM_NUM) << "permNum =" << permNum << endl;
if(permissions!=NULL){ if (permissions != NULL)
EXPECT_EQ(permissions[0].flags,PMS_FLAG_DEFAULT)<<"flags ="<<permissions[0].flags<<endl; {
EXPECT_EQ(permissions[0].flags, PMS_FLAG_DEFAULT) << "flags =" << permissions[0].flags << endl;
} }
ClrPers(permissions); ClrPers(permissions);
//pkg name empty // pkg name empty
ret=g_interface->UpdatePermissionFlags(NULL,g_systemPers[0].name,PMS_FLAG_USER_FIXED); ret = g_interface->UpdatePermissionFlags(NULL, g_systemPers[0].name, PMS_FLAG_USER_FIXED);
EXPECT_EQ(ret,PERM_ERRORCODE_INVALID_PARAMS)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_INVALID_PARAMS) << "update perms flag ret =" << ret << endl;
//pkg perm empty // pkg perm empty
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,NULL,PMS_FLAG_USER_FIXED); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, NULL, PMS_FLAG_USER_FIXED);
EXPECT_EQ(ret,PERM_ERRORCODE_INVALID_PARAMS)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_INVALID_PARAMS) << "update perms flag ret =" << ret << endl;
//pkg flag empty // pkg flag empty
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,g_systemPers[0].name,NULL); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, g_systemPers[0].name, NULL);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "update perms flag ret =" << ret << endl;
ClrPers(permissions); ClrPers(permissions);
UnLoadPermissions(TEST_TASKID); UnLoadPermissions(TEST_TASKID);
...@@ -239,23 +244,24 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_005, Function | Med ...@@ -239,23 +244,24 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_005, Function | Med
{ {
SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL); SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL);
PermissionSaved *permissions=NULL; PermissionSaved *permissions = NULL;
int permNum=0; int permNum = 0;
int ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); int ret = g_interface->QueryPermission(TEST_APP_ID, &permissions, &permNum);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "query ret=" << ret << endl;
EXPECT_EQ(permNum,SYS_PERM_NUM)<<"permNum ="<<permNum<<endl; EXPECT_EQ(permNum, SYS_PERM_NUM) << "permNum =" << permNum << endl;
if(permissions!=NULL){ if (permissions != NULL)
EXPECT_EQ(permissions[0].flags,PMS_FLAG_DEFAULT)<<"flags ="<<permissions[0].flags<<endl; {
EXPECT_EQ(permissions[0].flags, PMS_FLAG_DEFAULT) << "flags =" << permissions[0].flags << endl;
} }
ClrPers(permissions); ClrPers(permissions);
//pkg name invalid // pkg name invalid
ret=g_interface->UpdatePermissionFlags(TEST_APP_INVALID,g_systemPers[0].name,PMS_FLAG_USER_FIXED); ret = g_interface->UpdatePermissionFlags(TEST_APP_INVALID, g_systemPers[0].name, PMS_FLAG_USER_FIXED);
EXPECT_EQ(ret,PERM_ERRORCODE_FILE_NOT_EXIST)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_FILE_NOT_EXIST) << "update perms flag ret =" << ret << endl;
//pkg perm invalid // pkg perm invalid
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,PERMISSION_UNSUPPORTED,PMS_FLAG_USER_FIXED); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, PERMISSION_UNSUPPORTED, PMS_FLAG_USER_FIXED);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "update perms flag ret =" << ret << endl;
ClrPers(permissions); ClrPers(permissions);
UnLoadPermissions(TEST_TASKID); UnLoadPermissions(TEST_TASKID);
...@@ -271,22 +277,23 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_006, Function | Med ...@@ -271,22 +277,23 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_006, Function | Med
{ {
SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL); SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL);
PermissionSaved *permissions=NULL; PermissionSaved *permissions = NULL;
int permNum=0; int permNum = 0;
int ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); int ret = g_interface->QueryPermission(TEST_APP_ID, &permissions, &permNum);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "query ret=" << ret << endl;
EXPECT_EQ(permNum,SYS_PERM_NUM)<<"permNum ="<<permNum<<endl; EXPECT_EQ(permNum, SYS_PERM_NUM) << "permNum =" << permNum << endl;
if(permissions!=NULL){ if (permissions != NULL)
EXPECT_EQ(permissions[0].flags,PMS_FLAG_DEFAULT)<<"flags ="<<permissions[0].flags<<endl; {
EXPECT_EQ(permissions[0].flags, PMS_FLAG_DEFAULT) << "flags =" << permissions[0].flags << endl;
} }
ClrPers(permissions); ClrPers(permissions);
for(int i=0; i<PERFORMANCE_RUN_TIMES/2; i++) for (int i = 0; i < PERFORMANCE_RUN_TIMES / 2; i++)
{ {
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,g_systemPers[0].name,PMS_FLAG_DEFAULT); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, g_systemPers[0].name, PMS_FLAG_DEFAULT);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "update perms flag ret =" << ret << endl;
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,g_systemPers[0].name,PMS_FLAG_USER_FIXED); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, g_systemPers[0].name, PMS_FLAG_USER_FIXED);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"update perms flag ret ="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "update perms flag ret =" << ret << endl;
} }
ClrPers(permissions); ClrPers(permissions);
...@@ -301,27 +308,28 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_006, Function | Med ...@@ -301,27 +308,28 @@ HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_006, Function | Med
*/ */
HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_007, Function | MediumTest | Level2) HWTEST_F(ActsPMSUpdatePermissionTest, testSecPMUpdatePMFlags_007, Function | MediumTest | Level2)
{ {
SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL); SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL);
PermissionSaved *permissions=NULL; PermissionSaved *permissions = NULL;
int permNum=0; int permNum = 0;
int ret=g_interface->QueryPermission(TEST_APP_ID,&permissions,&permNum); int ret = g_interface->QueryPermission(TEST_APP_ID, &permissions, &permNum);
EXPECT_EQ(ret,PERM_ERRORCODE_SUCCESS)<<"query ret="<<ret<<endl; EXPECT_EQ(ret, PERM_ERRORCODE_SUCCESS) << "query ret=" << ret << endl;
EXPECT_EQ(permNum,SYS_PERM_NUM)<<"permNum ="<<permNum<<endl; EXPECT_EQ(permNum, SYS_PERM_NUM) << "permNum =" << permNum << endl;
if(permissions!=NULL){ if (permissions != NULL)
EXPECT_EQ(permissions[0].flags,PMS_FLAG_DEFAULT)<<"flags ="<<permissions[0].flags<<endl; {
EXPECT_EQ(permissions[0].flags, PMS_FLAG_DEFAULT) << "flags =" << permissions[0].flags << endl;
} }
ClrPers(permissions); ClrPers(permissions);
long startTime=GetCurrentTimeMillis(); long startTime = GetCurrentTimeMillis();
for(int i=0; i<PERFORMANCE_RUN_TIMES/2; i++) for (int i = 0; i < PERFORMANCE_RUN_TIMES / 2; i++)
{ {
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,g_systemPers[0].name,PMS_FLAG_DEFAULT); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, g_systemPers[0].name, PMS_FLAG_DEFAULT);
ret=g_interface->UpdatePermissionFlags(TEST_APP_ID,g_systemPers[0].name,PMS_FLAG_USER_FIXED); ret = g_interface->UpdatePermissionFlags(TEST_APP_ID, g_systemPers[0].name, PMS_FLAG_USER_FIXED);
} }
long timeCost=GetCurrentTimeMillis()-startTime; long timeCost = GetCurrentTimeMillis() - startTime;
long timeAvg=timeCost/10000; long timeAvg = timeCost / 10000;
EXPECT_LT(timeAvg,11)<<"avg times ="<<timeAvg<<endl; EXPECT_LT(timeAvg, 11) << "avg times =" << timeAvg << endl;
ClrPers(permissions); ClrPers(permissions);
UnLoadPermissions(TEST_TASKID); UnLoadPermissions(TEST_TASKID);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册