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 "switch_status_dependency_test.h"
17 
18 #include "test_log.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace DistributedSchedule {
25 namespace {
26     const std::string CONTINUE_SWITCH_STATUS_KEY = "Continue_Switch_Status";
27     const std::string CONTINUE_SWITCH_OFF = "0";
28     const std::string CONTINUE_SWITCH_ON = "1";
29 }
30 
SetUpTestCase()31 void SwitchStatusDependencyTest::SetUpTestCase()
32 {
33     DTEST_LOG << "SwitchStatusDependencyTest::SetUpTestCase" << std::endl;
34 }
35 
TearDownTestCase()36 void SwitchStatusDependencyTest::TearDownTestCase()
37 {
38     DTEST_LOG << "SwitchStatusDependencyTest::TearDownTestCase" << std::endl;
39 }
40 
TearDown()41 void SwitchStatusDependencyTest::TearDown()
42 {
43     DTEST_LOG << "SwitchStatusDependencyTest::TearDown" << std::endl;
44 }
45 
SetUp()46 void SwitchStatusDependencyTest::SetUp()
47 {
48     DTEST_LOG << "SwitchStatusDependencyTest::SetUp" << std::endl;
49 }
50 
51 /**
52  * @tc.name: IsContinueSwitchOn_001
53  * @tc.desc: IsContinueSwitchOn
54  * @tc.type: FUNC
55  * @tc.require: SR20240116513791
56  */
57 HWTEST_F(SwitchStatusDependencyTest, IsContinueSwitchOn_001, TestSize.Level3)
58 {
59     DTEST_LOG << "SwitchStatusDependencyTest IsContinueSwitchOn_001 begin" << std::endl;
60     EXPECT_TRUE(SwitchStatusDependency::GetInstance().IsContinueSwitchOn());
61     DTEST_LOG << "SwitchStatusDependencyTest IsContinueSwitchOn_001 end" << std::endl;
62 }
63 
64 /**
65  * @tc.name: IsCreateDataShareHelper_001
66  * @tc.desc: IsCreateDataShareHelper
67  * @tc.type: FUNC
68  * @tc.require: SR20240116513791
69  */
70 HWTEST_F(SwitchStatusDependencyTest, IsCreateDataShareHelper_001, TestSize.Level3)
71 {
72     DTEST_LOG << "SwitchStatusDependencyTest IsCreateDataShareHelper_001 begin" << std::endl;
73     std::string key = "";
74     std::string defaultValue = CONTINUE_SWITCH_ON;
75     SwitchStatusDependency::GetInstance().GetDataShareHelper();
76     EXPECT_EQ(CONTINUE_SWITCH_ON,
77         SwitchStatusDependency::GetInstance().GetSwitchStatus(key, defaultValue));
78     key = CONTINUE_SWITCH_STATUS_KEY;
79     defaultValue = CONTINUE_SWITCH_ON;
80     EXPECT_EQ(CONTINUE_SWITCH_ON,
81         SwitchStatusDependency::GetInstance().GetSwitchStatus(key, defaultValue));
82     DTEST_LOG << "SwitchStatusDependencyTest IsCreateDataShareHelper_001 end" << std::endl;
83 }
84 }
85 }