• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define private public
17 #include "continue_scene_session_handler_test.h"
18 #undef private
19 
20 #include "dtbschedmgr_log.h"
21 #include "test_log.h"
22 
23 using namespace testing;
24 using namespace testing::ext;
25 
26 namespace OHOS {
27 namespace DistributedSchedule {
28 
SetUpTestCase()29 void ContinueSceneSessionHandlerTest::SetUpTestCase()
30 {
31     DTEST_LOG << "ContinueSceneSessionHandlerTest::SetUpTestCase" << std::endl;
32 }
33 
TearDownTestCase()34 void ContinueSceneSessionHandlerTest::TearDownTestCase()
35 {
36     DTEST_LOG << "ContinueSceneSessionHandlerTest::TearDownTestCase" << std::endl;
37 }
38 
TearDown()39 void ContinueSceneSessionHandlerTest::TearDown()
40 {
41     DTEST_LOG << "ContinueSceneSessionHandlerTest::TearDown" << std::endl;
42 }
43 
SetUp()44 void ContinueSceneSessionHandlerTest::SetUp()
45 {
46     DTEST_LOG << "ContinueSceneSessionHandlerTest::SetUp" << std::endl;
47 }
48 
49 /**
50  * @tc.name: UpdateContinueSessionId_001
51  * @tc.desc: generated continueSessionId by bundleName and abilityName
52  * @tc.type: FUNC
53  * @tc.require: SR20240116512594
54  */
55 HWTEST_F(ContinueSceneSessionHandlerTest, UpdateContinueSessionId_001, TestSize.Level3)
56 {
57     DTEST_LOG << "ContinueSceneSessionHandlerTest UpdateContinueSessionId_001 begin" << std::endl;
58     std::string bundleName = "ohos.dms.bundleName_001";
59     std::string abilityName = "ohos.dms.abilityName_001";
60     ContinueSceneSessionHandler::GetInstance().UpdateContinueSessionId(bundleName, abilityName);
61     std::string continueSessionId = ContinueSceneSessionHandler::GetInstance().GetContinueSessionId();
62     EXPECT_FALSE(continueSessionId.empty());
63     DTEST_LOG << "ContinueSceneSessionHandlerTest UpdateContinueSessionId_001 end" << std::endl;
64 }
65 
66 /**
67  * @tc.name: GetContinueSessionId_001
68  * @tc.desc: get continueSessionId test
69  * @tc.type: FUNC
70  * @tc.require: SR20240116512594
71  */
72     HWTEST_F(ContinueSceneSessionHandlerTest, GetContinueSessionId_001, TestSize.Level3)
73 {
74     DTEST_LOG << "ContinueSceneSessionHandlerTest GetContinueSessionId_001 begin" << std::endl;
75     std::string continueSessionId = ContinueSceneSessionHandler::GetInstance().GetContinueSessionId();
76     EXPECT_FALSE(continueSessionId.empty());
77     DTEST_LOG << "ContinueSceneSessionHandlerTest GetContinueSessionId_001 end" << std::endl;
78 }
79 
80 /**
81  * @tc.name: GetPersistentId_001
82  * @tc.desc: get persistentId by continueSessionId
83  * @tc.type: FUNC
84  * @tc.require: SR20240116512594
85  */
86 HWTEST_F(ContinueSceneSessionHandlerTest, GetPersistentId_001, TestSize.Level3)
87 {
88     DTEST_LOG << "ContinueSceneSessionHandlerTest GetPersistentId_001 begin" << std::endl;
89     int32_t persistentId;
90     int32_t err = ContinueSceneSessionHandler::GetInstance().GetPersistentId(persistentId);
91     EXPECT_EQ(static_cast<int32_t>(INVALID_PARAMETERS_ERR), err);
92     DTEST_LOG << "ContinueSceneSessionHandlerTest GetPersistentId_001 end" << std::endl;
93 }
94 
95 /**
96  * @tc.name: GetPersistentId_002
97  * @tc.desc: get persistentId by continueSessionId
98  * @tc.type: FUNC
99  * @tc.require: SR20240116512594
100  */
101 HWTEST_F(ContinueSceneSessionHandlerTest, GetPersistentId_002, TestSize.Level3)
102 {
103     DTEST_LOG << "ContinueSceneSessionHandlerTest GetPersistentId_002 begin" << std::endl;
104     int32_t persistentId;
105     ContinueSceneSessionHandler::GetInstance().continueSessionId_.clear();
106     int32_t err = ContinueSceneSessionHandler::GetInstance().GetPersistentId(persistentId);
107     EXPECT_EQ(INVALID_PARAMETERS_ERR, err);
108     DTEST_LOG << "ContinueSceneSessionHandlerTest GetPersistentId_002 end" << std::endl;
109 }
110 
111 /**
112  * @tc.name: GetPersistentId_003
113  * @tc.desc: get persistentId by continueSessionId
114  * @tc.type: FUNC
115  * @tc.require: SR20240116512594
116  */
117 HWTEST_F(ContinueSceneSessionHandlerTest, GetPersistentId_003, TestSize.Level3)
118 {
119     DTEST_LOG << "ContinueSceneSessionHandlerTest GetPersistentId_003 begin" << std::endl;
120     int32_t persistentId;
121     std::string continueSessionId = "continueSessionId";
122     int32_t err = ContinueSceneSessionHandler::GetInstance().GetPersistentId(persistentId, continueSessionId);
123     EXPECT_EQ(static_cast<int32_t>(INVALID_PARAMETERS_ERR), err);
124     DTEST_LOG << "ContinueSceneSessionHandlerTest GetPersistentId_003 end" << std::endl;
125 }
126 
127 /**
128  * @tc.name: GetPersistentId_004
129  * @tc.desc: get persistentId by continueSessionId
130  * @tc.type: FUNC
131  * @tc.require: SR20240116512594
132  */
133 HWTEST_F(ContinueSceneSessionHandlerTest, GetPersistentId_004, TestSize.Level3)
134 {
135     DTEST_LOG << "ContinueSceneSessionHandlerTest GetPersistentId_004 begin" << std::endl;
136     int32_t persistentId;
137     std::string continueSessionId = "continueSessionId";
138     ContinueSceneSessionHandler::GetInstance().continueSessionId_.clear();
139     int32_t err = ContinueSceneSessionHandler::GetInstance().GetPersistentId(persistentId, continueSessionId);
140     EXPECT_EQ(INVALID_PARAMETERS_ERR, err);
141     DTEST_LOG << "ContinueSceneSessionHandlerTest GetPersistentId_004 end" << std::endl;
142 }
143 
144 /**
145  * @tc.name: ClearContinueSessionId_001
146  * @tc.desc: clear continueSessionId test
147  * @tc.type: FUNC
148  * @tc.require: SR20240116512594
149  */
150 HWTEST_F(ContinueSceneSessionHandlerTest, ClearContinueSessionId_001, TestSize.Level3)
151 {
152     DTEST_LOG << "ContinueSceneSessionHandlerTest ClearContinueSessionId_001 begin" << std::endl;
153     ContinueSceneSessionHandler::GetInstance().ClearContinueSessionId();
154     std::string continueSessionId = ContinueSceneSessionHandler::GetInstance().GetContinueSessionId();
155     EXPECT_TRUE(continueSessionId.empty());
156     DTEST_LOG << "ContinueSceneSessionHandlerTest ClearContinueSessionId_001 end" << std::endl;
157 }
158 }
159 }