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 "event_export_mgr_test.h"
17
18 #include "setting_observer_manager.h"
19
20 namespace OHOS {
21 namespace HiviewDFX {
22 namespace {
23 constexpr char PARAM_NAME[] = "PARAM_NAME";
24 constexpr char DEFAULT_VAL[] = "DEFAULT_VAL";
25 }
26
SetUpTestCase()27 void EventExportMgrTest::SetUpTestCase()
28 {
29 }
30
TearDownTestCase()31 void EventExportMgrTest::TearDownTestCase()
32 {
33 }
34
SetUp()35 void EventExportMgrTest::SetUp()
36 {
37 }
38
TearDown()39 void EventExportMgrTest::TearDown()
40 {
41 }
42
43 /**
44 * @tc.name: EventExportMgrTest001
45 * @tc.desc: Test apis of SettingObserverManager
46 * @tc.type: FUNC
47 * @tc.require: issueI9GHI8
48 */
49 HWTEST_F(EventExportMgrTest, EventExportMgrTest001, testing::ext::TestSize.Level3)
50 {
51 SettingObserver::ObserverCallback callback =
__anonf62509910202(const std::string& paramKey) 52 [] (const std::string& paramKey) {
53 // do nothing
54 };
55 auto ret = SettingObserverManager::GetInstance()->RegisterObserver(PARAM_NAME, callback);
56 ASSERT_TRUE(ret);
57 ret = SettingObserverManager::GetInstance()->UnregisterObserver(PARAM_NAME);
58 ASSERT_TRUE(ret);
59 auto value = SettingObserverManager::GetInstance()->GetStringValue(PARAM_NAME, DEFAULT_VAL);
60 ASSERT_EQ(value, DEFAULT_VAL);
61 }
62 } // namespace HiviewDFX
63 } // namespace OHOS