diff --git a/test/BUILD.gn b/test/BUILD.gn index 7f120ed9d5ec591f95d7719df30d61e7a7517750..1cd6c473bda10397aea56b5ccd733c6c48d551b1 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -27,5 +27,6 @@ group("systemtest") { deps = [ "common\acts:actsnotificationtest", "resource\ansSTSlotGroupTest:ansSTSlotGroupTest", + "systemtest\acts\ansDump:ansDumpTest", ] } diff --git a/test/systemtest/acts/ansDump/BUILD.gn b/test/systemtest/acts/ansDump/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fd79d5caa61a6217ec4fd5ad84d5212a48314173 --- /dev/null +++ b/test/systemtest/acts/ansDump/BUILD.gn @@ -0,0 +1,56 @@ +# 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. + +import("//base/notification/ans_standard/notification.gni") +import("//build/test.gni") + +module_output_path = "ans_standard/systemtest" +ohos_systemtest("AnsDumpTest") { + module_out_path = module_output_path + + sources = [ "ansDumpTest.cpp" ] + + include_dirs = [ + "//foundation/aafwk/standard/interfaces/innerkits/want/include/ohos/aafwk/content", + "//third_party/json/single_include", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + ] + + cflags = [] + + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${frameworks_path}/ans/core:ans_core", + "${frameworks_path}/wantagent:wantagent_innerkits", + "//third_party/googletest:gtest_main", + "//utils/native/base:utils", + ] + + external_deps = [ + "aafwk_standard:want", + "appexecfwk_standard:appexecfwk_core", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "samgr_standard:samgr_proxy", + ] +} + +group("ansDumpTest") { + testonly = true + + deps = [ ":AnsDumpTest" ] +} diff --git a/test/systemtest/acts/ansDump/ansDumpTest.cpp b/test/systemtest/acts/ansDump/ansDumpTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..de9999186ef7e38924bf52699b9ce0aa432a6038 --- /dev/null +++ b/test/systemtest/acts/ansDump/ansDumpTest.cpp @@ -0,0 +1,88 @@ +/* + * 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. + */ +#define private public +#define protected public + +#include "ans_notification.h" +#include "iservice_registry.h" +#include "singleton.h" +#include "system_ability_definition.h" + +#undef private +#undef protected + +#include + +using namespace testing::ext; + +namespace OHOS { +namespace Notification { +class AnsDumpTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); + + std::shared_ptr ans_; +}; + +void AnsDumpTest::SetUpTestCase() +{} + +void AnsDumpTest::TearDownTestCase() +{} + +void AnsDumpTest::SetUp() +{ + if (!ans_) { + ans_ = DelayedSingleton::GetInstance(); + } +} + +void AnsDumpTest::TearDown() +{} + +/* + * @tc.number: AnsDumpTest_GetServiceObject_0100 + * @tc.name: Get Service Object + * @tc.desc: + */ +HWTEST_F(AnsDumpTest, AnsDumpTest_GetServiceObject_0100, Function | MediumTest | Level0) +{ + sptr systemAbilityManager = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + EXPECT_NE(systemAbilityManager, nullptr); + + sptr remoteObject = + systemAbilityManager->GetSystemAbility(ADVANCED_NOTIFICATION_SERVICE_ABILITY_ID); + EXPECT_NE(remoteObject, nullptr); +} + +/* + * @tc.number: AnsDumpTest_ShellDump_0100 + * @tc.name: Shell Dump + * @tc.desc: + */ +HWTEST_F(AnsDumpTest, AnsDumpTest_ShellDump_0100, Function | MediumTest | Level0) +{ + std::vector infos; + if (ans_) { + auto ret = ans_->ShellDump("active", infos); + EXPECT_EQ(ret, 0); + } +} +} // namespace Notification +} // namespace OHOS \ No newline at end of file