2 * Copyright (C) 2016-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "addons/AddonBuilder.h"
10 #include "addons/LanguageResource.h"
11 #include "addons/addoninfo/AddonInfo.h"
12 #include "addons/addoninfo/AddonInfoBuilder.h"
13 #include "addons/addoninfo/AddonType.h"
15 #include <gtest/gtest.h>
17 using namespace ADDON
;
20 class TestAddonBuilder
: public ::testing::Test
23 TestAddonBuilder() = default;
26 TEST_F(TestAddonBuilder
, ShouldFailWhenEmpty
)
28 EXPECT_EQ(nullptr, CAddonBuilder::Generate(nullptr, AddonType::UNKNOWN
));
31 TEST_F(TestAddonBuilder
, ShouldBuildDependencyAddons
)
33 std::vector
<DependencyInfo
> deps
;
34 deps
.emplace_back("a", CAddonVersion("1.0.0"), CAddonVersion("1.0.10"), false);
36 CAddonInfoBuilderFromDB builder
;
38 builder
.SetDependencies(deps
);
39 CAddonType
addonType(AddonType::UNKNOWN
);
40 builder
.SetExtensions(addonType
);
41 AddonPtr addon
= CAddonBuilder::Generate(builder
.get(), AddonType::UNKNOWN
);
42 EXPECT_EQ(deps
, addon
->GetDependencies());
45 TEST_F(TestAddonBuilder
, ShouldReturnDerivedType
)
47 CAddonInfoBuilderFromDB builder
;
49 CAddonType
addonType(AddonType::RESOURCE_LANGUAGE
);
50 builder
.SetExtensions(addonType
);
51 auto addon
= std::dynamic_pointer_cast
<CLanguageResource
>(
52 CAddonBuilder::Generate(builder
.get(), AddonType::UNKNOWN
));
53 EXPECT_NE(nullptr, addon
);