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.
9 #include "CueDocument.h"
11 #include "FileItemList.h"
12 #include "music/tags/MusicInfoTag.h"
17 #include <gtest/gtest.h>
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
29 TITLE "Speak To Me
/ Breathe
"
30 PERFORMER "Pink Floyd
"
35 PERFORMER "Pink Floyd
"
40 PERFORMER "Pink Floyd
"
46 TEST(TestCueDocument
, LoadTracks
)
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
);
57 tag
.SetAlbumArtist("TestAlbumArtist"s
);
58 tag
.SetGenre("TestGenre"s
);
59 tag
.SetArtist({"TestArtist1"s
, "TestArtist2"s
});
60 tag
.SetCueSheet("TestCueSheet"s
);
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
,
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
]);