diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-03 17:29:17 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-03 17:29:17 +0000 |
commit | bcad6af626ebaef2290e60b1278c5795b28f02ac (patch) | |
tree | a8c0c2f32bf5d38e685de76da74efb33d9a825f7 | |
parent | 1f07d5ebec20e1ad036c665e0d9c28666d98f860 (diff) | |
download | chromium_src-bcad6af626ebaef2290e60b1278c5795b28f02ac.zip chromium_src-bcad6af626ebaef2290e60b1278c5795b28f02ac.tar.gz chromium_src-bcad6af626ebaef2290e60b1278c5795b28f02ac.tar.bz2 |
Merge 220264 "Fix location of tracks detected by itunes - they s..."
> Fix location of tracks detected by itunes - they should be absolute.
>
> BUG=280329
>
> Review URL: https://chromiumcodereview.appspot.com/23437016
TBR=vandebo@chromium.org
Review URL: https://codereview.chromium.org/23496032
git-svn-id: svn://svn.chromium.org/chrome/branches/1599/src@220968 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 26 insertions, 4 deletions
diff --git a/chrome/browser/media_galleries/fileapi/itunes_data_provider_browsertest.cc b/chrome/browser/media_galleries/fileapi/itunes_data_provider_browsertest.cc index 2f1742a..8d1982e 100644 --- a/chrome/browser/media_galleries/fileapi/itunes_data_provider_browsertest.cc +++ b/chrome/browser/media_galleries/fileapi/itunes_data_provider_browsertest.cc @@ -176,7 +176,12 @@ class ITunesDataProviderTest : public InProcessBrowserTest { return; std::string xml = "<plist><dict><key>Tracks</key><dict>\n"; for (size_t i = 0; i < entries.size(); ++i) { - GURL location("file://localhost/" + entries[i].location.AsUTF8Unsafe()); + std::string seperator; +#if defined(OS_WIN) + seperator = "/"; +#endif + GURL location("file://localhost" + seperator + + entries[i].location.AsUTF8Unsafe()); std::string entry_string = base::StringPrintf( "<key>%" PRIuS "</key><dict>\n" " <key>Track ID</key><integer>%" PRIuS "</integer>\n" diff --git a/chrome/utility/media_galleries/itunes_library_parser.cc b/chrome/utility/media_galleries/itunes_library_parser.cc index 5f14a0e..a7d49d0 100644 --- a/chrome/utility/media_galleries/itunes_library_parser.cc +++ b/chrome/utility/media_galleries/itunes_library_parser.cc @@ -102,7 +102,7 @@ bool GetTrackInfoFromDict(XmlReader* reader, TrackInfo* result) { string16 location(decoded_location.data(), decoded_location.length()); #else string16 location16(decoded_location.data(), decoded_location.length()); - std::string location = UTF16ToUTF8(location16); + std::string location = "/" + UTF16ToUTF8(location16); #endif result->location = base::FilePath(location); found_location = true; diff --git a/chrome/utility/media_galleries/itunes_library_parser_unittest.cc b/chrome/utility/media_galleries/itunes_library_parser_unittest.cc index ccdeb94..cb772f4 100644 --- a/chrome/utility/media_galleries/itunes_library_parser_unittest.cc +++ b/chrome/utility/media_galleries/itunes_library_parser_unittest.cc @@ -33,7 +33,7 @@ namespace { void CompareTrack(const parser::Track& a, const parser::Track& b) { EXPECT_EQ(a.id, b.id); - EXPECT_EQ(a.location, b.location); + EXPECT_EQ(a.location.value(), b.location.value()); } void CompareAlbum(const parser::Album& a, const parser::Album& b) { @@ -90,7 +90,13 @@ class ITunesLibraryParserTest : public testing::Test { void AddExpectedTrack(uint32 id, const std::string& location, const std::string& artist, const std::string& album) { - parser::Track track(id, base::FilePath::FromUTF8Unsafe(location)); + // On Mac this pretends that C: is a directory. +#if defined(OS_MACOSX) + std::string os_location = "/" + location; +#else + const std::string& os_location = location; +#endif + parser::Track track(id, base::FilePath::FromUTF8Unsafe(os_location)); expected_library_[artist][album].insert(track); } @@ -264,6 +270,17 @@ TEST_F(ITunesLibraryParserTest, AlbumArtist) { SIMPLE_FOOTER()); } +TEST_F(ITunesLibraryParserTest, MacPath) { + AddExpectedTrack(1, "dir/Song With Space.mp3", "Artist A", "Album A"); + TestParser( + true, + SIMPLE_HEADER() + // This path is concatenated with "http://localhost/", so no leading + // slash should be used. + SIMPLE_TRACK(1, 1, "dir/Song%20With%20Space.mp3", "Artist A", "Album A") + SIMPLE_FOOTER()); +} + } // namespace } // namespace itunes |