Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonZimmer committed Feb 4, 2025
1 parent 1f64bfc commit d122481
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 30 deletions.
5 changes: 5 additions & 0 deletions seele/inc/SummonToggle.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ namespace hidonash
setLookAndFeel(&lookAndFeel_);
}

~SummonToggle()
{
setLookAndFeel(nullptr);
}

void mouseEnter(const juce::MouseEvent&) override
{
setMouseCursor(juce::MouseCursor::StandardCursorType::PointingHandCursor);
Expand Down
11 changes: 11 additions & 0 deletions seele/inc/TextBox.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#pragma once


#include <exception>
#include <juce_gui_basics/juce_gui_basics.h>

#include <GraphicAssets.h>
#include <mutex>

#include "Font.h"
#include "UiConstants.h"
Expand Down Expand Up @@ -47,6 +49,15 @@ namespace hidonash
addAndMakeVisible(label_);
}

~TextBox()
{
try
{
slider_.removeListener(this);
} catch (...)
{}
}

void resized() override
{
label_.setBounds(getLocalBounds());
Expand Down
56 changes: 26 additions & 30 deletions seele/seeleCore/tests/src/EngineTestCase.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <random>

#include <gmock/gmock.h>
#include <gtest/gtest.h>

Expand All @@ -15,45 +17,39 @@ namespace hidonash
{
using namespace testing;

class UnitTest_Engine : public testing::Test
class UnitTest_Engine : public ::testing::Test
{
public:
void SetUp() override
{
factoryMock_ = std::make_unique<NiceMock<FactoryMock>>();
factoryMockPtr_ = factoryMock_.get();
memberParameterSetMock_ = std::make_unique<NiceMock<MemberParameterSetMock>>();
audioBufferMock_ = std::make_unique<NiceMock<core::AudioBufferMock>>();
audioBufferMockPtr_ = audioBufferMock_.get();

ON_CALL(*factoryMockPtr_, createAudioBuffer(_, _))
.WillByDefault(Return(ByMove(std::move(audioBufferMock_))));
ON_CALL(*factoryMockPtr_, createPitchShifterManager(_, _, _))
.WillByDefault(Return(ByMove(std::move(pitchShifterManagerMock_))));
ON_CALL(*factoryMockPtr_, createDelayProcessor(_, _, _))
.WillByDefault(Return(ByMove(std::move(delayProcessorMock_))));
ON_CALL(*factoryMockPtr_, createGainProcessor(_, _))
.WillByDefault(Return(ByMove(std::move(gainProcessorMock_))));
inputBuffer_ = std::make_unique<core::AudioBuffer>(2, 64);

for (auto ch = 0; ch < 2; ++ch)
for (auto sa = 0; sa < 64; ++sa)
inputBuffer_->setSample(ch, sa, ((float) std::rand() / (float) RAND_MAX) - 0.5f);
}

void TearDown() override
{
factoryMock_ = nullptr;
memberParameterSetMock_ = nullptr;
audioBufferMock_ = nullptr;
inputBuffer_->fill(0.f);
}

protected:
std::unique_ptr<FactoryMock> factoryMock_;
FactoryMock* factoryMockPtr_;
std::unique_ptr<MemberParameterSetMock> memberParameterSetMock_;
std::unique_ptr<core::AudioBufferMock> audioBufferMock_;
core::AudioBufferMock* audioBufferMockPtr_;
std::unique_ptr<PitchShifterManagerMock> pitchShifterManagerMock_;
PitchShifterManagerMock* pitchShifterManagerMockPtr_;
std::unique_ptr<DelayProcessorMock> delayProcessorMock_;
DelayProcessorMock* delayProcessorMockPtr_;
std::unique_ptr<GainProcessorMock> gainProcessorMock_;
GainProcessorMock* gainProcessorMockPtr_;
std::unique_ptr<core::AudioBuffer> inputBuffer_;
};

TEST_F(UnitTest_Engine, process)
{
const auto memberParameterSetMock = MemberParameterSetMock();
ON_CALL(memberParameterSetMock, getSanctity).WillByDefault(Return(1.5f));
auto engine = Engine(memberParameterSetMock, 44100., 64, 2);

engine.process(*inputBuffer_);

EXPECT_EQ(inputBuffer_->getSample(0, 0), -0.499992162f);
EXPECT_EQ(inputBuffer_->getSample(1, 0), 0.486642122f);
EXPECT_EQ(inputBuffer_->getSample(0, 32), -0.23754701f);
EXPECT_EQ(inputBuffer_->getSample(1, 32), -0.0879192352f);
EXPECT_EQ(inputBuffer_->getSample(0, 63), -0.180967063f);
EXPECT_EQ(inputBuffer_->getSample(1, 63), -0.260089189f);
}
}

0 comments on commit d122481

Please sign in to comment.