1 /*
2 * Copyright (C) 2022 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 #ifndef IS_SO_CROP_H
16 #include "screenlock_command_test.h"
17
18 #include <memory>
19
20 #include <command.h>
21 #include "sclock_log.h"
22
23 namespace OHOS {
24 namespace ScreenLock {
25 using namespace testing::ext;
26
SetUpTestCase()27 void ScreenLockCommandTest::SetUpTestCase()
28 {
29 }
30
TearDownTestCase()31 void ScreenLockCommandTest::TearDownTestCase()
32 {
33 }
34
SetUp()35 void ScreenLockCommandTest::SetUp()
36 {
37 }
38
TearDown()39 void ScreenLockCommandTest::TearDown()
40 {
41 }
42
43 /**
44 * @tc.name: SetScreenLockCommandTest001
45 * @tc.desc: do action
46 * @tc.type: FUNC
47 * @tc.require:
48 * @tc.author:
49 */
50 HWTEST_F(ScreenLockCommandTest, SetScreenLockCommandTest001, TestSize.Level0)
51 {
52 SCLOCK_HILOGD("Test SetScreenLockCommandTest001");
53 auto cmd = std::make_shared<Command>(std::vector<std::string>({ "-all" }), "Show all",
__anon50ecdc690102(const std::vector<std::string> &input, std::string &output) 54 [this](const std::vector<std::string> &input, std::string &output) -> bool {
55 output.append("SetScreenLockCommandTest001");
56 return true;
57 });
58 std::string output("");
59 cmd->DoAction(std::vector<std::string>{ "-all" }, output);
60 bool isOk = output.compare("SetScreenLockCommandTest001") == 0;
61 EXPECT_EQ(isOk, true);
62 }
63
64 /**
65 * @tc.name: SetScreenLockCommandTest002
66 * @tc.desc: get option.
67 * @tc.type: FUNC
68 * @tc.require:
69 * @tc.author:
70 */
71 HWTEST_F(ScreenLockCommandTest, SetScreenLockCommandTest002, TestSize.Level0)
72 {
73 SCLOCK_HILOGD("Test SetScreenLockCommandTest002 begin");
74 auto cmd = std::make_shared<Command>(std::vector<std::string>({ "-all" }), "Show all",
__anon50ecdc690202(const std::vector<std::string> &input, std::string &output) 75 [this](const std::vector<std::string> &input, std::string &output) -> bool {
76 output.append("SetScreenLockCommandTest002");
77 return true;
78 });
79 std::string option = cmd->GetOption();
80 bool isOk = option.compare("-all") == 0;
81 EXPECT_EQ(isOk, true);
82 }
83
84 /**
85 * @tc.name: SetScreenLockCommandTest003
86 * @tc.desc: Test GetFormat
87 * @tc.type: FUNC
88 * @tc.require:
89 * @tc.author:
90 */
91 HWTEST_F(ScreenLockCommandTest, SetScreenLockCommandTest003, TestSize.Level0)
92 {
93 SCLOCK_HILOGD("Test SetScreenLockCommandTest003 begin");
94 auto cmd = std::make_shared<Command>(std::vector<std::string>({ "-all" }), "Show all",
__anon50ecdc690302(const std::vector<std::string> &input, std::string &output) 95 [this](const std::vector<std::string> &input, std::string &output) -> bool {
96 output.append("SetScreenLockCommandTest001");
97 return true;
98 });
99 std::string format = cmd->GetFormat();
100 bool isOk = format.compare("-all ") == 0;
101 EXPECT_EQ(isOk, true);
102 }
103
104 /**
105 * @tc.name: SetScreenLockCommandTest004
106 * @tc.desc: Test GetFormat.
107 * @tc.type: FUNC
108 * @tc.require:
109 * @tc.author:
110 */
111 HWTEST_F(ScreenLockCommandTest, SetScreenLockCommandTest004, TestSize.Level0)
112 {
113 SCLOCK_HILOGD("Test SetScreenLockCommandTest004 begin");
114 auto cmd = std::make_shared<Command>(std::vector<std::string>({ "-all" }), "Show all");
115 std::string help = cmd->ShowHelp();
116 bool isOk = help.compare("Show all") == 0;
117 EXPECT_EQ(isOk, true);
118 }
119
120 } // namespace ScreenLock
121 } // namespace OHOS
122 #endif // IS_SO_CROP_H