1545fdf9bSopenharmony_ci/* 2545fdf9bSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3545fdf9bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4545fdf9bSopenharmony_ci * you may not use this file except in compliance with the License. 5545fdf9bSopenharmony_ci * You may obtain a copy of the License at 6545fdf9bSopenharmony_ci * 7545fdf9bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8545fdf9bSopenharmony_ci * 9545fdf9bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10545fdf9bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11545fdf9bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12545fdf9bSopenharmony_ci * See the License for the specific language governing permissions and 13545fdf9bSopenharmony_ci * limitations under the License. 14545fdf9bSopenharmony_ci */ 15545fdf9bSopenharmony_ci 16545fdf9bSopenharmony_ci#include <gtest/gtest.h> 17545fdf9bSopenharmony_ci 18545fdf9bSopenharmony_ci#define private public 19545fdf9bSopenharmony_ci#include "bundle_command.h" 20545fdf9bSopenharmony_ci#undef private 21545fdf9bSopenharmony_ci#include "bundle_installer_interface.h" 22545fdf9bSopenharmony_ci#include "iremote_broker.h" 23545fdf9bSopenharmony_ci#include "iremote_object.h" 24545fdf9bSopenharmony_ci#include "mock_bundle_installer_host.h" 25545fdf9bSopenharmony_ci#include "mock_bundle_mgr_host.h" 26545fdf9bSopenharmony_ci#include "parameter.h" 27545fdf9bSopenharmony_ci#include "parameters.h" 28545fdf9bSopenharmony_ci 29545fdf9bSopenharmony_ciusing namespace testing::ext; 30545fdf9bSopenharmony_ciusing namespace OHOS::AAFwk; 31545fdf9bSopenharmony_ciusing namespace OHOS::AppExecFwk; 32545fdf9bSopenharmony_ci 33545fdf9bSopenharmony_cinamespace OHOS { 34545fdf9bSopenharmony_cinamespace { 35545fdf9bSopenharmony_ci const char* IS_ROOT_MODE_PARAM = "const.debuggable"; 36545fdf9bSopenharmony_ci const std::string IS_DEVELOPER_MODE_PARAM = "const.security.developermode.state"; 37545fdf9bSopenharmony_ci const int32_t ROOT_MODE = 1; 38545fdf9bSopenharmony_ci} 39545fdf9bSopenharmony_ci 40545fdf9bSopenharmony_ciclass BmCommandTest : public ::testing::Test { 41545fdf9bSopenharmony_cipublic: 42545fdf9bSopenharmony_ci static void SetUpTestCase(); 43545fdf9bSopenharmony_ci static void TearDownTestCase(); 44545fdf9bSopenharmony_ci void SetUp() override; 45545fdf9bSopenharmony_ci void TearDown() override; 46545fdf9bSopenharmony_ci 47545fdf9bSopenharmony_ci void MakeMockObjects(); 48545fdf9bSopenharmony_ci void SetMockObjects(BundleManagerShellCommand &cmd) const; 49545fdf9bSopenharmony_ci 50545fdf9bSopenharmony_ci sptr<IBundleMgr> mgrProxyPtr_; 51545fdf9bSopenharmony_ci sptr<IBundleInstaller> installerProxyPtr_; 52545fdf9bSopenharmony_ci}; 53545fdf9bSopenharmony_ci 54545fdf9bSopenharmony_civoid BmCommandTest::SetUpTestCase() 55545fdf9bSopenharmony_ci{} 56545fdf9bSopenharmony_ci 57545fdf9bSopenharmony_civoid BmCommandTest::TearDownTestCase() 58545fdf9bSopenharmony_ci{} 59545fdf9bSopenharmony_ci 60545fdf9bSopenharmony_civoid BmCommandTest::SetUp() 61545fdf9bSopenharmony_ci{ 62545fdf9bSopenharmony_ci // reset optind to 0 63545fdf9bSopenharmony_ci optind = 0; 64545fdf9bSopenharmony_ci 65545fdf9bSopenharmony_ci // make mock objects 66545fdf9bSopenharmony_ci MakeMockObjects(); 67545fdf9bSopenharmony_ci} 68545fdf9bSopenharmony_ci 69545fdf9bSopenharmony_civoid BmCommandTest::TearDown() 70545fdf9bSopenharmony_ci{} 71545fdf9bSopenharmony_ci 72545fdf9bSopenharmony_civoid BmCommandTest::MakeMockObjects() 73545fdf9bSopenharmony_ci{ 74545fdf9bSopenharmony_ci // mock a mgr host 75545fdf9bSopenharmony_ci auto mgrHostPtr = sptr<IRemoteObject>(new (std::nothrow) MockBundleMgrHost()); 76545fdf9bSopenharmony_ci // mock a mgr proxy 77545fdf9bSopenharmony_ci mgrProxyPtr_ = iface_cast<IBundleMgr>(mgrHostPtr); 78545fdf9bSopenharmony_ci 79545fdf9bSopenharmony_ci // mock a installer host 80545fdf9bSopenharmony_ci auto installerHostPtr = sptr<IRemoteObject>(new (std::nothrow) MockBundleInstallerHost()); 81545fdf9bSopenharmony_ci // mock a installer proxy 82545fdf9bSopenharmony_ci installerProxyPtr_ = iface_cast<IBundleInstaller>(installerHostPtr); 83545fdf9bSopenharmony_ci} 84545fdf9bSopenharmony_ci 85545fdf9bSopenharmony_civoid BmCommandTest::SetMockObjects(BundleManagerShellCommand &cmd) const 86545fdf9bSopenharmony_ci{ 87545fdf9bSopenharmony_ci // set the mock mgr proxy 88545fdf9bSopenharmony_ci cmd.bundleMgrProxy_ = mgrProxyPtr_; 89545fdf9bSopenharmony_ci 90545fdf9bSopenharmony_ci // set the mock installer proxy 91545fdf9bSopenharmony_ci cmd.bundleInstallerProxy_ = installerProxyPtr_; 92545fdf9bSopenharmony_ci} 93545fdf9bSopenharmony_ci 94545fdf9bSopenharmony_ci/** 95545fdf9bSopenharmony_ci * @tc.number: Bm_Command_0001 96545fdf9bSopenharmony_ci * @tc.name: ExecCommand 97545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm" command. 98545fdf9bSopenharmony_ci */ 99545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_0001, Function | MediumTest | Level1) 100545fdf9bSopenharmony_ci{ 101545fdf9bSopenharmony_ci char *argv[] = { 102545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 103545fdf9bSopenharmony_ci const_cast<char*>(""), 104545fdf9bSopenharmony_ci }; 105545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 106545fdf9bSopenharmony_ci 107545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 108545fdf9bSopenharmony_ci 109545fdf9bSopenharmony_ci // set the mock objects 110545fdf9bSopenharmony_ci SetMockObjects(cmd); 111545fdf9bSopenharmony_ci 112545fdf9bSopenharmony_ci std::string message; 113545fdf9bSopenharmony_ci message += HELP_MSG; 114545fdf9bSopenharmony_ci int32_t mode = GetIntParameter(IS_ROOT_MODE_PARAM, ROOT_MODE); 115545fdf9bSopenharmony_ci if (mode == ROOT_MODE) { 116545fdf9bSopenharmony_ci message += ENABLE_DISABLE_HELP_MSG; 117545fdf9bSopenharmony_ci } 118545fdf9bSopenharmony_ci bool isDeveloperMode = system::GetBoolParameter(IS_DEVELOPER_MODE_PARAM, false); 119545fdf9bSopenharmony_ci if (mode == ROOT_MODE || isDeveloperMode) { 120545fdf9bSopenharmony_ci message += CLEAN_HELP_MSG; 121545fdf9bSopenharmony_ci } 122545fdf9bSopenharmony_ci 123545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), message); 124545fdf9bSopenharmony_ci} 125545fdf9bSopenharmony_ci 126545fdf9bSopenharmony_ci/** 127545fdf9bSopenharmony_ci * @tc.number: Bm_Command_0002 128545fdf9bSopenharmony_ci * @tc.name: ExecCommand 129545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm xxx" command. 130545fdf9bSopenharmony_ci */ 131545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_0002, Function | MediumTest | Level1) 132545fdf9bSopenharmony_ci{ 133545fdf9bSopenharmony_ci char *argv[] = { 134545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 135545fdf9bSopenharmony_ci const_cast<char*>("xxx"), 136545fdf9bSopenharmony_ci const_cast<char*>(""), 137545fdf9bSopenharmony_ci }; 138545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 139545fdf9bSopenharmony_ci 140545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 141545fdf9bSopenharmony_ci 142545fdf9bSopenharmony_ci // set the mock objects 143545fdf9bSopenharmony_ci SetMockObjects(cmd); 144545fdf9bSopenharmony_ci 145545fdf9bSopenharmony_ci std::string message; 146545fdf9bSopenharmony_ci message += HELP_MSG; 147545fdf9bSopenharmony_ci int32_t mode = GetIntParameter(IS_ROOT_MODE_PARAM, ROOT_MODE); 148545fdf9bSopenharmony_ci if (mode == ROOT_MODE) { 149545fdf9bSopenharmony_ci message += ENABLE_DISABLE_HELP_MSG; 150545fdf9bSopenharmony_ci } 151545fdf9bSopenharmony_ci bool isDeveloperMode = system::GetBoolParameter(IS_DEVELOPER_MODE_PARAM, false); 152545fdf9bSopenharmony_ci if (mode == ROOT_MODE || isDeveloperMode) { 153545fdf9bSopenharmony_ci message += CLEAN_HELP_MSG; 154545fdf9bSopenharmony_ci } 155545fdf9bSopenharmony_ci 156545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), cmd.GetCommandErrorMsg() + message); 157545fdf9bSopenharmony_ci} 158545fdf9bSopenharmony_ci 159545fdf9bSopenharmony_ci/** 160545fdf9bSopenharmony_ci * @tc.number: Bm_Command_0003 161545fdf9bSopenharmony_ci * @tc.name: ExecCommand 162545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm -xxx" command. 163545fdf9bSopenharmony_ci */ 164545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_0003, Function | MediumTest | Level1) 165545fdf9bSopenharmony_ci{ 166545fdf9bSopenharmony_ci char *argv[] = { 167545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 168545fdf9bSopenharmony_ci const_cast<char*>("-xxx"), 169545fdf9bSopenharmony_ci const_cast<char*>(""), 170545fdf9bSopenharmony_ci }; 171545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 172545fdf9bSopenharmony_ci 173545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 174545fdf9bSopenharmony_ci 175545fdf9bSopenharmony_ci // set the mock objects 176545fdf9bSopenharmony_ci SetMockObjects(cmd); 177545fdf9bSopenharmony_ci 178545fdf9bSopenharmony_ci std::string message; 179545fdf9bSopenharmony_ci message += HELP_MSG; 180545fdf9bSopenharmony_ci int32_t mode = GetIntParameter(IS_ROOT_MODE_PARAM, ROOT_MODE); 181545fdf9bSopenharmony_ci if (mode == ROOT_MODE) { 182545fdf9bSopenharmony_ci message += ENABLE_DISABLE_HELP_MSG; 183545fdf9bSopenharmony_ci } 184545fdf9bSopenharmony_ci bool isDeveloperMode = system::GetBoolParameter(IS_DEVELOPER_MODE_PARAM, false); 185545fdf9bSopenharmony_ci if (mode == ROOT_MODE || isDeveloperMode) { 186545fdf9bSopenharmony_ci message += CLEAN_HELP_MSG; 187545fdf9bSopenharmony_ci } 188545fdf9bSopenharmony_ci 189545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), cmd.GetCommandErrorMsg() + message); 190545fdf9bSopenharmony_ci} 191545fdf9bSopenharmony_ci 192545fdf9bSopenharmony_ci/** 193545fdf9bSopenharmony_ci * @tc.number: Bm_Command_0004 194545fdf9bSopenharmony_ci * @tc.name: ExecCommand 195545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm --xxx" command. 196545fdf9bSopenharmony_ci */ 197545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_0004, Function | MediumTest | Level1) 198545fdf9bSopenharmony_ci{ 199545fdf9bSopenharmony_ci char *argv[] = { 200545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 201545fdf9bSopenharmony_ci const_cast<char*>("--xxx"), 202545fdf9bSopenharmony_ci const_cast<char*>(""), 203545fdf9bSopenharmony_ci }; 204545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 205545fdf9bSopenharmony_ci 206545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 207545fdf9bSopenharmony_ci 208545fdf9bSopenharmony_ci // set the mock objects 209545fdf9bSopenharmony_ci SetMockObjects(cmd); 210545fdf9bSopenharmony_ci 211545fdf9bSopenharmony_ci std::string message; 212545fdf9bSopenharmony_ci message += HELP_MSG; 213545fdf9bSopenharmony_ci int32_t mode = GetIntParameter(IS_ROOT_MODE_PARAM, ROOT_MODE); 214545fdf9bSopenharmony_ci if (mode == ROOT_MODE) { 215545fdf9bSopenharmony_ci message += ENABLE_DISABLE_HELP_MSG; 216545fdf9bSopenharmony_ci } 217545fdf9bSopenharmony_ci bool isDeveloperMode = system::GetBoolParameter(IS_DEVELOPER_MODE_PARAM, false); 218545fdf9bSopenharmony_ci if (mode == ROOT_MODE || isDeveloperMode) { 219545fdf9bSopenharmony_ci message += CLEAN_HELP_MSG; 220545fdf9bSopenharmony_ci } 221545fdf9bSopenharmony_ci 222545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), cmd.GetCommandErrorMsg() + message); 223545fdf9bSopenharmony_ci} 224545fdf9bSopenharmony_ci 225545fdf9bSopenharmony_ci/** 226545fdf9bSopenharmony_ci * @tc.number: Bm_Command_0005 227545fdf9bSopenharmony_ci * @tc.name: ExecCommand 228545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm help" command. 229545fdf9bSopenharmony_ci */ 230545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_0005, Function | MediumTest | Level1) 231545fdf9bSopenharmony_ci{ 232545fdf9bSopenharmony_ci char *argv[] = { 233545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 234545fdf9bSopenharmony_ci const_cast<char*>("help"), 235545fdf9bSopenharmony_ci const_cast<char*>(""), 236545fdf9bSopenharmony_ci }; 237545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 238545fdf9bSopenharmony_ci 239545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 240545fdf9bSopenharmony_ci 241545fdf9bSopenharmony_ci // set the mock objects 242545fdf9bSopenharmony_ci SetMockObjects(cmd); 243545fdf9bSopenharmony_ci 244545fdf9bSopenharmony_ci std::string message; 245545fdf9bSopenharmony_ci message += HELP_MSG; 246545fdf9bSopenharmony_ci int32_t mode = GetIntParameter(IS_ROOT_MODE_PARAM, ROOT_MODE); 247545fdf9bSopenharmony_ci if (mode == ROOT_MODE) { 248545fdf9bSopenharmony_ci message += ENABLE_DISABLE_HELP_MSG; 249545fdf9bSopenharmony_ci } 250545fdf9bSopenharmony_ci bool isDeveloperMode = system::GetBoolParameter(IS_DEVELOPER_MODE_PARAM, false); 251545fdf9bSopenharmony_ci if (mode == ROOT_MODE || isDeveloperMode) { 252545fdf9bSopenharmony_ci message += CLEAN_HELP_MSG; 253545fdf9bSopenharmony_ci } 254545fdf9bSopenharmony_ci 255545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), message); 256545fdf9bSopenharmony_ci} 257545fdf9bSopenharmony_ci 258545fdf9bSopenharmony_ci/** 259545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0001 260545fdf9bSopenharmony_ci * @tc.name: ExecCommand 261545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean" command. 262545fdf9bSopenharmony_ci */ 263545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0001, Function | MediumTest | Level1) 264545fdf9bSopenharmony_ci{ 265545fdf9bSopenharmony_ci char *argv[] = { 266545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 267545fdf9bSopenharmony_ci const_cast<char*>("clean"), 268545fdf9bSopenharmony_ci const_cast<char*>(""), 269545fdf9bSopenharmony_ci }; 270545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 271545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 272545fdf9bSopenharmony_ci // set the mock objects 273545fdf9bSopenharmony_ci SetMockObjects(cmd); 274545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_CLEAN); 275545fdf9bSopenharmony_ci} 276545fdf9bSopenharmony_ci 277545fdf9bSopenharmony_ci/** 278545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0002 279545fdf9bSopenharmony_ci * @tc.name: ExecCommand 280545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean xx" command. 281545fdf9bSopenharmony_ci */ 282545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0002, Function | MediumTest | Level1) 283545fdf9bSopenharmony_ci{ 284545fdf9bSopenharmony_ci char *argv[] = { 285545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 286545fdf9bSopenharmony_ci const_cast<char*>("clean"), 287545fdf9bSopenharmony_ci const_cast<char*>("xxx"), 288545fdf9bSopenharmony_ci const_cast<char*>(""), 289545fdf9bSopenharmony_ci }; 290545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 291545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 292545fdf9bSopenharmony_ci // set the mock objects 293545fdf9bSopenharmony_ci SetMockObjects(cmd); 294545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_CLEAN); 295545fdf9bSopenharmony_ci} 296545fdf9bSopenharmony_ci 297545fdf9bSopenharmony_ci/** 298545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0003 299545fdf9bSopenharmony_ci * @tc.name: ExecCommand 300545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -n" command. 301545fdf9bSopenharmony_ci */ 302545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0003, Function | MediumTest | Level1) 303545fdf9bSopenharmony_ci{ 304545fdf9bSopenharmony_ci char *argv[] = { 305545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 306545fdf9bSopenharmony_ci const_cast<char*>("clean"), 307545fdf9bSopenharmony_ci const_cast<char*>("-n"), 308545fdf9bSopenharmony_ci const_cast<char*>(""), 309545fdf9bSopenharmony_ci }; 310545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 311545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 312545fdf9bSopenharmony_ci // set the mock objects 313545fdf9bSopenharmony_ci SetMockObjects(cmd); 314545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_CLEAN); 315545fdf9bSopenharmony_ci} 316545fdf9bSopenharmony_ci 317545fdf9bSopenharmony_ci/** 318545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0004 319545fdf9bSopenharmony_ci * @tc.name: ExecCommand 320545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -n <bundle-name>" command. 321545fdf9bSopenharmony_ci */ 322545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0004, Function | MediumTest | Level1) 323545fdf9bSopenharmony_ci{ 324545fdf9bSopenharmony_ci char *argv[] = { 325545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 326545fdf9bSopenharmony_ci const_cast<char*>("clean"), 327545fdf9bSopenharmony_ci const_cast<char*>("-n"), 328545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 329545fdf9bSopenharmony_ci const_cast<char*>(""), 330545fdf9bSopenharmony_ci }; 331545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 332545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 333545fdf9bSopenharmony_ci // set the mock objects 334545fdf9bSopenharmony_ci SetMockObjects(cmd); 335545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_DATA_OR_CACHE_OPTION + "\n" + HELP_MSG_CLEAN); 336545fdf9bSopenharmony_ci} 337545fdf9bSopenharmony_ci 338545fdf9bSopenharmony_ci/** 339545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0005 340545fdf9bSopenharmony_ci * @tc.name: ExecCommand 341545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -n <bundle-name> xxx" command. 342545fdf9bSopenharmony_ci */ 343545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0005, Function | MediumTest | Level1) 344545fdf9bSopenharmony_ci{ 345545fdf9bSopenharmony_ci char *argv[] = { 346545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 347545fdf9bSopenharmony_ci const_cast<char*>("clean"), 348545fdf9bSopenharmony_ci const_cast<char*>("-n"), 349545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 350545fdf9bSopenharmony_ci const_cast<char*>("xxx"), 351545fdf9bSopenharmony_ci const_cast<char*>(""), 352545fdf9bSopenharmony_ci }; 353545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 354545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 355545fdf9bSopenharmony_ci // set the mock objects 356545fdf9bSopenharmony_ci SetMockObjects(cmd); 357545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_DATA_OR_CACHE_OPTION + "\n" + HELP_MSG_CLEAN); 358545fdf9bSopenharmony_ci} 359545fdf9bSopenharmony_ci 360545fdf9bSopenharmony_ci/** 361545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0006 362545fdf9bSopenharmony_ci * @tc.name: ExecCommand 363545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -n <bundle-name> -d" command. 364545fdf9bSopenharmony_ci */ 365545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0006, Function | MediumTest | Level1) 366545fdf9bSopenharmony_ci{ 367545fdf9bSopenharmony_ci char *argv[] = { 368545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 369545fdf9bSopenharmony_ci const_cast<char*>("clean"), 370545fdf9bSopenharmony_ci const_cast<char*>("-n"), 371545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 372545fdf9bSopenharmony_ci const_cast<char*>("-d"), 373545fdf9bSopenharmony_ci const_cast<char*>(""), 374545fdf9bSopenharmony_ci }; 375545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 376545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 377545fdf9bSopenharmony_ci // set the mock objects 378545fdf9bSopenharmony_ci SetMockObjects(cmd); 379545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_CLEAN_DATA_BUNDLE_NG + "\n"); 380545fdf9bSopenharmony_ci} 381545fdf9bSopenharmony_ci 382545fdf9bSopenharmony_ci/** 383545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0007 384545fdf9bSopenharmony_ci * @tc.name: ExecCommand 385545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -n <bundle-name> -c" command. 386545fdf9bSopenharmony_ci */ 387545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0007, Function | MediumTest | Level1) 388545fdf9bSopenharmony_ci{ 389545fdf9bSopenharmony_ci char *argv[] = { 390545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 391545fdf9bSopenharmony_ci const_cast<char*>("clean"), 392545fdf9bSopenharmony_ci const_cast<char*>("-n"), 393545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 394545fdf9bSopenharmony_ci const_cast<char*>("-c"), 395545fdf9bSopenharmony_ci const_cast<char*>(""), 396545fdf9bSopenharmony_ci }; 397545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 398545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 399545fdf9bSopenharmony_ci // set the mock objects 400545fdf9bSopenharmony_ci SetMockObjects(cmd); 401545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_CLEAN_CACHE_BUNDLE_OK + "\n"); 402545fdf9bSopenharmony_ci} 403545fdf9bSopenharmony_ci 404545fdf9bSopenharmony_ci/** 405545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0008 406545fdf9bSopenharmony_ci * @tc.name: ExecCommand 407545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -c" command. 408545fdf9bSopenharmony_ci */ 409545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0008, Function | MediumTest | Level1) 410545fdf9bSopenharmony_ci{ 411545fdf9bSopenharmony_ci char *argv[] = { 412545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 413545fdf9bSopenharmony_ci const_cast<char*>("clean"), 414545fdf9bSopenharmony_ci const_cast<char*>("-c"), 415545fdf9bSopenharmony_ci const_cast<char*>(""), 416545fdf9bSopenharmony_ci }; 417545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 418545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 419545fdf9bSopenharmony_ci // set the mock objects 420545fdf9bSopenharmony_ci SetMockObjects(cmd); 421545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_BUNDLE_NAME_OPTION + "\n" + HELP_MSG_CLEAN); 422545fdf9bSopenharmony_ci} 423545fdf9bSopenharmony_ci 424545fdf9bSopenharmony_ci/** 425545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0009 426545fdf9bSopenharmony_ci * @tc.name: ExecCommand 427545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -d" command. 428545fdf9bSopenharmony_ci */ 429545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0009, Function | MediumTest | Level1) 430545fdf9bSopenharmony_ci{ 431545fdf9bSopenharmony_ci char *argv[] = { 432545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 433545fdf9bSopenharmony_ci const_cast<char*>("clean"), 434545fdf9bSopenharmony_ci const_cast<char*>("-d"), 435545fdf9bSopenharmony_ci const_cast<char*>(""), 436545fdf9bSopenharmony_ci }; 437545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 438545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 439545fdf9bSopenharmony_ci // set the mock objects 440545fdf9bSopenharmony_ci SetMockObjects(cmd); 441545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_BUNDLE_NAME_OPTION + "\n" + HELP_MSG_CLEAN); 442545fdf9bSopenharmony_ci} 443545fdf9bSopenharmony_ci 444545fdf9bSopenharmony_ci/** 445545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0010 446545fdf9bSopenharmony_ci * @tc.name: ExecCommand 447545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -n <bundle-name> -d -u" command. 448545fdf9bSopenharmony_ci */ 449545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0010, Function | MediumTest | Level1) 450545fdf9bSopenharmony_ci{ 451545fdf9bSopenharmony_ci char *argv[] = { 452545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 453545fdf9bSopenharmony_ci const_cast<char*>("clean"), 454545fdf9bSopenharmony_ci const_cast<char*>("-n"), 455545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 456545fdf9bSopenharmony_ci const_cast<char*>("-d"), 457545fdf9bSopenharmony_ci const_cast<char*>(" "), 458545fdf9bSopenharmony_ci const_cast<char*>("-u"), 459545fdf9bSopenharmony_ci const_cast<char*>(""), 460545fdf9bSopenharmony_ci }; 461545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 462545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 463545fdf9bSopenharmony_ci // set the mock objects 464545fdf9bSopenharmony_ci SetMockObjects(cmd); 465545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_CLEAN); 466545fdf9bSopenharmony_ci} 467545fdf9bSopenharmony_ci 468545fdf9bSopenharmony_ci/** 469545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0011 470545fdf9bSopenharmony_ci * @tc.name: ExecCommand 471545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -n <bundle-name> -d -u XXX" command. 472545fdf9bSopenharmony_ci */ 473545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0011, Function | MediumTest | Level1) 474545fdf9bSopenharmony_ci{ 475545fdf9bSopenharmony_ci char *argv[] = { 476545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 477545fdf9bSopenharmony_ci const_cast<char*>("clean"), 478545fdf9bSopenharmony_ci const_cast<char*>("-n"), 479545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 480545fdf9bSopenharmony_ci const_cast<char*>("-d"), 481545fdf9bSopenharmony_ci const_cast<char*>(" "), 482545fdf9bSopenharmony_ci const_cast<char*>("-u"), 483545fdf9bSopenharmony_ci const_cast<char*>("XXX"), 484545fdf9bSopenharmony_ci const_cast<char*>(""), 485545fdf9bSopenharmony_ci }; 486545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 487545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 488545fdf9bSopenharmony_ci // set the mock objects 489545fdf9bSopenharmony_ci SetMockObjects(cmd); 490545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_CLEAN_DATA_BUNDLE_NG + "\n"); 491545fdf9bSopenharmony_ci} 492545fdf9bSopenharmony_ci 493545fdf9bSopenharmony_ci/** 494545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0012 495545fdf9bSopenharmony_ci * @tc.name: ExecCommand 496545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -n <bundle-name> -d -u <user-id>" command. 497545fdf9bSopenharmony_ci */ 498545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0012, Function | MediumTest | Level1) 499545fdf9bSopenharmony_ci{ 500545fdf9bSopenharmony_ci char *argv[] = { 501545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 502545fdf9bSopenharmony_ci const_cast<char*>("clean"), 503545fdf9bSopenharmony_ci const_cast<char*>("-n"), 504545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 505545fdf9bSopenharmony_ci const_cast<char*>("-d"), 506545fdf9bSopenharmony_ci const_cast<char*>(" "), 507545fdf9bSopenharmony_ci const_cast<char*>("-u"), 508545fdf9bSopenharmony_ci const_cast<char*>(DEFAULT_USER_ID.c_str()), 509545fdf9bSopenharmony_ci const_cast<char*>(""), 510545fdf9bSopenharmony_ci }; 511545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 512545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 513545fdf9bSopenharmony_ci // set the mock objects 514545fdf9bSopenharmony_ci SetMockObjects(cmd); 515545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_CLEAN_DATA_BUNDLE_NG + "\n"); 516545fdf9bSopenharmony_ci} 517545fdf9bSopenharmony_ci 518545fdf9bSopenharmony_ci/** 519545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0013 520545fdf9bSopenharmony_ci * @tc.name: ExecCommand 521545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -h" command. 522545fdf9bSopenharmony_ci */ 523545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0013, Function | MediumTest | Level1) 524545fdf9bSopenharmony_ci{ 525545fdf9bSopenharmony_ci char *argv[] = { 526545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 527545fdf9bSopenharmony_ci const_cast<char*>("clean"), 528545fdf9bSopenharmony_ci const_cast<char*>("-h"), 529545fdf9bSopenharmony_ci }; 530545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 531545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 532545fdf9bSopenharmony_ci // set the mock objects 533545fdf9bSopenharmony_ci SetMockObjects(cmd); 534545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), "error: you must specify an option at least.\n" + HELP_MSG_CLEAN); 535545fdf9bSopenharmony_ci} 536545fdf9bSopenharmony_ci 537545fdf9bSopenharmony_ci/** 538545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0014 539545fdf9bSopenharmony_ci * @tc.name: ExecCommand 540545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -xxx" command. 541545fdf9bSopenharmony_ci */ 542545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0014, Function | MediumTest | Level1) 543545fdf9bSopenharmony_ci{ 544545fdf9bSopenharmony_ci char *argv[] = { 545545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 546545fdf9bSopenharmony_ci const_cast<char*>("clean"), 547545fdf9bSopenharmony_ci const_cast<char*>("-XXX"), 548545fdf9bSopenharmony_ci const_cast<char*>(" "), 549545fdf9bSopenharmony_ci }; 550545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 551545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 552545fdf9bSopenharmony_ci // set the mock objects 553545fdf9bSopenharmony_ci SetMockObjects(cmd); 554545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_CLEAN); 555545fdf9bSopenharmony_ci} 556545fdf9bSopenharmony_ci 557545fdf9bSopenharmony_ci/** 558545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0015 559545fdf9bSopenharmony_ci * @tc.name: ExecCommand 560545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -n <bundle-name> -d -xxx <user-id>" command. 561545fdf9bSopenharmony_ci */ 562545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0015, Function | MediumTest | Level1) 563545fdf9bSopenharmony_ci{ 564545fdf9bSopenharmony_ci char *argv[] = { 565545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 566545fdf9bSopenharmony_ci const_cast<char*>("clean"), 567545fdf9bSopenharmony_ci const_cast<char*>("-n"), 568545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 569545fdf9bSopenharmony_ci const_cast<char*>("-d"), 570545fdf9bSopenharmony_ci const_cast<char*>(" "), 571545fdf9bSopenharmony_ci const_cast<char*>("-XXX"), 572545fdf9bSopenharmony_ci const_cast<char*>(DEFAULT_USER_ID.c_str()), 573545fdf9bSopenharmony_ci const_cast<char*>(""), 574545fdf9bSopenharmony_ci }; 575545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 576545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 577545fdf9bSopenharmony_ci // set the mock objects 578545fdf9bSopenharmony_ci SetMockObjects(cmd); 579545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_CLEAN); 580545fdf9bSopenharmony_ci} 581545fdf9bSopenharmony_ci 582545fdf9bSopenharmony_ci/** 583545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0016 584545fdf9bSopenharmony_ci * @tc.name: ExecCommand 585545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -xxx <bundle-name>" command. 586545fdf9bSopenharmony_ci */ 587545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0016, Function | MediumTest | Level1) 588545fdf9bSopenharmony_ci{ 589545fdf9bSopenharmony_ci char *argv[] = { 590545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 591545fdf9bSopenharmony_ci const_cast<char*>("clean"), 592545fdf9bSopenharmony_ci const_cast<char*>("-xxx"), 593545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 594545fdf9bSopenharmony_ci const_cast<char*>(""), 595545fdf9bSopenharmony_ci }; 596545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 597545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 598545fdf9bSopenharmony_ci // set the mock objects 599545fdf9bSopenharmony_ci SetMockObjects(cmd); 600545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_CLEAN); 601545fdf9bSopenharmony_ci} 602545fdf9bSopenharmony_ci 603545fdf9bSopenharmony_ci/** 604545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Clean_0017 605545fdf9bSopenharmony_ci * @tc.name: ExecCommand 606545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm clean -h" command. 607545fdf9bSopenharmony_ci */ 608545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Clean_0017, Function | MediumTest | Level1) 609545fdf9bSopenharmony_ci{ 610545fdf9bSopenharmony_ci char *argv[] = { 611545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 612545fdf9bSopenharmony_ci const_cast<char*>("clean"), 613545fdf9bSopenharmony_ci const_cast<char*>("-h"), 614545fdf9bSopenharmony_ci const_cast<char*>(""), 615545fdf9bSopenharmony_ci }; 616545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 617545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 618545fdf9bSopenharmony_ci // set the mock objects 619545fdf9bSopenharmony_ci SetMockObjects(cmd); 620545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_CLEAN); 621545fdf9bSopenharmony_ci} 622545fdf9bSopenharmony_ci 623545fdf9bSopenharmony_ci/** 624545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0001 625545fdf9bSopenharmony_ci * @tc.name: ExecCommand 626545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable" command. 627545fdf9bSopenharmony_ci */ 628545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0001, Function | MediumTest | Level1) 629545fdf9bSopenharmony_ci{ 630545fdf9bSopenharmony_ci char *argv[] = { 631545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 632545fdf9bSopenharmony_ci const_cast<char*>("enable"), 633545fdf9bSopenharmony_ci const_cast<char*>(""), 634545fdf9bSopenharmony_ci }; 635545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 636545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 637545fdf9bSopenharmony_ci // set the mock objects 638545fdf9bSopenharmony_ci SetMockObjects(cmd); 639545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_ENABLE); 640545fdf9bSopenharmony_ci} 641545fdf9bSopenharmony_ci 642545fdf9bSopenharmony_ci/** 643545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0002 644545fdf9bSopenharmony_ci * @tc.name: ExecCommand 645545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable -n <bundle-name>" command. 646545fdf9bSopenharmony_ci */ 647545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0002, Function | MediumTest | Level1) 648545fdf9bSopenharmony_ci{ 649545fdf9bSopenharmony_ci char *argv[] = { 650545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 651545fdf9bSopenharmony_ci const_cast<char*>("enable"), 652545fdf9bSopenharmony_ci const_cast<char*>("-n"), 653545fdf9bSopenharmony_ci const_cast<char*>(""), 654545fdf9bSopenharmony_ci }; 655545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 656545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 657545fdf9bSopenharmony_ci // set the mock objects 658545fdf9bSopenharmony_ci SetMockObjects(cmd); 659545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_ENABLE); 660545fdf9bSopenharmony_ci} 661545fdf9bSopenharmony_ci 662545fdf9bSopenharmony_ci/** 663545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0003 664545fdf9bSopenharmony_ci * @tc.name: ExecCommand 665545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable -n <bundle-name>" command. 666545fdf9bSopenharmony_ci */ 667545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0003, Function | MediumTest | Level1) 668545fdf9bSopenharmony_ci{ 669545fdf9bSopenharmony_ci char *argv[] = { 670545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 671545fdf9bSopenharmony_ci const_cast<char*>("enable"), 672545fdf9bSopenharmony_ci const_cast<char*>("-n"), 673545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 674545fdf9bSopenharmony_ci const_cast<char*>(""), 675545fdf9bSopenharmony_ci }; 676545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 677545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 678545fdf9bSopenharmony_ci // set the mock objects 679545fdf9bSopenharmony_ci SetMockObjects(cmd); 680545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_ENABLE_BUNDLE_OK + "\n"); 681545fdf9bSopenharmony_ci} 682545fdf9bSopenharmony_ci 683545fdf9bSopenharmony_ci/** 684545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0004 685545fdf9bSopenharmony_ci * @tc.name: ExecCommand 686545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable -n <bundle-name> -a <ability-name>" command. 687545fdf9bSopenharmony_ci */ 688545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0004, Function | MediumTest | Level1) 689545fdf9bSopenharmony_ci{ 690545fdf9bSopenharmony_ci char *argv[] = { 691545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 692545fdf9bSopenharmony_ci const_cast<char*>("enable"), 693545fdf9bSopenharmony_ci const_cast<char*>("-n"), 694545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 695545fdf9bSopenharmony_ci const_cast<char*>("-a"), 696545fdf9bSopenharmony_ci const_cast<char*>(""), 697545fdf9bSopenharmony_ci }; 698545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 699545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 700545fdf9bSopenharmony_ci // set the mock objects 701545fdf9bSopenharmony_ci SetMockObjects(cmd); 702545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_ENABLE); 703545fdf9bSopenharmony_ci} 704545fdf9bSopenharmony_ci 705545fdf9bSopenharmony_ci/** 706545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0005 707545fdf9bSopenharmony_ci * @tc.name: ExecCommand 708545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable -n <bundle-name> -a <ability-name>" command. 709545fdf9bSopenharmony_ci */ 710545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0005, Function | MediumTest | Level1) 711545fdf9bSopenharmony_ci{ 712545fdf9bSopenharmony_ci char *argv[] = { 713545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 714545fdf9bSopenharmony_ci const_cast<char*>("enable"), 715545fdf9bSopenharmony_ci const_cast<char*>("-n"), 716545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 717545fdf9bSopenharmony_ci const_cast<char*>("-a"), 718545fdf9bSopenharmony_ci const_cast<char*>(STRING_ABILITY_NAME.c_str()), 719545fdf9bSopenharmony_ci const_cast<char*>(""), 720545fdf9bSopenharmony_ci }; 721545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 722545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 723545fdf9bSopenharmony_ci // set the mock objects 724545fdf9bSopenharmony_ci SetMockObjects(cmd); 725545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_ENABLE_BUNDLE_OK + "\n"); 726545fdf9bSopenharmony_ci} 727545fdf9bSopenharmony_ci 728545fdf9bSopenharmony_ci/** 729545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0006 730545fdf9bSopenharmony_ci * @tc.name: ExecCommand 731545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable -x" command. 732545fdf9bSopenharmony_ci */ 733545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0006, Function | MediumTest | Level1) 734545fdf9bSopenharmony_ci{ 735545fdf9bSopenharmony_ci char *argv[] = { 736545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 737545fdf9bSopenharmony_ci const_cast<char*>("enable"), 738545fdf9bSopenharmony_ci const_cast<char*>("-x"), 739545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 740545fdf9bSopenharmony_ci const_cast<char*>(""), 741545fdf9bSopenharmony_ci }; 742545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 743545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 744545fdf9bSopenharmony_ci // set the mock objects 745545fdf9bSopenharmony_ci SetMockObjects(cmd); 746545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_ENABLE); 747545fdf9bSopenharmony_ci} 748545fdf9bSopenharmony_ci 749545fdf9bSopenharmony_ci/** 750545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0007 751545fdf9bSopenharmony_ci * @tc.name: ExecCommand 752545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable -n <bundle-name> -u" command. 753545fdf9bSopenharmony_ci */ 754545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0007, Function | MediumTest | Level1) 755545fdf9bSopenharmony_ci{ 756545fdf9bSopenharmony_ci char *argv[] = { 757545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 758545fdf9bSopenharmony_ci const_cast<char*>("enable"), 759545fdf9bSopenharmony_ci const_cast<char*>("-n"), 760545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 761545fdf9bSopenharmony_ci const_cast<char*>("-u"), 762545fdf9bSopenharmony_ci const_cast<char*>(""), 763545fdf9bSopenharmony_ci }; 764545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 765545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 766545fdf9bSopenharmony_ci // set the mock objects 767545fdf9bSopenharmony_ci SetMockObjects(cmd); 768545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_ENABLE); 769545fdf9bSopenharmony_ci} 770545fdf9bSopenharmony_ci 771545fdf9bSopenharmony_ci/** 772545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0008 773545fdf9bSopenharmony_ci * @tc.name: ExecCommand 774545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable -n <bundle-name> -u XXX" command. 775545fdf9bSopenharmony_ci */ 776545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0008, Function | MediumTest | Level1) 777545fdf9bSopenharmony_ci{ 778545fdf9bSopenharmony_ci char *argv[] = { 779545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 780545fdf9bSopenharmony_ci const_cast<char*>("enable"), 781545fdf9bSopenharmony_ci const_cast<char*>("-n"), 782545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 783545fdf9bSopenharmony_ci const_cast<char*>("-u"), 784545fdf9bSopenharmony_ci const_cast<char*>("XXX"), 785545fdf9bSopenharmony_ci const_cast<char*>(""), 786545fdf9bSopenharmony_ci }; 787545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 788545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 789545fdf9bSopenharmony_ci // set the mock objects 790545fdf9bSopenharmony_ci SetMockObjects(cmd); 791545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_ENABLE_BUNDLE_OK + "\n"); 792545fdf9bSopenharmony_ci} 793545fdf9bSopenharmony_ci 794545fdf9bSopenharmony_ci/** 795545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0009 796545fdf9bSopenharmony_ci * @tc.name: ExecCommand 797545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable -n <bundle-name> -u <user-id>" command. 798545fdf9bSopenharmony_ci */ 799545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0009, Function | MediumTest | Level1) 800545fdf9bSopenharmony_ci{ 801545fdf9bSopenharmony_ci char *argv[] = { 802545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 803545fdf9bSopenharmony_ci const_cast<char*>("enable"), 804545fdf9bSopenharmony_ci const_cast<char*>("-n"), 805545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 806545fdf9bSopenharmony_ci const_cast<char*>("-u"), 807545fdf9bSopenharmony_ci const_cast<char*>(DEFAULT_USER_ID.c_str()), 808545fdf9bSopenharmony_ci const_cast<char*>(""), 809545fdf9bSopenharmony_ci }; 810545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 811545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 812545fdf9bSopenharmony_ci // set the mock objects 813545fdf9bSopenharmony_ci SetMockObjects(cmd); 814545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_ENABLE_BUNDLE_OK + "\n"); 815545fdf9bSopenharmony_ci} 816545fdf9bSopenharmony_ci 817545fdf9bSopenharmony_ci/** 818545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0010 819545fdf9bSopenharmony_ci * @tc.name: ExecCommand 820545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable -h" command. 821545fdf9bSopenharmony_ci */ 822545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0010, Function | MediumTest | Level1) 823545fdf9bSopenharmony_ci{ 824545fdf9bSopenharmony_ci char *argv[] = { 825545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 826545fdf9bSopenharmony_ci const_cast<char*>("enable"), 827545fdf9bSopenharmony_ci const_cast<char*>("-h"), 828545fdf9bSopenharmony_ci const_cast<char*>(""), 829545fdf9bSopenharmony_ci }; 830545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 831545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 832545fdf9bSopenharmony_ci // set the mock objects 833545fdf9bSopenharmony_ci SetMockObjects(cmd); 834545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_ENABLE); 835545fdf9bSopenharmony_ci} 836545fdf9bSopenharmony_ci 837545fdf9bSopenharmony_ci/** 838545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Enable_0011 839545fdf9bSopenharmony_ci * @tc.name: ExecCommand 840545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm enable -n <bundle-name> -xxx <user-id>" command. 841545fdf9bSopenharmony_ci */ 842545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Enable_0011, Function | MediumTest | Level1) 843545fdf9bSopenharmony_ci{ 844545fdf9bSopenharmony_ci char *argv[] = { 845545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 846545fdf9bSopenharmony_ci const_cast<char*>("enable"), 847545fdf9bSopenharmony_ci const_cast<char*>("-n"), 848545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 849545fdf9bSopenharmony_ci const_cast<char*>("-XXX"), 850545fdf9bSopenharmony_ci const_cast<char*>(DEFAULT_USER_ID.c_str()), 851545fdf9bSopenharmony_ci const_cast<char*>(""), 852545fdf9bSopenharmony_ci }; 853545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 854545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 855545fdf9bSopenharmony_ci // set the mock objects 856545fdf9bSopenharmony_ci SetMockObjects(cmd); 857545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_ENABLE); 858545fdf9bSopenharmony_ci} 859545fdf9bSopenharmony_ci 860545fdf9bSopenharmony_ci/** 861545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0001 862545fdf9bSopenharmony_ci * @tc.name: ExecCommand 863545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable" command. 864545fdf9bSopenharmony_ci */ 865545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0001, Function | MediumTest | Level1) 866545fdf9bSopenharmony_ci{ 867545fdf9bSopenharmony_ci char *argv[] = { 868545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 869545fdf9bSopenharmony_ci const_cast<char*>("disable"), 870545fdf9bSopenharmony_ci const_cast<char*>(""), 871545fdf9bSopenharmony_ci }; 872545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 873545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 874545fdf9bSopenharmony_ci // set the mock objects 875545fdf9bSopenharmony_ci SetMockObjects(cmd); 876545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_DISABLE); 877545fdf9bSopenharmony_ci} 878545fdf9bSopenharmony_ci 879545fdf9bSopenharmony_ci/** 880545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0002 881545fdf9bSopenharmony_ci * @tc.name: ExecCommand 882545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable -n <bundle-name>" command. 883545fdf9bSopenharmony_ci */ 884545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0002, Function | MediumTest | Level1) 885545fdf9bSopenharmony_ci{ 886545fdf9bSopenharmony_ci char *argv[] = { 887545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 888545fdf9bSopenharmony_ci const_cast<char*>("disable"), 889545fdf9bSopenharmony_ci const_cast<char*>("-n"), 890545fdf9bSopenharmony_ci const_cast<char*>(""), 891545fdf9bSopenharmony_ci }; 892545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 893545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 894545fdf9bSopenharmony_ci // set the mock objects 895545fdf9bSopenharmony_ci SetMockObjects(cmd); 896545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_DISABLE); 897545fdf9bSopenharmony_ci} 898545fdf9bSopenharmony_ci 899545fdf9bSopenharmony_ci/** 900545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0003 901545fdf9bSopenharmony_ci * @tc.name: ExecCommand 902545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable -n <bundle-name>" command. 903545fdf9bSopenharmony_ci */ 904545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0003, Function | MediumTest | Level1) 905545fdf9bSopenharmony_ci{ 906545fdf9bSopenharmony_ci char *argv[] = { 907545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 908545fdf9bSopenharmony_ci const_cast<char*>("disable"), 909545fdf9bSopenharmony_ci const_cast<char*>("-n"), 910545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 911545fdf9bSopenharmony_ci const_cast<char*>(""), 912545fdf9bSopenharmony_ci }; 913545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 914545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 915545fdf9bSopenharmony_ci // set the mock objects 916545fdf9bSopenharmony_ci SetMockObjects(cmd); 917545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_DISABLE_BUNDLE_OK + "\n"); 918545fdf9bSopenharmony_ci} 919545fdf9bSopenharmony_ci 920545fdf9bSopenharmony_ci/** 921545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0004 922545fdf9bSopenharmony_ci * @tc.name: ExecCommand 923545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable -n <bundle-name> -a <ability-name>" command. 924545fdf9bSopenharmony_ci */ 925545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0004, Function | MediumTest | Level1) 926545fdf9bSopenharmony_ci{ 927545fdf9bSopenharmony_ci char *argv[] = { 928545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 929545fdf9bSopenharmony_ci const_cast<char*>("disable"), 930545fdf9bSopenharmony_ci const_cast<char*>("-n"), 931545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 932545fdf9bSopenharmony_ci const_cast<char*>("-a"), 933545fdf9bSopenharmony_ci const_cast<char*>(""), 934545fdf9bSopenharmony_ci }; 935545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 936545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 937545fdf9bSopenharmony_ci // set the mock objects 938545fdf9bSopenharmony_ci SetMockObjects(cmd); 939545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_DISABLE); 940545fdf9bSopenharmony_ci} 941545fdf9bSopenharmony_ci 942545fdf9bSopenharmony_ci/** 943545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0005 944545fdf9bSopenharmony_ci * @tc.name: ExecCommand 945545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable -n <bundle-name> -a <ability-name>" command. 946545fdf9bSopenharmony_ci */ 947545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0005, Function | MediumTest | Level1) 948545fdf9bSopenharmony_ci{ 949545fdf9bSopenharmony_ci char *argv[] = { 950545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 951545fdf9bSopenharmony_ci const_cast<char*>("disable"), 952545fdf9bSopenharmony_ci const_cast<char*>("-n"), 953545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 954545fdf9bSopenharmony_ci const_cast<char*>("-a"), 955545fdf9bSopenharmony_ci const_cast<char*>(STRING_ABILITY_NAME.c_str()), 956545fdf9bSopenharmony_ci const_cast<char*>(""), 957545fdf9bSopenharmony_ci }; 958545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 959545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 960545fdf9bSopenharmony_ci // set the mock objects 961545fdf9bSopenharmony_ci SetMockObjects(cmd); 962545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_DISABLE_BUNDLE_OK + "\n"); 963545fdf9bSopenharmony_ci} 964545fdf9bSopenharmony_ci 965545fdf9bSopenharmony_ci/** 966545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0006 967545fdf9bSopenharmony_ci * @tc.name: ExecCommand 968545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable -n <bundle-name> -u <user-id>" command. 969545fdf9bSopenharmony_ci */ 970545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0006, Function | MediumTest | Level1) 971545fdf9bSopenharmony_ci{ 972545fdf9bSopenharmony_ci char *argv[] = { 973545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 974545fdf9bSopenharmony_ci const_cast<char*>("disable"), 975545fdf9bSopenharmony_ci const_cast<char*>("-n"), 976545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 977545fdf9bSopenharmony_ci const_cast<char*>("-u"), 978545fdf9bSopenharmony_ci const_cast<char*>(""), 979545fdf9bSopenharmony_ci }; 980545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 981545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 982545fdf9bSopenharmony_ci // set the mock objects 983545fdf9bSopenharmony_ci SetMockObjects(cmd); 984545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_DISABLE); 985545fdf9bSopenharmony_ci} 986545fdf9bSopenharmony_ci 987545fdf9bSopenharmony_ci/** 988545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0007 989545fdf9bSopenharmony_ci * @tc.name: ExecCommand 990545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable -n <bundle-name> -u <user-id>" command. 991545fdf9bSopenharmony_ci */ 992545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0007, Function | MediumTest | Level1) 993545fdf9bSopenharmony_ci{ 994545fdf9bSopenharmony_ci char *argv[] = { 995545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 996545fdf9bSopenharmony_ci const_cast<char*>("disable"), 997545fdf9bSopenharmony_ci const_cast<char*>("-n"), 998545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 999545fdf9bSopenharmony_ci const_cast<char*>("-u"), 1000545fdf9bSopenharmony_ci const_cast<char*>("100"), 1001545fdf9bSopenharmony_ci const_cast<char*>(""), 1002545fdf9bSopenharmony_ci }; 1003545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1004545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1005545fdf9bSopenharmony_ci // set the mock objects 1006545fdf9bSopenharmony_ci SetMockObjects(cmd); 1007545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_DISABLE_BUNDLE_OK + "\n"); 1008545fdf9bSopenharmony_ci} 1009545fdf9bSopenharmony_ci 1010545fdf9bSopenharmony_ci/** 1011545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0008 1012545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1013545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable -x" command. 1014545fdf9bSopenharmony_ci */ 1015545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0008, Function | MediumTest | Level1) 1016545fdf9bSopenharmony_ci{ 1017545fdf9bSopenharmony_ci char *argv[] = { 1018545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1019545fdf9bSopenharmony_ci const_cast<char*>("disable"), 1020545fdf9bSopenharmony_ci const_cast<char*>("-x"), 1021545fdf9bSopenharmony_ci const_cast<char*>(""), 1022545fdf9bSopenharmony_ci }; 1023545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1024545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1025545fdf9bSopenharmony_ci // set the mock objects 1026545fdf9bSopenharmony_ci SetMockObjects(cmd); 1027545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_DISABLE); 1028545fdf9bSopenharmony_ci} 1029545fdf9bSopenharmony_ci 1030545fdf9bSopenharmony_ci/** 1031545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0009 1032545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1033545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable -h" command. 1034545fdf9bSopenharmony_ci */ 1035545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0009, Function | MediumTest | Level1) 1036545fdf9bSopenharmony_ci{ 1037545fdf9bSopenharmony_ci char *argv[] = { 1038545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1039545fdf9bSopenharmony_ci const_cast<char*>("disable"), 1040545fdf9bSopenharmony_ci const_cast<char*>("-h"), 1041545fdf9bSopenharmony_ci const_cast<char*>(""), 1042545fdf9bSopenharmony_ci }; 1043545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1044545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1045545fdf9bSopenharmony_ci // set the mock objects 1046545fdf9bSopenharmony_ci SetMockObjects(cmd); 1047545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_DISABLE); 1048545fdf9bSopenharmony_ci} 1049545fdf9bSopenharmony_ci 1050545fdf9bSopenharmony_ci/** 1051545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0010 1052545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1053545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable -n <bundle-name> -u XXX" command. 1054545fdf9bSopenharmony_ci */ 1055545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0010, Function | MediumTest | Level1) 1056545fdf9bSopenharmony_ci{ 1057545fdf9bSopenharmony_ci char *argv[] = { 1058545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1059545fdf9bSopenharmony_ci const_cast<char*>("disable"), 1060545fdf9bSopenharmony_ci const_cast<char*>("-u"), 1061545fdf9bSopenharmony_ci const_cast<char*>("XXX"), 1062545fdf9bSopenharmony_ci const_cast<char*>(""), 1063545fdf9bSopenharmony_ci }; 1064545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1065545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1066545fdf9bSopenharmony_ci // set the mock objects 1067545fdf9bSopenharmony_ci SetMockObjects(cmd); 1068545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_BUNDLE_NAME_OPTION + "\n" + HELP_MSG_DISABLE); 1069545fdf9bSopenharmony_ci} 1070545fdf9bSopenharmony_ci 1071545fdf9bSopenharmony_ci/** 1072545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Disable_0011 1073545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1074545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm disable -n <bundle-name> -xxx <ability-name>" command. 1075545fdf9bSopenharmony_ci */ 1076545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Disable_0011, Function | MediumTest | Level1) 1077545fdf9bSopenharmony_ci{ 1078545fdf9bSopenharmony_ci char *argv[] = { 1079545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1080545fdf9bSopenharmony_ci const_cast<char*>("disable"), 1081545fdf9bSopenharmony_ci const_cast<char*>("-n"), 1082545fdf9bSopenharmony_ci const_cast<char*>(STRING_BUNDLE_NAME.c_str()), 1083545fdf9bSopenharmony_ci const_cast<char*>("-XXX"), 1084545fdf9bSopenharmony_ci const_cast<char*>(STRING_ABILITY_NAME.c_str()), 1085545fdf9bSopenharmony_ci const_cast<char*>(""), 1086545fdf9bSopenharmony_ci }; 1087545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1088545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1089545fdf9bSopenharmony_ci // set the mock objects 1090545fdf9bSopenharmony_ci SetMockObjects(cmd); 1091545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), "error: unknown option.\n" + HELP_MSG_DISABLE); 1092545fdf9bSopenharmony_ci} 1093545fdf9bSopenharmony_ci 1094545fdf9bSopenharmony_ci/** 1095545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Get_0001 1096545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1097545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm get" command. 1098545fdf9bSopenharmony_ci */ 1099545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Get_0001, Function | MediumTest | Level1) 1100545fdf9bSopenharmony_ci{ 1101545fdf9bSopenharmony_ci // install a bundle 1102545fdf9bSopenharmony_ci char *argv[] = { 1103545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1104545fdf9bSopenharmony_ci const_cast<char*>("get"), 1105545fdf9bSopenharmony_ci const_cast<char*>(""), 1106545fdf9bSopenharmony_ci }; 1107545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1108545fdf9bSopenharmony_ci 1109545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1110545fdf9bSopenharmony_ci 1111545fdf9bSopenharmony_ci // set the mock objects 1112545fdf9bSopenharmony_ci SetMockObjects(cmd); 1113545fdf9bSopenharmony_ci 1114545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_NO_OPTION + "\n" + HELP_MSG_GET); 1115545fdf9bSopenharmony_ci} 1116545fdf9bSopenharmony_ci 1117545fdf9bSopenharmony_ci/** 1118545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Get_0002 1119545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1120545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm get -u" command. 1121545fdf9bSopenharmony_ci */ 1122545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Get_0002, Function | MediumTest | Level1) 1123545fdf9bSopenharmony_ci{ 1124545fdf9bSopenharmony_ci // install a bundle 1125545fdf9bSopenharmony_ci char *argv[] = { 1126545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1127545fdf9bSopenharmony_ci const_cast<char*>("get"), 1128545fdf9bSopenharmony_ci const_cast<char*>("-u"), 1129545fdf9bSopenharmony_ci const_cast<char*>(""), 1130545fdf9bSopenharmony_ci }; 1131545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1132545fdf9bSopenharmony_ci 1133545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1134545fdf9bSopenharmony_ci 1135545fdf9bSopenharmony_ci // set the mock objects 1136545fdf9bSopenharmony_ci SetMockObjects(cmd); 1137545fdf9bSopenharmony_ci 1138545fdf9bSopenharmony_ci std::string result = cmd.ExecCommand(); 1139545fdf9bSopenharmony_ci auto pos = result.find(STRING_GET_UDID_OK); 1140545fdf9bSopenharmony_ci 1141545fdf9bSopenharmony_ci EXPECT_NE(pos, std::string::npos); 1142545fdf9bSopenharmony_ci} 1143545fdf9bSopenharmony_ci 1144545fdf9bSopenharmony_ci/** 1145545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Get_0003 1146545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1147545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm get -x" command. 1148545fdf9bSopenharmony_ci */ 1149545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Get_0003, Function | MediumTest | Level1) 1150545fdf9bSopenharmony_ci{ 1151545fdf9bSopenharmony_ci // install a bundle 1152545fdf9bSopenharmony_ci char *argv[] = { 1153545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1154545fdf9bSopenharmony_ci const_cast<char*>("get"), 1155545fdf9bSopenharmony_ci const_cast<char*>("-x"), 1156545fdf9bSopenharmony_ci const_cast<char*>(""), 1157545fdf9bSopenharmony_ci }; 1158545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1159545fdf9bSopenharmony_ci 1160545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1161545fdf9bSopenharmony_ci 1162545fdf9bSopenharmony_ci // set the mock objects 1163545fdf9bSopenharmony_ci SetMockObjects(cmd); 1164545fdf9bSopenharmony_ci 1165545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_INCORRECT_OPTION + "\n" + HELP_MSG_GET); 1166545fdf9bSopenharmony_ci} 1167545fdf9bSopenharmony_ci 1168545fdf9bSopenharmony_ci/** 1169545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Get_0004 1170545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1171545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm get -u -x" command. 1172545fdf9bSopenharmony_ci */ 1173545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Get_0004, Function | MediumTest | Level1) 1174545fdf9bSopenharmony_ci{ 1175545fdf9bSopenharmony_ci // install a bundle 1176545fdf9bSopenharmony_ci char *argv[] = { 1177545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1178545fdf9bSopenharmony_ci const_cast<char*>("get"), 1179545fdf9bSopenharmony_ci const_cast<char*>("-u"), 1180545fdf9bSopenharmony_ci const_cast<char*>("-x"), 1181545fdf9bSopenharmony_ci const_cast<char*>(""), 1182545fdf9bSopenharmony_ci }; 1183545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1184545fdf9bSopenharmony_ci 1185545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1186545fdf9bSopenharmony_ci 1187545fdf9bSopenharmony_ci // set the mock objects 1188545fdf9bSopenharmony_ci SetMockObjects(cmd); 1189545fdf9bSopenharmony_ci 1190545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_GET); 1191545fdf9bSopenharmony_ci} 1192545fdf9bSopenharmony_ci 1193545fdf9bSopenharmony_ci/** 1194545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Get_0005 1195545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1196545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm get -u xxx" command. 1197545fdf9bSopenharmony_ci */ 1198545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Get_0005, Function | MediumTest | Level1) 1199545fdf9bSopenharmony_ci{ 1200545fdf9bSopenharmony_ci // install a bundle 1201545fdf9bSopenharmony_ci char *argv[] = { 1202545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1203545fdf9bSopenharmony_ci const_cast<char*>("get"), 1204545fdf9bSopenharmony_ci const_cast<char*>("-u"), 1205545fdf9bSopenharmony_ci const_cast<char*>("xxx"), 1206545fdf9bSopenharmony_ci const_cast<char*>(""), 1207545fdf9bSopenharmony_ci }; 1208545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1209545fdf9bSopenharmony_ci 1210545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1211545fdf9bSopenharmony_ci 1212545fdf9bSopenharmony_ci // set the mock objects 1213545fdf9bSopenharmony_ci SetMockObjects(cmd); 1214545fdf9bSopenharmony_ci 1215545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_GET); 1216545fdf9bSopenharmony_ci} 1217545fdf9bSopenharmony_ci 1218545fdf9bSopenharmony_ci/** 1219545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Get_0006 1220545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1221545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm get --udid" command. 1222545fdf9bSopenharmony_ci */ 1223545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Get_0006, Function | MediumTest | Level1) 1224545fdf9bSopenharmony_ci{ 1225545fdf9bSopenharmony_ci // install a bundle 1226545fdf9bSopenharmony_ci char *argv[] = { 1227545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1228545fdf9bSopenharmony_ci const_cast<char*>("get"), 1229545fdf9bSopenharmony_ci const_cast<char*>("--udid"), 1230545fdf9bSopenharmony_ci const_cast<char*>(""), 1231545fdf9bSopenharmony_ci }; 1232545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1233545fdf9bSopenharmony_ci 1234545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1235545fdf9bSopenharmony_ci 1236545fdf9bSopenharmony_ci // set the mock objects 1237545fdf9bSopenharmony_ci SetMockObjects(cmd); 1238545fdf9bSopenharmony_ci 1239545fdf9bSopenharmony_ci std::string result = cmd.ExecCommand(); 1240545fdf9bSopenharmony_ci auto pos = result.find(STRING_GET_UDID_OK); 1241545fdf9bSopenharmony_ci 1242545fdf9bSopenharmony_ci EXPECT_NE(pos, std::string::npos); 1243545fdf9bSopenharmony_ci} 1244545fdf9bSopenharmony_ci 1245545fdf9bSopenharmony_ci/** 1246545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Get_0007 1247545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1248545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm get --xxx" command. 1249545fdf9bSopenharmony_ci */ 1250545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Get_0007, Function | MediumTest | Level1) 1251545fdf9bSopenharmony_ci{ 1252545fdf9bSopenharmony_ci // install a bundle 1253545fdf9bSopenharmony_ci char *argv[] = { 1254545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1255545fdf9bSopenharmony_ci const_cast<char*>("get"), 1256545fdf9bSopenharmony_ci const_cast<char*>("--xxx"), 1257545fdf9bSopenharmony_ci const_cast<char*>(""), 1258545fdf9bSopenharmony_ci }; 1259545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1260545fdf9bSopenharmony_ci 1261545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1262545fdf9bSopenharmony_ci 1263545fdf9bSopenharmony_ci // set the mock objects 1264545fdf9bSopenharmony_ci SetMockObjects(cmd); 1265545fdf9bSopenharmony_ci 1266545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), STRING_INCORRECT_OPTION + "\n" + HELP_MSG_GET); 1267545fdf9bSopenharmony_ci} 1268545fdf9bSopenharmony_ci 1269545fdf9bSopenharmony_ci/** 1270545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Get_0008 1271545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1272545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm get --udid -x" command. 1273545fdf9bSopenharmony_ci */ 1274545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Get_0008, Function | MediumTest | Level1) 1275545fdf9bSopenharmony_ci{ 1276545fdf9bSopenharmony_ci // install a bundle 1277545fdf9bSopenharmony_ci char *argv[] = { 1278545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1279545fdf9bSopenharmony_ci const_cast<char*>("get"), 1280545fdf9bSopenharmony_ci const_cast<char*>("--udid"), 1281545fdf9bSopenharmony_ci const_cast<char*>("-x"), 1282545fdf9bSopenharmony_ci const_cast<char*>(""), 1283545fdf9bSopenharmony_ci }; 1284545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1285545fdf9bSopenharmony_ci 1286545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1287545fdf9bSopenharmony_ci 1288545fdf9bSopenharmony_ci // set the mock objects 1289545fdf9bSopenharmony_ci SetMockObjects(cmd); 1290545fdf9bSopenharmony_ci 1291545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_GET); 1292545fdf9bSopenharmony_ci} 1293545fdf9bSopenharmony_ci 1294545fdf9bSopenharmony_ci/** 1295545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Get_0009 1296545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1297545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm get -u xxx" command. 1298545fdf9bSopenharmony_ci */ 1299545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Get_0009, Function | MediumTest | Level1) 1300545fdf9bSopenharmony_ci{ 1301545fdf9bSopenharmony_ci // install a bundle 1302545fdf9bSopenharmony_ci char *argv[] = { 1303545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1304545fdf9bSopenharmony_ci const_cast<char*>("get"), 1305545fdf9bSopenharmony_ci const_cast<char*>("--udid"), 1306545fdf9bSopenharmony_ci const_cast<char*>("xxx"), 1307545fdf9bSopenharmony_ci const_cast<char*>(""), 1308545fdf9bSopenharmony_ci }; 1309545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1310545fdf9bSopenharmony_ci 1311545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1312545fdf9bSopenharmony_ci 1313545fdf9bSopenharmony_ci // set the mock objects 1314545fdf9bSopenharmony_ci SetMockObjects(cmd); 1315545fdf9bSopenharmony_ci 1316545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_GET); 1317545fdf9bSopenharmony_ci} 1318545fdf9bSopenharmony_ci 1319545fdf9bSopenharmony_ci/** 1320545fdf9bSopenharmony_ci * @tc.number: Bm_Command_Get_0010 1321545fdf9bSopenharmony_ci * @tc.name: ExecCommand 1322545fdf9bSopenharmony_ci * @tc.desc: Verify the "bm get -h" command. 1323545fdf9bSopenharmony_ci */ 1324545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, Bm_Command_Get_0010, Function | MediumTest | Level1) 1325545fdf9bSopenharmony_ci{ 1326545fdf9bSopenharmony_ci // install a bundle 1327545fdf9bSopenharmony_ci char *argv[] = { 1328545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1329545fdf9bSopenharmony_ci const_cast<char*>("get"), 1330545fdf9bSopenharmony_ci const_cast<char*>("-h"), 1331545fdf9bSopenharmony_ci const_cast<char*>(""), 1332545fdf9bSopenharmony_ci }; 1333545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1334545fdf9bSopenharmony_ci 1335545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1336545fdf9bSopenharmony_ci 1337545fdf9bSopenharmony_ci // set the mock objects 1338545fdf9bSopenharmony_ci SetMockObjects(cmd); 1339545fdf9bSopenharmony_ci 1340545fdf9bSopenharmony_ci EXPECT_EQ(cmd.ExecCommand(), HELP_MSG_GET); 1341545fdf9bSopenharmony_ci} 1342545fdf9bSopenharmony_ci 1343545fdf9bSopenharmony_ci/** 1344545fdf9bSopenharmony_ci * @tc.number: GetBundlePath_0001 1345545fdf9bSopenharmony_ci * @tc.name: test GetBundlePath 1346545fdf9bSopenharmony_ci * @tc.desc: Verify the "GetBundlePath". 1347545fdf9bSopenharmony_ci */ 1348545fdf9bSopenharmony_ciHWTEST_F(BmCommandTest, GetBundlePath_0001, Function | MediumTest | Level1) 1349545fdf9bSopenharmony_ci{ 1350545fdf9bSopenharmony_ci // install a bundle 1351545fdf9bSopenharmony_ci char *argv[] = { 1352545fdf9bSopenharmony_ci const_cast<char*>(TOOL_NAME.c_str()), 1353545fdf9bSopenharmony_ci const_cast<char*>("-h"), 1354545fdf9bSopenharmony_ci }; 1355545fdf9bSopenharmony_ci int argc = sizeof(argv) / sizeof(argv[0]) - 1; 1356545fdf9bSopenharmony_ci 1357545fdf9bSopenharmony_ci BundleManagerShellCommand cmd(argc, argv); 1358545fdf9bSopenharmony_ci std::string param = ""; 1359545fdf9bSopenharmony_ci std::vector<std::string> bundlePaths; 1360545fdf9bSopenharmony_ci auto res = cmd.GetBundlePath(param, bundlePaths); 1361545fdf9bSopenharmony_ci EXPECT_EQ(res, ERR_INVALID_VALUE); 1362545fdf9bSopenharmony_ci 1363545fdf9bSopenharmony_ci param = "-r"; 1364545fdf9bSopenharmony_ci res = cmd.GetBundlePath(param, bundlePaths); 1365545fdf9bSopenharmony_ci EXPECT_EQ(res, ERR_INVALID_VALUE); 1366545fdf9bSopenharmony_ci 1367545fdf9bSopenharmony_ci param = "--replace"; 1368545fdf9bSopenharmony_ci res = cmd.GetBundlePath(param, bundlePaths); 1369545fdf9bSopenharmony_ci EXPECT_EQ(res, ERR_INVALID_VALUE); 1370545fdf9bSopenharmony_ci 1371545fdf9bSopenharmony_ci param = "-p"; 1372545fdf9bSopenharmony_ci res = cmd.GetBundlePath(param, bundlePaths); 1373545fdf9bSopenharmony_ci EXPECT_EQ(res, ERR_INVALID_VALUE); 1374545fdf9bSopenharmony_ci 1375545fdf9bSopenharmony_ci param = "--bundle-path"; 1376545fdf9bSopenharmony_ci res = cmd.GetBundlePath(param, bundlePaths); 1377545fdf9bSopenharmony_ci EXPECT_EQ(res, ERR_INVALID_VALUE); 1378545fdf9bSopenharmony_ci 1379545fdf9bSopenharmony_ci param = "-u"; 1380545fdf9bSopenharmony_ci res = cmd.GetBundlePath(param, bundlePaths); 1381545fdf9bSopenharmony_ci EXPECT_EQ(res, ERR_INVALID_VALUE); 1382545fdf9bSopenharmony_ci 1383545fdf9bSopenharmony_ci param = "--user-id"; 1384545fdf9bSopenharmony_ci res = cmd.GetBundlePath(param, bundlePaths); 1385545fdf9bSopenharmony_ci EXPECT_EQ(res, ERR_INVALID_VALUE); 1386545fdf9bSopenharmony_ci 1387545fdf9bSopenharmony_ci param = "-w"; 1388545fdf9bSopenharmony_ci res = cmd.GetBundlePath(param, bundlePaths); 1389545fdf9bSopenharmony_ci EXPECT_EQ(res, ERR_INVALID_VALUE); 1390545fdf9bSopenharmony_ci 1391545fdf9bSopenharmony_ci param = "--waitting-time"; 1392545fdf9bSopenharmony_ci res = cmd.GetBundlePath(param, bundlePaths); 1393545fdf9bSopenharmony_ci EXPECT_EQ(res, ERR_INVALID_VALUE); 1394545fdf9bSopenharmony_ci 1395545fdf9bSopenharmony_ci param = "-x"; 1396545fdf9bSopenharmony_ci res = cmd.GetBundlePath(param, bundlePaths); 1397545fdf9bSopenharmony_ci EXPECT_EQ(res, ERR_OK); 1398545fdf9bSopenharmony_ci} 1399545fdf9bSopenharmony_ci} // namespace OHOS