HiSysEventCPPTest.cpp 27.1 KB
Newer Older
M
mamingshuai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "hilog/log.h"
#include <gtest/gtest.h>

#include "file_utils.h"
#include "hisysevent.h"

using namespace testing;
using namespace testing::ext;
using namespace std;
using namespace OHOS::HiviewDFX;
namespace {
string g_key = "key";
string g_reDiRectTimeout = "5";
string g_hiLogRedirect = "/data/local/tmp/hilogredirect.log";
}
class HiSysEventCPPTest : public testing::Test {
public:
    static void SetUpTestCase();
    static void TearDownTestCase();
    void SetUp();
    void TearDown();
private:
};
void HiSysEventCPPTest::SetUp()
{
    std::cout << "SetUp" << std::endl;
    std::vector<std::string> cmdret;
    string cmd = "hilog -r";
    ExecCmdWithRet(cmd, cmdret);
    cmd = "setprop persist.sys.hilog.debug.on false";
    ExecCmdWithRet(cmd, cmdret);
}
void HiSysEventCPPTest::TearDown()
{
    std::cout << "TearDown" << std::endl;
    std::vector<std::string> cmdret;
    string cmd = "rm " + g_hiLogRedirect;
    ExecCmdWithRet(cmd, cmdret);
}
void HiSysEventCPPTest::SetUpTestCase()
{
    std::cout << "SetUpTestCase" << std::endl;
    std::vector<std::string> cmdret;
    string cmd = "mkdir /data/local/tmp/";
    ExecCmdWithRet(cmd, cmdret);
}
void HiSysEventCPPTest::TearDownTestCase()
{
    std::cout << "TearDownTestCase" << std::endl;
}
/**
* @tc.name HiSysEvent Native Write Interface Test, Reported When the KeyValue Is of the
*       boolean Type and the bool Value Is False
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0100
* @tc.desc The keyvalue is of the boolean type and the bool value is false.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0100, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0100 start" << endl;
    bool result = false;
    bool param = false;
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::AAFWK;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo;
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"AAFWK", "eventNameDemo", "\"event_type_\":1", "\"key\":0"};
    if (!fileinfo.empty()) {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0100 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0100 end" << endl;
}
/**
* @tc.name HiSysEvent Native Write Interface Test, Reported When the KeyValue Is of
*       the boolean Type and the bool Value Is False
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0200
* @tc.desc The keyvalue is of the boolean type and the bool value is true.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0200, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0200 start" << endl;
    bool result = false;
    bool param = true;
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::APPEXECFWK;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"APPEXECFWK", "eventNameDemo", "\"event_type_\":1", "\"key\":1"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0200 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0200 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Keyvalue of the Boolean List Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0300
* @tc.desc The value of keyvalue is a boolean list.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0300, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0300 start" << endl;
    bool result = false;
    bool param = false;
    std::vector<bool> test;
    test.push_back(param);
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::ACCOUNT;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"ACCOUNT", "eventNameDemo", "\"event_type_\":1", "\"key\":[0]"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0300 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0300 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Key Value of the Char Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0400
* @tc.desc The keyvalue is of the char type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0400, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0400 start" << endl;
    bool result = false;
    char param = 'a';
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::OTHERS;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"OTHERS", "eventNameDemo", "\"event_type_\":1", "\"key\":97"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0400 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0400 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Keyvalue of the Char List Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0500
* @tc.desc keyvalue is of the char list type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0500, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0500 start" << endl;
    bool result = false;
    char param = 'a';
    std::vector<char> test;
    test.push_back(param);
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::WEARABLE;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"WEARABLE", "eventNameDemo", "\"event_type_\":1", "\"key\":[97]"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0500 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0500 end" << endl;
}
/**
* @tc.name HiSysEvent Natvie Write Interface Test, Reported When the KeyValue Is of the Double Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0600
* @tc.desc The keyvalue is of the double type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0600, Function|MediumTest|Level2)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0600 start" << endl;
    bool result = false;
    double param = 30949.374;
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::WEARABLE_HARDWARE;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"WEARABLEHW", "eventNameDemo", "\"event_type_\":1", "\"key\":30949.4"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0600 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0600 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Keyvalue of the Char List Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0700
* @tc.desc keyvalue is of the char list type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0700, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0700 start" << endl;
    bool result = false;
    double param = 30949.374;
    std::vector<double> test;
    test.push_back(param);
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::USB;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"USB", "eventNameDemo", "\"event_type_\":1", "\"key\":[30949.4]"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0700 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0700 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Key Value of the Floating Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0800
* @tc.desc The keyvalue is of the float type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0800, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0800 start" << endl;
    bool result = false;
    float param = 230.47;
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::UPDATE;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"UPDATE", "eventNameDemo", "\"event_type_\":1", "\"key\":230.47"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0800 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0800 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Keyvalue of the Char List Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_0900
* @tc.desc keyvalue is of the char list type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0900, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0900 start" << endl;
    bool result = false;
    float param = 230.47;
    std::vector<float> test;
    test.push_back(param);
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::TELEPHONY;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"TELEPHONY", "eventNameDemo", "\"event_type_\":1", "\"key\":[230.47]"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_0900 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0900 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Keyvalue of the Int Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1000
* @tc.desc The keyvalue is of the int type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1000, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1000 start" << endl;
    bool result = false;
    int param = 100;
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::STARTUP;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"STARTUP", "eventNameDemo", "\"event_type_\":1", "\"key\":100"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1000 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1000 end" << endl;
}
/**
* @tc.name HiSysEvent Natvie Write Interface Test, Reporting of the int List of KeyValues
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1100
* @tc.desc keyvalue is of the int list type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1100, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1100 start" << endl;
    bool result = false;
    int param = 100;
    std::vector<int> test;
    test.push_back(param);
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::SOURCE_CODE_TRANSFORMER;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"SRCTRANSFORMER", "eventNameDemo", "\"event_type_\":1", "\"key\":[100]"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1100 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1100 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Key Value of the Long Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1200
* @tc.desc The keyvalue is of the long type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1200, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1200 start" << endl;
    bool result = false;
    long param = 1000000;
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::SENSORS;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"SENSORS", "eventNameDemo", "\"event_type_\":1", "\"key\":1000000"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1200 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1200 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the List of the Long Key Value
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1300
* @tc.desc The keyvalue is of the long list type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1300, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1300 start" << endl;
    bool result = false;
    long param = 1000000;
    std::vector<long> test;
    test.push_back(param);
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"SECURITY", "eventNameDemo", "\"event_type_\":1", "\"key\":[1000000]"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1300 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1300 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Key Value of the Short Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1400
* @tc.desc The keyvalue is of the short type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1400, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0250 start" << endl;
    bool result = false;
    short param = 10;
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::ROUTER;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"ROUTER", "eventNameDemo", "\"event_type_\":1", "\"key\":10"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1400 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1400 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the List of Short Key Values
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1500
* @tc.desc The keyvalue is of the short list type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1500, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1500 start" << endl;
    bool result = false;
    short param = 10;
    std::vector<short> test;
    test.push_back(param);
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::POWERMGR;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"POWERMGR", "eventNameDemo", "\"event_type_\":2", "\"key\":[10]"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1500 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1500 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the Key Value of the String Type
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1600
* @tc.desc The keyvalue is of the string type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1600, Function|MediumTest|Level2)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1600 start" << endl;
    bool result = false;
    string param = "abc";
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::NOTIFICATION;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"NOTIFICATION", "eventNameDemo", "\"event_type_\":2", "\"key\":\"abc\""};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1600 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1600 end" << endl;
}
/**
* @tc.name Testing the HiSysEvent Natvie Write Interface, Reporting the List of Short Key Values
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1700
* @tc.desc The keyvalue is of the short list type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1700, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1700 start" << endl;
    bool result = false;
    string param = "abc";
    std::vector<string> test;
    test.push_back(param);
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MODAL_INPUT;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::SECURITY;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"MULTIMODALINPUT", "eventNameDemo", "\"event_type_\":3", "\"key\":[\"abc\"]"};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1700 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1700 end" << endl;
}
/**
* @tc.name HiSysEvent Natvie Write Interface Test, Reporting the List of 20 List Parameters When the Key Value Is String
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_1800
* @tc.desc The keyvalue is reported as a string list. There are 20 list parameters.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1800, Function|MediumTest|Level4)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_0290 start" << endl;
    bool result = false;
    string param = "abc";
    std::vector<string> test;
    for (int i = 0; i < 20; i++) {
        test.push_back(param);
    }
    string str = "\"key\":[";
    for (int i = 0; i < 19; i++) {
        str = str + "\"abc\",";
    }
    str = str + "\"abc\"]";
    GTEST_LOG_(INFO) << str << endl;
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MEDIA;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::SECURITY;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"MULTIMEDIA", "eventNameDemo", "\"event_type_\":3", str};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_1800 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_1800 end" << endl;
}
/**
* @tc.name In the HiSysEvent Natvie Write interface test, 32 parameters are reported for each type of keyvalue.
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_2000
* @tc.desc The keyvalue parameter has 32 parameters for each type.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_2000, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_2000 start" << endl;
    bool result = false;
    string param = "abc";
    string str = "";
    for (int i=0; i < 31; i++){
        str = str + "\"key\":\"abc\",";
    }
    str += "\"key\":\"abc\"";
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::MSDP;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype,
        g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param,
        g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param,
        g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param,
        g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param,
        g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param,
        g_key, param, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"MSDP", "eventNameDemo", "\"event_type_\":4", str};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_2000 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_2000 end" << endl;
}
/**
* @tc.name In the test of the HiSysEvent Natvie Write interface, the key value is a string of 256 characters.
* @tc.number DFX_DFT_HiviewKit_HiSysEvent_Native_2200
* @tc.desc The keyvalue is a string of 256 characters.
*/
HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_2200, Function|MediumTest|Level3)
{
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_2200 start" << endl;
    bool result = false;
    string param = "";
    for (int i = 0; i < 256; i++) {
        param += "a";
    }
    string domain = OHOS::HiviewDFX::HiSysEvent::Domain::LOCATION;
    OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR;
    OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param);
    RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout);
    string fileinfo = "";
    fileinfo = ReadFile(g_hiLogRedirect);
    std::vector<std::string> para = {"LOCATION", "eventNameDemo", "\"event_type_\":4", g_key, param};
    if (fileinfo != "") {
        result = CheckInfo(para, fileinfo);
    } else {
        std::cout << "DFX_DFT_HiviewKit_HiSysEvent_Native_2200 file error" << std::endl;
    }
    ASSERT_TRUE(result);
    GTEST_LOG_(INFO) << "DFX_DFT_HiviewKit_HiSysEvent_Native_2200 end" << endl;
}