2 * Copyright (C) 2005-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.
11 #include "filesystem/Directory.h"
12 #include "platform/Filesystem.h"
13 #include "utils/FileUtils.h"
14 #include "utils/URIUtils.h"
15 #include "video/VideoUtils.h"
20 #include <gtest/gtest.h>
23 namespace fs
= KODI::PLATFORM::FILESYSTEM
;
25 using OptDef
= std::pair
<std::string
, bool>;
27 class OpticalMediaPathTest
: public testing::WithParamInterface
<OptDef
>, public testing::Test
31 TEST_P(OpticalMediaPathTest
, GetOpticalMediaPath
)
34 const std::string temp_path
= fs::create_temp_directory(ec
);
36 const std::string file_path
= URIUtils::AddFileToFolder(temp_path
, GetParam().first
);
37 EXPECT_TRUE(CUtil::CreateDirectoryEx(URIUtils::GetDirectory(file_path
)));
39 std::ofstream
of(file_path
);
41 CFileItem
item(temp_path
, true);
42 if (GetParam().second
)
43 EXPECT_EQ(VIDEO::UTILS::GetOpticalMediaPath(item
), file_path
);
45 EXPECT_EQ(VIDEO::UTILS::GetOpticalMediaPath(item
), "");
47 XFILE::CDirectory::RemoveRecursive(temp_path
);
50 const auto mediapath_tests
= std::array
{
51 OptDef
{"VIDEO_TS.IFO", true}, OptDef
{"VIDEO_TS/VIDEO_TS.IFO", true},
52 OptDef
{"some.file", false},
54 OptDef
{"index.bdmv", true}, OptDef
{"INDEX.BDM", true},
55 OptDef
{"BDMV/index.bdmv", true}, OptDef
{"BDMV/INDEX.BDM", true},
59 INSTANTIATE_TEST_SUITE_P(TestVideoUtils
, OpticalMediaPathTest
, testing::ValuesIn(mediapath_tests
));