diff options
| author | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
| commit | be933ef2241d79558f91796cc5b3a161f72ebf9c (patch) | |
| tree | fe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/test/TestLabelFormatter.cpp | |
| parent | 5f8335c1e49ce108ef3481863833c98efa00411b (diff) | |
| download | kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2 kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip | |
sync with upstream
Diffstat (limited to 'xbmc/utils/test/TestLabelFormatter.cpp')
| -rw-r--r-- | xbmc/utils/test/TestLabelFormatter.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/xbmc/utils/test/TestLabelFormatter.cpp b/xbmc/utils/test/TestLabelFormatter.cpp new file mode 100644 index 0000000..0989fec --- /dev/null +++ b/xbmc/utils/test/TestLabelFormatter.cpp | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include "FileItem.h" | ||
| 10 | #include "ServiceBroker.h" | ||
| 11 | #include "filesystem/File.h" | ||
| 12 | #include "settings/Settings.h" | ||
| 13 | #include "settings/SettingsComponent.h" | ||
| 14 | #include "test/TestUtils.h" | ||
| 15 | #include "utils/LabelFormatter.h" | ||
| 16 | |||
| 17 | #include <gtest/gtest.h> | ||
| 18 | |||
| 19 | /* Set default settings used by CLabelFormatter. */ | ||
| 20 | class TestLabelFormatter : public testing::Test | ||
| 21 | { | ||
| 22 | protected: | ||
| 23 | TestLabelFormatter() = default; | ||
| 24 | |||
| 25 | ~TestLabelFormatter() override | ||
| 26 | { | ||
| 27 | CServiceBroker::GetSettingsComponent()->GetSettings()->Unload(); | ||
| 28 | } | ||
| 29 | }; | ||
| 30 | |||
| 31 | TEST_F(TestLabelFormatter, FormatLabel) | ||
| 32 | { | ||
| 33 | XFILE::CFile *tmpfile; | ||
| 34 | std::string tmpfilepath, destpath; | ||
| 35 | LABEL_MASKS labelMasks; | ||
| 36 | CLabelFormatter formatter("", labelMasks.m_strLabel2File); | ||
| 37 | |||
| 38 | ASSERT_NE(nullptr, (tmpfile = XBMC_CREATETEMPFILE(""))); | ||
| 39 | tmpfilepath = XBMC_TEMPFILEPATH(tmpfile); | ||
| 40 | |||
| 41 | CFileItemPtr item(new CFileItem(tmpfilepath)); | ||
| 42 | item->SetPath(tmpfilepath); | ||
| 43 | item->m_bIsFolder = false; | ||
| 44 | item->Select(true); | ||
| 45 | |||
| 46 | formatter.FormatLabel(item.get()); | ||
| 47 | |||
| 48 | EXPECT_TRUE(XBMC_DELETETEMPFILE(tmpfile)); | ||
| 49 | } | ||
| 50 | |||
| 51 | TEST_F(TestLabelFormatter, FormatLabel2) | ||
| 52 | { | ||
| 53 | XFILE::CFile *tmpfile; | ||
| 54 | std::string tmpfilepath, destpath; | ||
| 55 | LABEL_MASKS labelMasks; | ||
| 56 | CLabelFormatter formatter("", labelMasks.m_strLabel2File); | ||
| 57 | |||
| 58 | ASSERT_NE(nullptr, (tmpfile = XBMC_CREATETEMPFILE(""))); | ||
| 59 | tmpfilepath = XBMC_TEMPFILEPATH(tmpfile); | ||
| 60 | |||
| 61 | CFileItemPtr item(new CFileItem(tmpfilepath)); | ||
| 62 | item->SetPath(tmpfilepath); | ||
| 63 | item->m_bIsFolder = false; | ||
| 64 | item->Select(true); | ||
| 65 | |||
| 66 | formatter.FormatLabel2(item.get()); | ||
| 67 | |||
| 68 | EXPECT_TRUE(XBMC_DELETETEMPFILE(tmpfile)); | ||
| 69 | } | ||
