Skip to content

Commit

Permalink
Address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelirh committed Sep 10, 2024
1 parent 8084be8 commit 5eda705
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 4 additions & 10 deletions panther_lights/test/test_apa102.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,14 @@ TestAPA102::TestAPA102()
apa102_ = std::make_unique<APA102Wrapper>(spi_device_, kMockDeviceName);
}

TEST_F(TestAPA102, TestInitialization) { EXPECT_TRUE(spi_device_ != nullptr); }

TEST(TestInitialization, InvalidDevices)
{
auto spi_device = std::make_shared<MockSPIDevice::NiceMock>();

// Return -1 to simulate failed device opening
ON_CALL(*spi_device, Open(kMockDeviceName)).WillByDefault(testing::Return(-1));

EXPECT_THROW(std::make_unique<APA102Wrapper>(spi_device, kMockDeviceName);
, std::ios_base::failure);
EXPECT_THROW(APA102Wrapper(spi_device, kMockDeviceName), std::ios_base::failure);
}

TEST(TestInitialization, SetModeFailure)
Expand All @@ -86,8 +83,7 @@ TEST(TestInitialization, SetModeFailure)
.WillByDefault(testing::Return(-1));
EXPECT_CALL(*spi_device, Close(testing::_)).Times(1);

EXPECT_THROW(std::make_unique<APA102Wrapper>(spi_device, kMockDeviceName);
, std::ios_base::failure);
EXPECT_THROW(APA102Wrapper(spi_device, kMockDeviceName), std::ios_base::failure);
}

TEST(TestInitialization, SetBitsFailure)
Expand All @@ -99,8 +95,7 @@ TEST(TestInitialization, SetBitsFailure)
.WillByDefault(testing::Return(-1));
EXPECT_CALL(*spi_device, Close(testing::_)).Times(1);

EXPECT_THROW(std::make_unique<APA102Wrapper>(spi_device, kMockDeviceName);
, std::ios_base::failure);
EXPECT_THROW(APA102Wrapper(spi_device, kMockDeviceName), std::ios_base::failure);
}

TEST(TestInitialization, SetSpeedFailure)
Expand All @@ -112,8 +107,7 @@ TEST(TestInitialization, SetSpeedFailure)
.WillByDefault(testing::Return(-1));
EXPECT_CALL(*spi_device, Close(testing::_)).Times(1);

EXPECT_THROW(std::make_unique<APA102Wrapper>(spi_device, kMockDeviceName);
, std::ios_base::failure);
EXPECT_THROW(APA102Wrapper(spi_device, kMockDeviceName), std::ios_base::failure);
}

TEST_F(TestAPA102, SetGlobalBrightnessRatioNegative)
Expand Down
2 changes: 2 additions & 0 deletions panther_lights/test/test_lights_driver_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@ TEST_F(TestLightsDriverNode, FrameCBSuccess)
lights_driver_node_->ToggleLEDControlCB(std::move(future));

EXPECT_CALL(*channel_1_, SetPanel(testing::_)).Times(1);
EXPECT_CALL(*channel_2_, SetPanel(testing::_)).Times(1);

lights_driver_node_->FrameCB(msg, channel_1_, msg->header.stamp, "channel_1");
lights_driver_node_->FrameCB(msg, channel_2_, msg->header.stamp, "channel_2");
}

TEST_F(TestLightsDriverNode, FrameCBTimeout)
Expand Down

0 comments on commit 5eda705

Please sign in to comment.