예제 #1
0
        public void TestSizePath()
        {
            var png_file_path = ExtractPngFromResource ();
            string jpg_file_path = null;

            try {
                var artist_album_id = CoverArtSpec.CreateArtistAlbumId ("Metallica", "Master Of Puppets");
                jpg_file_path = CoverArtSpec.GetPathForSize (artist_album_id, CustomArtworkManager.SizeTest); // i.e.: /home/knocte/.cache/media-art/36/album-d33f25dbd7dfb4817a7e99f6bc2de49e.jpg"
                var pixbuf = new Pixbuf (png_file_path);

                var dir = System.IO.Path.GetDirectoryName (jpg_file_path);
                if (!System.IO.Directory.Exists (dir)) {
                    System.IO.Directory.CreateDirectory (dir);
                }

                pixbuf.Save (jpg_file_path, "jpeg");

                var artwork_manager = new CustomArtworkManager ();
                Assert.IsNull (artwork_manager.LookupScaleSurface (artist_album_id, 1, false),
                               "Should have got null at the first request, with an invalid size");
                Assert.IsNotNull (artwork_manager.LookupScaleSurface (artist_album_id, CustomArtworkManager.SizeTest, false),
                                  "Null at the second request, was null cached incorrectly?");

            } finally {
                File.Delete (png_file_path);
                if (File.Exists (jpg_file_path)) {
                    File.Delete (jpg_file_path);
                }
            }
        }
예제 #2
0
        public void TestSizePath()
        {
            var    png_file_path = ExtractPngFromResource();
            string jpg_file_path = null;

            try {
                var artist_album_id = CoverArtSpec.CreateArtistAlbumId("Metallica", "Master Of Puppets");
                jpg_file_path = CoverArtSpec.GetPathForSize(artist_album_id, CustomArtworkManager.SizeTest);  // i.e.: /home/knocte/.cache/media-art/36/album-d33f25dbd7dfb4817a7e99f6bc2de49e.jpg"
                var pixbuf = new Pixbuf(png_file_path);

                var dir = System.IO.Path.GetDirectoryName(jpg_file_path);
                if (!System.IO.Directory.Exists(dir))
                {
                    System.IO.Directory.CreateDirectory(dir);
                }

                pixbuf.Save(jpg_file_path, "jpeg");

                var artwork_manager = new CustomArtworkManager();
                Assert.IsNull(artwork_manager.LookupScaleSurface(artist_album_id, 1, false),
                              "Should have got null at the first request, with an invalid size");
                Assert.IsNotNull(artwork_manager.LookupScaleSurface(artist_album_id, CustomArtworkManager.SizeTest, false),
                                 "Null at the second request, was null cached incorrectly?");
            } finally {
                File.Delete(png_file_path);
                if (File.Exists(jpg_file_path))
                {
                    File.Delete(jpg_file_path);
                }
            }
        }