diff options
Diffstat (limited to 'xbmc/network/test/TestNetworkFileItemClassify.cpp')
-rw-r--r-- | xbmc/network/test/TestNetworkFileItemClassify.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/xbmc/network/test/TestNetworkFileItemClassify.cpp b/xbmc/network/test/TestNetworkFileItemClassify.cpp index 335b8340fc..0d195c887d 100644 --- a/xbmc/network/test/TestNetworkFileItemClassify.cpp +++ b/xbmc/network/test/TestNetworkFileItemClassify.cpp @@ -17,6 +17,21 @@ using namespace KODI; +namespace +{ + +struct SimpleDefinition +{ + SimpleDefinition(const std::string& path, bool folder, bool res) : item(path, folder), result(res) + { + } + + CFileItem item; + bool result; +}; + +} // namespace + struct InternetStreamDefinition { InternetStreamDefinition(const std::string& path, bool folder, bool strict, bool res) @@ -175,3 +190,67 @@ TEST(TestNetworkWorkFileItemClassify, InternetStreamStacks) EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false), true)); EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true), true)); } + +class StreamedFilesystemTest : public testing::WithParamInterface<SimpleDefinition>, + public testing::Test +{ +}; + +TEST_P(StreamedFilesystemTest, IsStreamedFilesystem) +{ + EXPECT_EQ(NETWORK::IsStreamedFilesystem(GetParam().item), GetParam().result); +} + +const auto streamedfs_tests = std::array{ + SimpleDefinition{"/home/user/test.disc", false, false}, + SimpleDefinition{"/home/user/test.disc", true, false}, + SimpleDefinition{"http://some.where/foo", false, true}, + SimpleDefinition{"http://some.where/foo", true, true}, + SimpleDefinition{"https://some.where/foo", false, true}, + SimpleDefinition{"https://some.where/foo", true, true}, + SimpleDefinition{"ftp://some.where/foo", false, true}, + SimpleDefinition{"ftp://some.where/foo", true, true}, + SimpleDefinition{"sftp://some.where/foo", false, true}, + SimpleDefinition{"sftp://some.where/foo", true, true}, + SimpleDefinition{"ssh://some.where/foo", false, true}, + SimpleDefinition{"ssh://some.where/foo", true, true}, + SimpleDefinition{"ssh://some.where/foo", true, true}, +}; + +INSTANTIATE_TEST_SUITE_P(TestNetworkFileItemClassify, + StreamedFilesystemTest, + testing::ValuesIn(streamedfs_tests)); + +TEST(TestNetworkWorkFileItemClassify, StreamedFilesystemStacks) +{ + std::string stackPath; + EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( + {"/home/foo/somthing.avi", "/home/bar/else.mkv"}, stackPath)); + EXPECT_FALSE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false))); + EXPECT_FALSE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true))); + + EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( + {"https://home/foo/somthing.avi", "https://home/bar/else.mkv"}, stackPath)); + EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false))); + EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true))); + + EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( + {"shout://home/foo/somthing.avi", "shout://home/bar/else.mkv"}, stackPath)); + EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false))); + EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true))); + + EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( + {"ftp://home/foo/somthing.avi", "ftp://home/bar/else.mkv"}, stackPath)); + EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false))); + EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true))); + + EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( + {"ftp://home/foo/somthing.avi", "/home/bar/else.mkv"}, stackPath)); + EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false))); + EXPECT_TRUE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true))); + + EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( + {"/home/foo/somthing.avi", "ftp://home/bar/else.mkv"}, stackPath)); + EXPECT_FALSE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, false))); + EXPECT_FALSE(NETWORK::IsStreamedFilesystem(CFileItem(stackPath, true))); +} |