196279301Sopenharmony_ci/*
296279301Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
396279301Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
496279301Sopenharmony_ci * you may not use this file except in compliance with the License.
596279301Sopenharmony_ci * You may obtain a copy of the License at
696279301Sopenharmony_ci *
796279301Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
896279301Sopenharmony_ci *
996279301Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1096279301Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1196279301Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1296279301Sopenharmony_ci * See the License for the specific language governing permissions and
1396279301Sopenharmony_ci * limitations under the License.
1496279301Sopenharmony_ci */
1596279301Sopenharmony_ci#define private public
1696279301Sopenharmony_ci#define protected public
1796279301Sopenharmony_ci
1896279301Sopenharmony_ci#include "ans_notification.h"
1996279301Sopenharmony_ci#include "iservice_registry.h"
2096279301Sopenharmony_ci#include "singleton.h"
2196279301Sopenharmony_ci#include "system_ability_definition.h"
2296279301Sopenharmony_ci
2396279301Sopenharmony_ci#undef private
2496279301Sopenharmony_ci#undef protected
2596279301Sopenharmony_ci
2696279301Sopenharmony_ci#include <gtest/gtest.h>
2796279301Sopenharmony_ci
2896279301Sopenharmony_ciusing namespace testing::ext;
2996279301Sopenharmony_ci
3096279301Sopenharmony_cinamespace OHOS {
3196279301Sopenharmony_cinamespace Notification {
3296279301Sopenharmony_ciclass AnsDumpTest : public testing::Test {
3396279301Sopenharmony_cipublic:
3496279301Sopenharmony_ci    static void SetUpTestCase();
3596279301Sopenharmony_ci    static void TearDownTestCase();
3696279301Sopenharmony_ci    void SetUp();
3796279301Sopenharmony_ci    void TearDown();
3896279301Sopenharmony_ci
3996279301Sopenharmony_ci    std::shared_ptr<AnsNotification> ans_;
4096279301Sopenharmony_ci};
4196279301Sopenharmony_ci
4296279301Sopenharmony_civoid AnsDumpTest::SetUpTestCase()
4396279301Sopenharmony_ci{}
4496279301Sopenharmony_ci
4596279301Sopenharmony_civoid AnsDumpTest::TearDownTestCase()
4696279301Sopenharmony_ci{}
4796279301Sopenharmony_ci
4896279301Sopenharmony_civoid AnsDumpTest::SetUp()
4996279301Sopenharmony_ci{
5096279301Sopenharmony_ci    if (!ans_) {
5196279301Sopenharmony_ci        ans_ = DelayedSingleton<AnsNotification>::GetInstance();
5296279301Sopenharmony_ci    }
5396279301Sopenharmony_ci}
5496279301Sopenharmony_ci
5596279301Sopenharmony_civoid AnsDumpTest::TearDown()
5696279301Sopenharmony_ci{}
5796279301Sopenharmony_ci
5896279301Sopenharmony_ci/*
5996279301Sopenharmony_ci * @tc.number: AnsDumpTest_GetServiceObject_0100
6096279301Sopenharmony_ci * @tc.name: Get Service Object
6196279301Sopenharmony_ci * @tc.desc:
6296279301Sopenharmony_ci */
6396279301Sopenharmony_ciHWTEST_F(AnsDumpTest, AnsDumpTest_GetServiceObject_0100, Function | MediumTest | Level0)
6496279301Sopenharmony_ci{
6596279301Sopenharmony_ci    sptr<ISystemAbilityManager> systemAbilityManager =
6696279301Sopenharmony_ci        SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
6796279301Sopenharmony_ci    EXPECT_NE(systemAbilityManager, nullptr);
6896279301Sopenharmony_ci
6996279301Sopenharmony_ci    sptr<IRemoteObject> remoteObject =
7096279301Sopenharmony_ci        systemAbilityManager->GetSystemAbility(ADVANCED_NOTIFICATION_SERVICE_ABILITY_ID);
7196279301Sopenharmony_ci    EXPECT_NE(remoteObject, nullptr);
7296279301Sopenharmony_ci}
7396279301Sopenharmony_ci
7496279301Sopenharmony_ci/*
7596279301Sopenharmony_ci * @tc.number: AnsDumpTest_ShellDump_0100
7696279301Sopenharmony_ci * @tc.name: Shell Dump
7796279301Sopenharmony_ci * @tc.desc:
7896279301Sopenharmony_ci */
7996279301Sopenharmony_ciHWTEST_F(AnsDumpTest, AnsDumpTest_ShellDump_0100, Function | MediumTest | Level0)
8096279301Sopenharmony_ci{
8196279301Sopenharmony_ci    std::vector<std::string> infos;
8296279301Sopenharmony_ci    if (ans_) {
8396279301Sopenharmony_ci        auto ret = ans_->ShellDump("active", infos);
8496279301Sopenharmony_ci        EXPECT_EQ(ret, 0);
8596279301Sopenharmony_ci    }
8696279301Sopenharmony_ci}
8796279301Sopenharmony_ci}  // namespace Notification
8896279301Sopenharmony_ci}  // namespace OHOS