!247 codeCheck报警修改

Merge pull request !247 from 周柯/master
This commit is contained in:
openharmony_ci
2022-09-08 02:31:05 +00:00
committed by Gitee
6 changed files with 26 additions and 25 deletions
+7 -7
View File
@@ -117,7 +117,7 @@ namespace OHOS::uitest {
// emit handshake and wait-for first interaction established
LOG_I("Start checking CS-interaction");
if (!transceiver_->DiscoverPeer(WAIT_CONNECTION_TIMEOUT_MS)) {
LOG_E("Wait CS-interaction timed out in %{public}llu ms", (unsigned long long)WAIT_CONNECTION_TIMEOUT_MS);
LOG_E("Wait CS-interaction timed out in %{public}llu ms", WAIT_CONNECTION_TIMEOUT_MS);
return false;
}
// schedule connection-checking with auto-handshaking
@@ -132,19 +132,19 @@ namespace OHOS::uitest {
}
static unique_ptr<TransactionClientImpl> sClient = nullptr;
static atomic<bool> sSetupCalled = false;
static atomic<bool> g_sSetupCalled = false;
/**Exported transaction-client initialization callback function.*/
bool SetupTransactionEnv(string_view token)
{
if (!sSetupCalled.load()) {
if (!g_sSetupCalled.load()) {
if (sClient == nullptr) {
sClient = make_unique<TransactionClientImpl>(token);
}
if (!sClient->Initialize()) {
LOG_E("SetupTransactionEnv failed");
}
sSetupCalled.store(true);
g_sSetupCalled.store(true);
}
return true;
}
@@ -152,16 +152,16 @@ namespace OHOS::uitest {
/**Exported transaction client api-calling function.*/
void TransactionClientFunc(const ApiCallInfo& call, ApiReplyInfo& reply)
{
DCHECK(sClient != nullptr && sSetupCalled.load());
DCHECK(sClient != nullptr && g_sSetupCalled.load());
sClient->InvokeApi(call, reply);
}
/**Exported transaction-client dispose callback function.*/
void DisposeTransactionEnv()
{
if (sSetupCalled.load() && sClient != nullptr) {
if (g_sSetupCalled.load() && sClient != nullptr) {
sClient->Finalize();
sSetupCalled.store(false);
g_sSetupCalled.store(false);
}
}
}
+1
View File
@@ -42,6 +42,7 @@ namespace OHOS::uitest {
constexpr size_t INDEX_TWO = 2;
constexpr size_t INDEX_THREE = 3;
constexpr size_t INDEX_FOUR = 4;
constexpr int32_t NUM_TWO = 2;
/**Get current time millisecond.*/
inline uint64_t GetCurrentMillisecond()
+2 -2
View File
@@ -88,12 +88,12 @@ namespace OHOS::uitest {
FORCE_INLINE int32_t GetCenterX() const
{
return (left_ + right_) / 2;
return (left_ + right_) / NUM_TWO;
}
FORCE_INLINE int32_t GetCenterY() const
{
return (top_ + bottom_) / 2;
return (top_ + bottom_) / NUM_TWO;
}
FORCE_INLINE int32_t GetWidth() const
+6 -6
View File
@@ -39,7 +39,7 @@ namespace OHOS::uitest {
std::string_view message;
};
static const Operational g_operations[28] = {
static const Operational OPERATIONS[28] = {
{MOVETO, FULLSCREEN, false, INDEX_ZERO, "Fullscreen window can not move"},
{MOVETO, SPLIT_PRIMARY, false, INDEX_ZERO, "SPLIT_PRIMARY window can not move"},
{MOVETO, SPLIT_SECONDARY, false, INDEX_ZERO, "SPLIT_SECONDARY window can not move"},
@@ -72,13 +72,13 @@ namespace OHOS::uitest {
static bool IsOperational(const WindowAction action, const WindowMode mode, ApiReplyInfo &out, size_t &index)
{
for (auto dex = 0; dex < sizeof(g_operations) / sizeof(Operational); dex++) {
if (g_operations[dex].action == action && g_operations[dex].windowMode == mode) {
if (g_operations[dex].support) {
index = g_operations[dex].index;
for (auto dex = 0; dex < sizeof(OPERATIONS) / sizeof(Operational); dex++) {
if (OPERATIONS[dex].action == action && OPERATIONS[dex].windowMode == mode) {
if (OPERATIONS[dex].support) {
index = OPERATIONS[dex].index;
return true;
} else {
out.exception_ = ApiCallErr(ErrCode::USAGE_ERROR, g_operations[dex].message);
out.exception_ = ApiCallErr(ErrCode::USAGE_ERROR, OPERATIONS[dex].message);
return false;
}
}
+2 -2
View File
@@ -487,8 +487,6 @@ namespace OHOS::uitest {
LOG_I("Start connect to AccessibilityUITestAbility");
auto ret = ability->Connect();
switch (ret) {
case (RET_OK):
break;
case (RET_ERR_INVALID_PARAM):
LOG_E("Failed to connect to AccessibilityUITestAbility, RET_ERR_INVALID_PARAM");
return false;
@@ -504,6 +502,8 @@ namespace OHOS::uitest {
case (RET_ERR_SAMGR):
LOG_E("Failed to connect to AccessibilityUITestAbility, RET_ERR_SAMGR");
return false;
default:
break;
}
const auto timeout = chrono::milliseconds(1000);
if (condition.wait_for(uLock, timeout) == cv_status::timeout) {
+8 -8
View File
@@ -54,8 +54,8 @@ TEST_F(UiActionTest, computeClickAction)
PointerMatrix events;
action.Decompose(events, customOptions_);
ASSERT_EQ(2, events.GetSize()); // up & down
auto & event1 = events.At(0, 0);
auto & event2 = events.At(0, 1);
auto &event1 = events.At(0, 0);
auto &event2 = events.At(0, 1);
ASSERT_EQ(point.px_, event1.point_.px_);
ASSERT_EQ(point.py_, event1.point_.py_);
ASSERT_EQ(ActionStage::DOWN, event1.stage_);
@@ -74,8 +74,8 @@ TEST_F(UiActionTest, computeLongClickAction)
PointerMatrix events;
action.Decompose(events, customOptions_);
ASSERT_EQ(2, events.GetSize()); // up & down
auto & event1 = events.At(0, 0);
auto & event2 = events.At(0, 1);
auto &event1 = events.At(0, 0);
auto &event2 = events.At(0, 1);
ASSERT_EQ(point.px_, event1.point_.px_);
ASSERT_EQ(point.py_, event1.point_.py_);
ASSERT_EQ(ActionStage::DOWN, event1.stage_);
@@ -96,10 +96,10 @@ TEST_F(UiActionTest, computeDoubleClickAction)
PointerMatrix events;
action.Decompose(events, customOptions_);
ASSERT_EQ(4, events.GetSize()); // up-down-interval-up-down
auto & event1 = events.At(0, 0);
auto & event2 = events.At(0, 1);
auto & event3 = events.At(0, 2);
auto & event4 = events.At(0, 3);
auto &event1 = events.At(0, 0);
auto &event2 = events.At(0, 1);
auto &event3 = events.At(0, 2);
auto &event4 = events.At(0, 3);
ASSERT_EQ(point.px_, event1.point_.px_);
ASSERT_EQ(point.py_, event1.point_.py_);
ASSERT_EQ(ActionStage::DOWN, event1.stage_);