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

namespace smo {
namespace stim_buff {
namespace lcamera_buff {
namespace {

TEST(YuvCaptureLayoutTest, PackedYuyvUsesMmapDeinterleavedBacking)
{
	lcamera_dev::LcameraDevConfiguredCameraMode mode;
	mode.pixelFormatName = "YUYV";
	mode.isFullyPlanar = false;
	mode.planeCount = 1;

	EXPECT_EQ(
		classifyYuvCaptureLayoutPath(mode),
		YuvCaptureLayoutPath::PackedDeinterleave);
	EXPECT_EQ(
		getChannelBackingPlanForLayoutPath(
			YuvCaptureLayoutPath::PackedDeinterleave),
		YuvChannelBackingPlan::MmapDeinterleaved);
}

TEST(YuvCaptureLayoutTest, FullPlanarUsesDirectBacking)
{
	lcamera_dev::LcameraDevConfiguredCameraMode mode;
	mode.pixelFormatName = "YU12";
	mode.isFullyPlanar = true;
	mode.planeCount = 3;

	EXPECT_EQ(
		classifyYuvCaptureLayoutPath(mode),
		YuvCaptureLayoutPath::FullPlanarDirect);
	EXPECT_EQ(
		getChannelBackingPlanForLayoutPath(
			YuvCaptureLayoutPath::FullPlanarDirect),
		YuvChannelBackingPlan::LCameraDirect);
}

} // namespace
} // namespace lcamera_buff
} // namespace stim_buff
} // namespace smo
