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 "continue_scene_session_handler_test.h"
17 
18 #include "dtbschedmgr_log.h"
19 #include "test_log.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace DistributedSchedule {
26 
SetUpTestCase()27 void ContinueSceneSessionHandlerTest::SetUpTestCase()
28 {
29     DTEST_LOG << "ContinueSceneSessionHandlerTest::SetUpTestCase" << std::endl;
30 }
31 
TearDownTestCase()32 void ContinueSceneSessionHandlerTest::TearDownTestCase()
33 {
34     DTEST_LOG << "ContinueSceneSessionHandlerTest::TearDownTestCase" << std::endl;
35 }
36 
TearDown()37 void ContinueSceneSessionHandlerTest::TearDown()
38 {
39     DTEST_LOG << "ContinueSceneSessionHandlerTest::TearDown" << std::endl;
40 }
41 
SetUp()42 void ContinueSceneSessionHandlerTest::SetUp()
43 {
44     DTEST_LOG << "ContinueSceneSessionHandlerTest::SetUp" << std::endl;
45 }
46 
47 /**
48  * @tc.name: UpdateContinueSessionId_001
49  * @tc.desc: generated continueSessionId by bundleName and abilityName
50  * @tc.type: FUNC
51  * @tc.require: SR20240116512594
52  */
53 HWTEST_F(ContinueSceneSessionHandlerTest, UpdateContinueSessionId_001, TestSize.Level3)
54 {
55     DTEST_LOG << "ContinueSceneSessionHandlerTest UpdateContinueSessionId_001 begin" << std::endl;
56     std::string bundleName = "ohos.dms.bundleName_001";
57     std::string abilityName = "ohos.dms.abilityName_001";
58     ContinueSceneSessionHandler::GetInstance().UpdateContinueSessionId(bundleName, abilityName);
59     std::string continueSessionId = ContinueSceneSessionHandler::GetInstance().GetContinueSessionId();
60     EXPECT_FALSE(continueSessionId.empty());
61     DTEST_LOG << "ContinueSceneSessionHandlerTest UpdateContinueSessionId_001 end" << std::endl;
62 }
63 
64 /**
65  * @tc.name: GetContinueSessionId_001
66  * @tc.desc: get continueSessionId test
67  * @tc.type: FUNC
68  * @tc.require: SR20240116512594
69  */
70     HWTEST_F(ContinueSceneSessionHandlerTest, GetContinueSessionId_001, TestSize.Level3)
71 {
72     DTEST_LOG << "ContinueSceneSessionHandlerTest GetContinueSessionId_001 begin" << std::endl;
73     std::string continueSessionId = ContinueSceneSessionHandler::GetInstance().GetContinueSessionId();
74     EXPECT_FALSE(continueSessionId.empty());
75     DTEST_LOG << "ContinueSceneSessionHandlerTest GetContinueSessionId_001 end" << std::endl;
76 }
77 
78 /**
79  * @tc.name: GetPersistentId_001
80  * @tc.desc: get persistentId by continueSessionId
81  * @tc.type: FUNC
82  * @tc.require: SR20240116512594
83  */
84 HWTEST_F(ContinueSceneSessionHandlerTest, GetPersistentId_001, TestSize.Level3)
85 {
86     DTEST_LOG << "ContinueSceneSessionHandlerTest GetPersistentId_001 begin" << std::endl;
87     int32_t persistentId;
88     int32_t err = ContinueSceneSessionHandler::GetInstance().GetPersistentId(persistentId);
89     EXPECT_EQ(static_cast<int32_t>(INVALID_PARAMETERS_ERR), err);
90     DTEST_LOG << "ContinueSceneSessionHandlerTest GetPersistentId_001 end" << std::endl;
91 }
92 
93 /**
94  * @tc.name: ClearContinueSessionId_001
95  * @tc.desc: clear continueSessionId test
96  * @tc.type: FUNC
97  * @tc.require: SR20240116512594
98  */
99 HWTEST_F(ContinueSceneSessionHandlerTest, ClearContinueSessionId_001, TestSize.Level3)
100 {
101     DTEST_LOG << "ContinueSceneSessionHandlerTest ClearContinueSessionId_001 begin" << std::endl;
102     ContinueSceneSessionHandler::GetInstance().ClearContinueSessionId();
103     std::string continueSessionId = ContinueSceneSessionHandler::GetInstance().GetContinueSessionId();
104     EXPECT_TRUE(continueSessionId.empty());
105     DTEST_LOG << "ContinueSceneSessionHandlerTest ClearContinueSessionId_001 end" << std::endl;
106 }
107 }
108 }