1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SOFTBUS_HISYSEVENT_MATCHER_H 17 #define SOFTBUS_HISYSEVENT_MATCHER_H 18 19 #include <gmock/gmock.h> 20 21 #include "convert/softbus_event_converter.h" 22 #include "hisysevent_c.h" 23 #include "softbus_event.h" 24 25 MATCHER_P(ParamArraySizeMatcher, formSize, "param array size match fail") 26 { 27 auto paramSize = static_cast<int>(arg); 28 EXPECT_EQ(paramSize, (formSize + SOFTBUS_ASSIGNER_SIZE)); 29 return true; 30 } 31 32 MATCHER_P2(SoftbusParamArrayMatcher, inForm, validSize, "softbus param array match fail") 33 { 34 const auto *params = static_cast<const HiSysEventParam *>(arg); 35 auto form = static_cast<SoftbusEventForm>(inForm); 36 int32_t index = 0; 37 EXPECT_STREQ(params[index].name, g_softbusAssigners[index].name); 38 EXPECT_EQ(params[index].t, g_softbusAssigners[index].type); 39 EXPECT_EQ(params[index].v.i32, form.scene); 40 ++index; 41 EXPECT_STREQ(params[index].name, g_softbusAssigners[index].name); 42 EXPECT_EQ(params[index].t, g_softbusAssigners[index].type); 43 EXPECT_EQ(params[index].v.i32, form.stage); 44 ++index; 45 EXPECT_STREQ(params[index].name, g_softbusAssigners[index].name); 46 EXPECT_EQ(params[index].t, g_softbusAssigners[index].type); 47 EXPECT_STREQ(params[index].v.s, SOFTBUS_EVENT_PKG_NAME); 48 ++index; 49 EXPECT_STREQ(params[index].name, g_softbusAssigners[index].name); 50 EXPECT_EQ(params[index].t, g_softbusAssigners[index].type); 51 EXPECT_STREQ(params[index].v.s, form.func); 52 EXPECT_EQ(++index, validSize); 53 return true; 54 } 55 #endif // SOFTBUS_HISYSEVENT_MATCHER_H 56