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