|
| 1 | +/* This file is part of YUView - The YUV player with advanced analytics toolset |
| 2 | + * <https://github.com/IENT/YUView> |
| 3 | + * Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY |
| 4 | + * |
| 5 | + * This program is free software; you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU General Public License as published by |
| 7 | + * the Free Software Foundation; either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * In addition, as a special exception, the copyright holders give |
| 11 | + * permission to link the code of portions of this program with the |
| 12 | + * OpenSSL library under certain conditions as described in each |
| 13 | + * individual source file, and distribute linked combinations including |
| 14 | + * the two. |
| 15 | + * |
| 16 | + * You must obey the GNU General Public License in all respects for all |
| 17 | + * of the code used other than OpenSSL. If you modify file(s) with this |
| 18 | + * exception, you may extend this exception to your version of the |
| 19 | + * file(s), but you are not obligated to do so. If you do not wish to do |
| 20 | + * so, delete this exception statement from your version. If you delete |
| 21 | + * this exception statement from all source files in the program, then |
| 22 | + * also delete it here. |
| 23 | + * |
| 24 | + * This program is distributed in the hope that it will be useful, |
| 25 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 26 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 27 | + * GNU General Public License for more details. |
| 28 | + * |
| 29 | + * You should have received a copy of the GNU General Public License |
| 30 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 31 | + */ |
| 32 | + |
| 33 | +#include <common/Testing.h> |
| 34 | + |
| 35 | +#include <statistics/StatisticsTypeBuilder.h> |
| 36 | + |
| 37 | +namespace stats::test |
| 38 | +{ |
| 39 | + |
| 40 | +TEST(StatisticsTypeBuilderTest, DefaultValues) |
| 41 | +{ |
| 42 | + const auto statisticsType = StatisticsTypeBuilder().build(); |
| 43 | + |
| 44 | + EXPECT_EQ(statisticsType.typeID, 0); |
| 45 | + EXPECT_TRUE(statisticsType.typeName.empty()); |
| 46 | + EXPECT_TRUE(statisticsType.description.empty()); |
| 47 | + EXPECT_FALSE(statisticsType.render); |
| 48 | + EXPECT_EQ(statisticsType.alphaFactor, 50); |
| 49 | + EXPECT_FALSE(statisticsType.valueDataOptions); |
| 50 | + EXPECT_FALSE(statisticsType.vectorDataOptions); |
| 51 | + EXPECT_FALSE(statisticsType.gridOptions.render); |
| 52 | + EXPECT_EQ(statisticsType.gridOptions.style, LineDrawStyle()); |
| 53 | + EXPECT_FALSE(statisticsType.gridOptions.scaleToZoom); |
| 54 | +} |
| 55 | + |
| 56 | +TEST(StatisticsTypeBuilderTest, SetTypeNameDescriptionAndRenderValues) |
| 57 | +{ |
| 58 | + const auto statisticsType = stats::StatisticsTypeBuilder() |
| 59 | + .withTypeID(1) |
| 60 | + .withTypeName("TestType") |
| 61 | + .withDescription("TestDescription") |
| 62 | + .withRender(true) |
| 63 | + .withAlphaFactor(75) |
| 64 | + .build(); |
| 65 | + |
| 66 | + EXPECT_EQ(statisticsType.typeID, 1); |
| 67 | + EXPECT_EQ(statisticsType.typeName, "TestType"); |
| 68 | + EXPECT_EQ(statisticsType.description, "TestDescription"); |
| 69 | + EXPECT_TRUE(statisticsType.render); |
| 70 | + EXPECT_EQ(statisticsType.alphaFactor, 75); |
| 71 | +} |
| 72 | + |
| 73 | +TEST(StatisticsTypeBuilderTest, SetValueDatDefaultValues) |
| 74 | +{ |
| 75 | + const auto statisticsType = stats::StatisticsTypeBuilder().withValueDataOptions({}).build(); |
| 76 | + |
| 77 | + EXPECT_TRUE(statisticsType.valueDataOptions); |
| 78 | + EXPECT_EQ(statisticsType.valueDataOptions->render, true); |
| 79 | + EXPECT_EQ(statisticsType.valueDataOptions->scaleToBlockSize, false); |
| 80 | + EXPECT_EQ(statisticsType.valueDataOptions->colorMapper, color::ColorMapper()); |
| 81 | +} |
| 82 | + |
| 83 | +TEST(StatisticsTypeBuilderTest, SetValueDataCustomValues) |
| 84 | +{ |
| 85 | + const auto colorMapper = color::ColorMapper({0, 255}, color::PredefinedType::Jet); |
| 86 | + |
| 87 | + const auto statisticsType = |
| 88 | + stats::StatisticsTypeBuilder() |
| 89 | + .withValueDataOptions( |
| 90 | + {.render = false, .scaleToBlockSize = true, .colorMapper = colorMapper}) |
| 91 | + .build(); |
| 92 | + |
| 93 | + EXPECT_TRUE(statisticsType.valueDataOptions); |
| 94 | + EXPECT_EQ(statisticsType.valueDataOptions->render, false); |
| 95 | + EXPECT_EQ(statisticsType.valueDataOptions->scaleToBlockSize, true); |
| 96 | + EXPECT_EQ(statisticsType.valueDataOptions->colorMapper, colorMapper); |
| 97 | +} |
| 98 | + |
| 99 | +TEST(StatisticsTypeBuilderTest, SetVectorDataDefaultValues) |
| 100 | +{ |
| 101 | + const auto statisticsType = StatisticsTypeBuilder().withVectorDataOptions({}).build(); |
| 102 | + |
| 103 | + EXPECT_TRUE(statisticsType.vectorDataOptions); |
| 104 | + EXPECT_TRUE(statisticsType.vectorDataOptions->render); |
| 105 | + EXPECT_TRUE(statisticsType.vectorDataOptions->renderDataValues); |
| 106 | + EXPECT_FALSE(statisticsType.vectorDataOptions->scaleToZoom); |
| 107 | + EXPECT_EQ(statisticsType.vectorDataOptions->style, LineDrawStyle()); |
| 108 | + EXPECT_EQ(statisticsType.vectorDataOptions->scale, 0); |
| 109 | + EXPECT_FALSE(statisticsType.vectorDataOptions->mapToColor); |
| 110 | + EXPECT_EQ(statisticsType.vectorDataOptions->arrowHead, StatisticsType::ArrowHead::arrow); |
| 111 | +} |
| 112 | + |
| 113 | +TEST(StatisticsTypeBuilderTest, SetVectorDataCustomValues) |
| 114 | +{ |
| 115 | + const auto lineDrawStyle = LineDrawStyle(Color(255, 0, 0), 2, Pattern::DashDot); |
| 116 | + |
| 117 | + const auto statisticsType = StatisticsTypeBuilder() |
| 118 | + .withVectorDataOptions({ |
| 119 | + .render = false, |
| 120 | + .renderDataValues = false, |
| 121 | + .scaleToZoom = true, |
| 122 | + .style = lineDrawStyle, |
| 123 | + .scale = 3, |
| 124 | + .mapToColor = true, |
| 125 | + .arrowHead = StatisticsType::ArrowHead::circle, |
| 126 | + }) |
| 127 | + .build(); |
| 128 | + |
| 129 | + EXPECT_TRUE(statisticsType.vectorDataOptions); |
| 130 | + EXPECT_FALSE(statisticsType.vectorDataOptions->render); |
| 131 | + EXPECT_FALSE(statisticsType.vectorDataOptions->renderDataValues); |
| 132 | + EXPECT_TRUE(statisticsType.vectorDataOptions->scaleToZoom); |
| 133 | + EXPECT_EQ(statisticsType.vectorDataOptions->style, lineDrawStyle); |
| 134 | + EXPECT_EQ(statisticsType.vectorDataOptions->scale, 3); |
| 135 | + EXPECT_TRUE(statisticsType.vectorDataOptions->mapToColor); |
| 136 | + EXPECT_EQ(statisticsType.vectorDataOptions->arrowHead, StatisticsType::ArrowHead::circle); |
| 137 | +} |
| 138 | + |
| 139 | +TEST(StatisticsTypeBuilderTest, SetGridOptionsDefaultValues) |
| 140 | +{ |
| 141 | + const auto statisticsType = StatisticsTypeBuilder().withGridOptions({}).build(); |
| 142 | + |
| 143 | + EXPECT_FALSE(statisticsType.gridOptions.render); |
| 144 | + EXPECT_EQ(statisticsType.gridOptions.style, LineDrawStyle()); |
| 145 | + EXPECT_FALSE(statisticsType.gridOptions.scaleToZoom); |
| 146 | +} |
| 147 | + |
| 148 | +TEST(StatisticsTypeBuilderTest, SetGridOptionsCustomValues) |
| 149 | +{ |
| 150 | + const auto lineDrawStyle = LineDrawStyle(Color(123, 44, 99), 5, Pattern::DashDot); |
| 151 | + |
| 152 | + const auto statisticsType = |
| 153 | + StatisticsTypeBuilder() |
| 154 | + .withGridOptions({.render = true, .style = lineDrawStyle, .scaleToZoom = true}) |
| 155 | + .build(); |
| 156 | + |
| 157 | + EXPECT_TRUE(statisticsType.gridOptions.render); |
| 158 | + EXPECT_EQ(statisticsType.gridOptions.style, lineDrawStyle); |
| 159 | + EXPECT_TRUE(statisticsType.gridOptions.scaleToZoom); |
| 160 | +} |
| 161 | + |
| 162 | +} // namespace stats::test |
0 commit comments