[WASAPI] fix stream types and frequencies enumeration
[xbmc.git] / xbmc / video / test / TestVideoUtils.cpp
blob579fff0180f50e5f2c25220881c744a97de5baf0
1 /*
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.
7 */
9 #include "FileItem.h"
10 #include "Util.h"
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"
17 #include <array>
18 #include <fstream>
20 #include <gtest/gtest.h>
22 using namespace KODI;
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)
33 std::error_code ec;
34 const std::string temp_path = fs::create_temp_directory(ec);
35 EXPECT_FALSE(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);
44 else
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},
53 #ifdef HAVE_LIBBLURAY
54 OptDef{"index.bdmv", true}, OptDef{"INDEX.BDM", true},
55 OptDef{"BDMV/index.bdmv", true}, OptDef{"BDMV/INDEX.BDM", true},
56 #endif
59 INSTANTIATE_TEST_SUITE_P(TestVideoUtils, OpticalMediaPathTest, testing::ValuesIn(mediapath_tests));