1 /*
2 * Copyright (c) 2024 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 #include <string>
17 #include <map>
18 #include <gtest/gtest.h>
19 #include "secodeFuzz.h"
20 #include "common.h"
21 #include "CommandParse.h"
22 #include "CommandLineInterface.h"
23 #define private public
24 #include "CommandParser.h"
25 using namespace fuzztest;
26
27 namespace {
28 std::map<std::string, std::string> commonDataMap = {
29 {"MousePress", R"({"x":365,"y":1076,"duration":""})"},
30 {"MouseRelease", R"({"x":365,"y":1071})"},
31 {"MouseMove", R"({"x":365,"y":1071,"duration":79})"},
32 {"Language", R"({"Language":"zh_CN"})"},
33 {"SupportedLanguages", ""},
34 {"exit", ""},
35 {"Resolution", ""},
36 {"CurrentRouter", ""},
37 {"LoadContent", ""},
38 {"UnsupportedCommond", ""},
39 {"KeyPress", R"({"isInputMethod":true,"codePoint":33})"},
40 };
41
TEST(CommonCommandParseFuzzTest,test_command)42 TEST(CommonCommandParseFuzzTest, test_command)
43 {
44 std::cout << "--> CommonCommandParseFuzzTest for common start <--" << std::endl;
45 DT_FUZZ_START(0, TEST_TIMES, (char*)"CommonCommandParseFuzzTest", 0)
46 {
47 CommandParse parse;
48 CommandParser::GetInstance().deviceType = "common";
49 parse.CreateAndExecuteCommand(commonDataMap);
50 }
51 DT_FUZZ_END()
52 printf("end ---- CommonCommandParseFuzzTest\r\n");
53 if (DT_GetIsPass() == 0) {
54 printf("test CommonCommandParseFuzzTest is not ok\r\n");
55 } else {
56 printf("test CommonCommandParseFuzzTest is ok\r\n");
57 }
58 std::cout << "--> CommonCommandParseFuzzTest for common end <--" << std::endl;
59 }
60 }