Skip to content

Commit 743dfd0

Browse files
authored
method-by-method strategy: setEnabled fix expectations to mocks
1 parent 2fba4c3 commit 743dfd0

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

Tests/L1Tests/tests/test_HdmiCecSource.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -497,30 +497,22 @@ class HdmiCecSourceInitializedEventTest : public HdmiCecSourceInitializedTest {
497497

498498
TEST_F(HdmiCecSourceInitializedTest, setEnabled_EnablesCecSuccessfully)
499499
{
500-
// Setup mocks for CEC enable operation
501-
EXPECT_CALL(*p_wrapsImplMock, persistJsonSettings(::testing::_, ::testing::_))
502-
.Times(1)
503-
.WillOnce(::testing::Return(true));
504-
505-
EXPECT_CALL(*p_libCCECImplMock, getInstance())
506-
.Times(::testing::AtLeast(1))
507-
.WillRepeatedly(::testing::Return(p_libCCECImplMock));
508-
509-
EXPECT_CALL(*p_connectionImplMock, open())
510-
.Times(1)
511-
.WillOnce(::testing::Return(true));
512-
500+
// Setup mocks for device settings initialization
513501
EXPECT_CALL(*p_managerImplMock, Initialize())
514-
.Times(1)
515-
.WillOnce(::testing::Return());
502+
.Times(1);
516503

517-
EXPECT_CALL(*p_hostImplMock, getVideoOutputPort())
504+
EXPECT_CALL(*p_hostImplMock, getVideoOutputPort(::testing::_))
518505
.Times(::testing::AtLeast(1))
519-
.WillRepeatedly(::testing::Return(p_videoOutputPortMock));
506+
.WillRepeatedly(::testing::ReturnRef(*p_videoOutputPortMock));
520507

521508
EXPECT_CALL(*p_videoOutputPortMock, getDisplay())
522509
.Times(::testing::AtLeast(1))
523-
.WillRepeatedly(::testing::Return(p_displayMock));
510+
.WillRepeatedly(::testing::ReturnRef(*p_displayMock));
511+
512+
// Setup IARM bus mock expectations
513+
EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_))
514+
.Times(::testing::AtLeast(1))
515+
.WillRepeatedly(::testing::Return(IARM_RESULT_SUCCESS));
524516

525517
// Test setEnabled with enabled=true
526518
string response;
@@ -529,7 +521,7 @@ TEST_F(HdmiCecSourceInitializedTest, setEnabled_EnablesCecSuccessfully)
529521
// Verify successful response
530522
EXPECT_EQ(response, string("{\"success\":true}"));
531523

532-
// Verify that CEC was actually enabled by checking the status
524+
// Verify that the enable state can be retrieved
533525
string getEnabledResponse;
534526
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("getEnabled"), _T("{}"), getEnabledResponse));
535527
EXPECT_THAT(getEnabledResponse, ::testing::HasSubstr("\"enabled\":true"));

0 commit comments

Comments
 (0)