@@ -225,6 +225,28 @@ TEST_F(ProfileTest, UninitProfileList_Success) {
225225 EXPECT_EQ (uninitProfileList (), T2ERROR_SUCCESS);
226226}
227227
228+ TEST_F (ProfileTest, ReportProfiles_uninit) {
229+ EXPECT_CALL (*g_vectorMock, Vector_Create (_))
230+ .Times (::testing::AtMost (3 ))
231+ .WillRepeatedly (Return (T2ERROR_SUCCESS));
232+ EXPECT_CALL (*g_vectorMock, Vector_PushBack (_, _))
233+ .Times (::testing::AtMost (1 ))
234+ .WillRepeatedly (Return (T2ERROR_SUCCESS));
235+ EXPECT_CALL (*g_vectorMock, Vector_Size (_))
236+ .Times (::testing::AtMost (3 ))
237+ .WillRepeatedly (Return (0 ));
238+ EXPECT_CALL (*g_vectorMock, Vector_At (_, _))
239+ .Times (::testing::AtMost (2 ))
240+ .WillRepeatedly (Return (nullptr ));
241+ EXPECT_CALL (*g_schedulerMock, uninitScheduler ())
242+ .Times (::testing::AtMost (1 ));
243+ EXPECT_CALL (*g_schedulerMock, unregisterProfileFromScheduler (_))
244+ .Times (::testing::AtMost (5 ))
245+ .WillRepeatedly (Return (T2ERROR_SUCCESS));
246+
247+ EXPECT_EQ (ReportProfiles_uninit (), T2ERROR_FAILURE);
248+ }
249+
228250// Test getProfileCount
229251TEST_F (ProfileTest, GetProfileCount_NotInitialized) {
230252 EXPECT_CALL (*g_vectorMock, Vector_Size (_))
@@ -759,6 +781,14 @@ TEST_F(ProfileTest, ReportProfiles_deleteProfileXConf) {
759781}
760782#endif
761783
784+ TEST_F (ProfileTest, ReportProfiles_deleteProfileXConf) {
785+ ProfileXConf profile;
786+ EXPECT_CALL (*g_vectorMock, Vector_Size (_))
787+ .Times (::testing::AtMost (1 ))
788+ .WillRepeatedly (Return (0 )); // Return 1 to indicate only one profile (no duplicates)
789+ EXPECT_EQ (ReportProfiles_deleteProfileXConf (&profile), T2ERROR_SUCCESS);
790+ }
791+
762792TEST_F (ProfileTest, ReportProfiles_deleteProfile) {
763793 EXPECT_CALL (*g_vectorMock, Vector_Size (_))
764794 .Times (::testing::AtMost (2 ))
@@ -810,7 +840,16 @@ TEST_F(ProfileTest, RemovePreRPfromDisk) {
810840 EXPECT_EQ (RemovePreRPfromDisk (" /tmp" , &dummy), T2ERROR_SUCCESS);
811841}
812842
813- #if 0
843+ TEST_F (ProfileTest, RemovePreRPfromDisk_FailsIfDirNull) {
844+ hash_map_t dummy;
845+ // Mock opendir to return NULL to simulate failure
846+ EXPECT_CALL (*g_fileIOMock, opendir (_))
847+ .Times (1 )
848+ .WillOnce (Return (nullptr ));
849+ // readdir and closedir should NOT be called in this branch
850+ EXPECT_EQ (RemovePreRPfromDisk (" /tmp" , &dummy), T2ERROR_FAILURE);
851+ }
852+
814853TEST_F (ProfileTest, deleteAllReportProfiles) {
815854 EXPECT_CALL (*g_vectorMock, Vector_Size (_))
816855 .Times (::testing::AtMost (1 ))
@@ -819,58 +858,7 @@ TEST_F(ProfileTest, deleteAllReportProfiles) {
819858 .WillRepeatedly (Return (T2ERROR_SUCCESS));
820859 EXPECT_EQ (deleteAllReportProfiles (), T2ERROR_SUCCESS);
821860}
822- #endif
823861
824- #if 0
825- TEST_F(ProfileTest, isMtlsEnabled) {
826- char status[8] = "true";
827- EXPECT_CALL(*g_rbusMock, rbus_get(_,_,_))
828- .Times(::testing::AtMost(2))
829- .WillRepeatedly(Return(RBUS_ERROR_SUCCESS));
830- EXPECT_CALL(*g_rbusMock, rbusValue_GetType(_))
831- .Times(::testing::AtMost(2))
832- .WillRepeatedly(Return(RBUS_BOOLEAN));
833- EXPECT_CALL(*g_rbusMock, rbusValue_GetBoolean(_))
834- .Times(::testing::AtMost(2))
835- .WillRepeatedly(Return(RBUS_ERROR_SUCCESS));
836- EXPECT_CALL(*g_rbusMock, rbusValue_Release(_))
837- .Times(::testing::AtMost(2))
838- .WillRepeatedly(Return());
839- EXPECT_CALL(*g_rbusMock, rbusValue_ToString(_,_,_))
840- .Times(::testing::AtMost(1))
841- .WillRepeatedly(Return(status));
842- EXPECT_TRUE(isMtlsEnabled());
843- }
844- #endif
845-
846- #if 0
847- TEST_F(ProfileTest, ReportProfiles_uninit) {
848- EXPECT_CALL(*g_vectorMock, Vector_Create(_))
849- .Times(::testing::AtMost(3)) // 1 for local test configlist, 1 for global profileList, 1 for configList in loadReportProfilesFromDisk
850- .WillRepeatedly(Return(T2ERROR_SUCCESS));
851- EXPECT_CALL(*g_vectorMock, Vector_PushBack(_, _))
852- .Times(::testing::AtMost(1))
853- .WillRepeatedly(Return(T2ERROR_SUCCESS));
854- EXPECT_CALL(*g_vectorMock, Vector_Size(_))
855- .Times(::testing::AtMost(3)) // May be called multiple times - in deleteAllProfiles, etc.
856- .WillRepeatedly(Return(0)); // Return 0 to indicate no profiles (avoid unregister calls)
857- EXPECT_CALL(*g_vectorMock, Vector_At(_, _))
858- .Times(::testing::AtMost(2)) // May be called if profiles exist
859- .WillRepeatedly(Return(nullptr));
860-
861- // Scheduler mock expectations - uninitScheduler is definitely called
862- EXPECT_CALL(*g_schedulerMock, uninitScheduler())
863- .Times(::testing::AtMost(1));
864-
865- // unregisterProfileFromScheduler may be called for each profile during deleteAllProfiles
866- // Using AtMost to handle cases where profiles exist
867- EXPECT_CALL(*g_schedulerMock, unregisterProfileFromScheduler(_))
868- .Times(::testing::AtMost(5)) // Allow up to 5 calls in case profiles exist
869- .WillRepeatedly(Return(T2ERROR_SUCCESS));
870-
871- EXPECT_EQ(ReportProfiles_uninit(), T2ERROR_SUCCESS);
872- }
873- #endif
874862#endif
875863
876864#if 1
@@ -1097,6 +1085,7 @@ TEST_F(ProfileTest, DeleteProfile) {
10971085 profile->isUpdated = false ;
10981086
10991087 ProfileXConf_set (profile);
1088+ EXPECT_EQ (ReportProfiles_setProfileXConf (profile),T2ERROR_FAILURE);
11001089 EXPECT_EQ (ProfileXConf_delete (profile), T2ERROR_FAILURE);
11011090 ProfileXConf_uninit ();
11021091}
0 commit comments