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 /** 17 * @tc.number: SUB_backup_sa_session_GetLastIncrementalTime_0100 18 * @tc.name: SUB_backup_sa_session_GetLastIncrementalTime_0100 19 * @tc.desc: 测试 GetLastIncrementalTime 20 * @tc.size: MEDIUM 21 * @tc.type: FUNC 22 * @tc.level Level 1 23 * @tc.require: I6F3GV 24 */ 25 HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_GetLastIncrementalTime_0100, testing::ext::TestSize.Level1) 26 { 27 GTEST_LOG_(INFO) << "SvcSessionManagerTest-begin SUB_backup_sa_session_GetLastIncrementalTime_0100"; 28 try { 29 try { 30 EXPECT_TRUE(sessionManagerPtr_ != nullptr); 31 sessionManagerPtr_->impl_.clientToken = 0; 32 sessionManagerPtr_->GetLastIncrementalTime(BUNDLE_NAME); 33 EXPECT_TRUE(false); 34 } catch (BError &err) { 35 EXPECT_EQ(err.GetRawCode(), BError::Codes::SA_INVAL_ARG); 36 } 37 38 sessionManagerPtr_->impl_.clientToken = CLIENT_TOKEN_ID; 39 sessionManagerPtr_->impl_.backupExtNameMap.clear(); 40 sessionManagerPtr_->impl_.backupExtNameMap[BUNDLE_NAME] = {}; 41 sessionManagerPtr_->GetLastIncrementalTime(BUNDLE_NAME); 42 EXPECT_TRUE(true); 43 } catch (...) { 44 EXPECT_TRUE(false); 45 GTEST_LOG_(INFO) << "SvcSessionManagerTest-an exception occurred by GetLastIncrementalTime."; 46 } 47 GTEST_LOG_(INFO) << "SvcSessionManagerTest-end SUB_backup_sa_session_GetLastIncrementalTime_0100"; 48 } 49 50 /** 51 * @tc.number: SUB_backup_sa_session_DecreaseSessionCnt_0100 52 * @tc.name: SUB_backup_sa_session_DecreaseSessionCnt_0100 53 * @tc.desc: 测试 DecreaseSessionCnt 54 * @tc.size: MEDIUM 55 * @tc.type: FUNC 56 * @tc.level Level 1 57 * @tc.require: I6F3GV 58 */ 59 HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_DecreaseSessionCnt_0100, testing::ext::TestSize.Level1) 60 { 61 GTEST_LOG_(INFO) << "SvcSessionManagerTest-begin SUB_backup_sa_session_DecreaseSessionCnt_0100"; 62 try { 63 sessionManagerPtr_->DecreaseSessionCnt(__PRETTY_FUNCTION__); 64 EXPECT_TRUE(true); 65 } catch (...) { 66 EXPECT_TRUE(false); 67 GTEST_LOG_(INFO) << "SvcSessionManagerTest-an exception occurred by DecreaseSessionCnt."; 68 } 69 GTEST_LOG_(INFO) << "SvcSessionManagerTest-end SUB_backup_sa_session_DecreaseSessionCnt_0100"; 70 } 71 72 /** 73 * @tc.number: SUB_backup_sa_session_DecreaseSessionCnt_0101 74 * @tc.name: SUB_backup_sa_session_DecreaseSessionCnt_0101 75 * @tc.desc: 测试 DecreaseSessionCnt 76 * @tc.size: MEDIUM 77 * @tc.type: FUNC 78 * @tc.level Level 1 79 * @tc.require: I6F3GV 80 */ 81 HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_DecreaseSessionCnt_0101, testing::ext::TestSize.Level1) 82 { 83 GTEST_LOG_(INFO) << "SvcSessionManagerTest-begin SUB_backup_sa_session_DecreaseSessionCnt_0101"; 84 try { 85 sessionManagerPtr_->IncreaseSessionCnt(__PRETTY_FUNCTION__); 86 sessionManagerPtr_->DecreaseSessionCnt(__PRETTY_FUNCTION__); 87 EXPECT_TRUE(true); 88 } catch (...) { 89 EXPECT_TRUE(false); 90 GTEST_LOG_(INFO) << "SvcSessionManagerTest-an exception occurred by DecreaseSessionCnt."; 91 } 92 GTEST_LOG_(INFO) << "SvcSessionManagerTest-end SUB_backup_sa_session_DecreaseSessionCnt_0101"; 93 } 94 95 /** 96 * @tc.number: SUB_backup_sa_session_GetServiceSchedAction_0104 97 * @tc.name: SUB_backup_sa_session_GetServiceSchedAction_0104 98 * @tc.desc: 测试 GetServiceSchedAction 获取状态 99 * @tc.size: MEDIUM 100 * @tc.type: FUNC 101 * @tc.level Level 1 102 * @tc.require: I6F3GV 103 */ 104 HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_GetServiceSchedAction_0104, testing::ext::TestSize.Level1) 105 { 106 GTEST_LOG_(INFO) << "SvcSessionManagerTest-begin SUB_backup_sa_session_GetServiceSchedAction_0104"; 107 try { 108 try { 109 EXPECT_TRUE(sessionManagerPtr_ != nullptr); 110 sessionManagerPtr_->impl_.clientToken = 0; 111 sessionManagerPtr_->GetServiceSchedAction(BUNDLE_NAME); 112 EXPECT_TRUE(true); 113 } catch (BError &err) { 114 EXPECT_EQ(err.GetRawCode(), BError::Codes::SA_INVAL_ARG); 115 } 116 } catch (...) { 117 EXPECT_TRUE(false); 118 GTEST_LOG_(INFO) << "SvcSessionManagerTest-an exception occurred by GetServiceSchedAction."; 119 } 120 GTEST_LOG_(INFO) << "SvcSessionManagerTest-end SUB_backup_sa_session_GetServiceSchedAction_0104"; 121 } 122 123 /** 124 * @tc.number: SUB_backup_sa_session_GetServiceSchedAction_0105 125 * @tc.name: SUB_backup_sa_session_GetServiceSchedAction_0105 126 * @tc.desc: 测试 GetServiceSchedAction 获取状态 127 * @tc.size: MEDIUM 128 * @tc.type: FUNC 129 * @tc.level Level 1 130 * @tc.require: I6F3GV 131 */ 132 HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_GetServiceSchedAction_0105, testing::ext::TestSize.Level1) 133 { 134 GTEST_LOG_(INFO) << "SvcSessionManagerTest-begin SUB_backup_sa_session_GetServiceSchedAction_0105"; 135 try { 136 try { 137 EXPECT_TRUE(sessionManagerPtr_ != nullptr); 138 sessionManagerPtr_->impl_.clientToken = 0; 139 sessionManagerPtr_->SetServiceSchedAction(BUNDLE_NAME, BConstants::ServiceSchedAction::RUNNING); 140 EXPECT_TRUE(true); 141 } catch (BError &err) { 142 EXPECT_EQ(err.GetRawCode(), BError::Codes::SA_INVAL_ARG); 143 } 144 } catch (...) { 145 EXPECT_TRUE(false); 146 GTEST_LOG_(INFO) << "SvcSessionManagerTest-an exception occurred by GetServiceSchedAction."; 147 } 148 GTEST_LOG_(INFO) << "SvcSessionManagerTest-end SUB_backup_sa_session_GetServiceSchedAction_0105"; 149 }