[WASAPI] fix stream types and frequencies enumeration
[xbmc.git] / xbmc / test / TestCueDocument.cpp
blobe3ce24a0a5e6c8143a5b1f13f3163106e54e7688
1 /*
2 * Copyright (C) 2024 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 "CueDocument.h"
10 #include "FileItem.h"
11 #include "FileItemList.h"
12 #include "music/tags/MusicInfoTag.h"
14 #include <array>
15 #include <string>
17 #include <gtest/gtest.h>
19 using namespace KODI;
21 namespace
24 const std::string input =
25 R"(PERFORMER "Pink Floyd"
26 TITLE "The Dark Side Of The Moon"
27 FILE "The Dark Side Of The Moon.mp3" WAVE
28 TRACK 01 AUDIO
29 TITLE "Speak To Me / Breathe"
30 PERFORMER "Pink Floyd"
31 INDEX 00 00:00:00
32 INDEX 01 00:00:32
33 TRACK 02 AUDIO
34 TITLE "On The Run"
35 PERFORMER "Pink Floyd"
36 INDEX 00 03:58:72
37 INDEX 01 04:00:72
38 TRACK 03 AUDIO
39 TITLE "Time"
40 PERFORMER "Pink Floyd"
41 INDEX 00 07:31:70
42 INDEX 01 07:33:70)";
46 TEST(TestCueDocument, LoadTracks)
48 CCueDocument doc;
49 doc.ParseTag(input);
51 using namespace std::string_literals;
53 CFileItem item("The Dark Side Of The Moon.mp3", false);
54 auto& tag = *item.GetMusicInfoTag();
55 tag.SetAlbum("TestAlbum"s);
56 tag.SetLoaded(true);
57 tag.SetAlbumArtist("TestAlbumArtist"s);
58 tag.SetGenre("TestGenre"s);
59 tag.SetArtist({"TestArtist1"s, "TestArtist2"s});
60 tag.SetCueSheet("TestCueSheet"s);
61 tag.SetYear(2005);
62 tag.SetDuration(554);
64 CFileItemList scannedItems;
65 doc.LoadTracks(scannedItems, item);
67 ASSERT_EQ(scannedItems.Size(), 3U);
69 static const auto trackNames = std::array{
70 "Speak To Me / Breathe"s,
71 "On The Run"s,
72 "Time"s,
74 static const auto duration = std::array{241, 213, 100};
75 for (size_t i = 0; i < 3; ++i)
77 EXPECT_EQ(scannedItems[i]->GetPath(), "The Dark Side Of The Moon.mp3");
78 ASSERT_TRUE(scannedItems[i]->GetMusicInfoTag() != nullptr);
79 EXPECT_EQ(scannedItems[i]->GetMusicInfoTag()->GetArtist(), std::vector{"Pink Floyd"s});
80 EXPECT_EQ(scannedItems[i]->GetMusicInfoTag()->GetAlbumArtist(), std::vector{"Pink Floyd"s});
81 EXPECT_EQ(scannedItems[i]->GetMusicInfoTag()->GetCueSheet(), "TestCueSheet"s);
82 EXPECT_EQ(scannedItems[i]->GetMusicInfoTag()->GetGenre(), std::vector{"TestGenre"s});
83 EXPECT_EQ(scannedItems[i]->GetMusicInfoTag()->GetTitle(), trackNames[i]);
84 EXPECT_EQ(scannedItems[i]->GetMusicInfoTag()->GetTrackNumber(), i + 1);
85 EXPECT_EQ(scannedItems[i]->GetMusicInfoTag()->GetDuration(), duration[i]);