[gnome-ostree] smoketest: Convert images to PNG if we have GdkPixbuf



commit 59055e3c48c870c6e84f2eb380776b67b267b0a6
Author: Colin Walters <walters verbum org>
Date:   Wed Apr 17 03:56:56 2013 -0400

    smoketest: Convert images to PNG if we have GdkPixbuf
    
    Then they can be sanely viewed in the browser.

 src/js/tasks/task-smoketest.js | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/js/tasks/task-smoketest.js b/src/js/tasks/task-smoketest.js
index 7b0cbc2..a5243e5 100644
--- a/src/js/tasks/task-smoketest.js
+++ b/src/js/tasks/task-smoketest.js
@@ -168,6 +168,7 @@ const SmoketestOne = new Lang.Class({
 
     _screenshot: function(isFinal) {
         let filename;
+        let modified = true;
         if (isFinal)
             filename = "screenshot-final.ppm";
         else
@@ -175,17 +176,30 @@ const SmoketestOne = new Lang.Class({
 
         this._qemuCommand({"execute": "screendump", "arguments": { "filename": filename }});
 
+        let filePath = this._subworkdir.get_child(filename);
+
         if (!isFinal) {
-            let filePath = this._subworkdir.get_child(filename);
                  let contentsBytes = GSystem.file_map_readonly(filePath, this._cancellable);
                  let csum = GLib.compute_checksum_for_bytes(GLib.ChecksumType.SHA256,
                                                                                           contentsBytes);
             
-            if (this._lastScreenshotChecksum == csum)
+            modified = this._lastScreenshotChecksum != csum;
+            if (!modified) {
                 GSystem.file_unlink(filePath, this._cancellable);
-            this._lastScreenshotChecksum = csum;
+            } else {
+                this._lastScreenshotChecksum = csum;
+            }
             this._screenshotSerial++;
         }
+
+        // Convert to PNG if possible
+        if (modified && imports.gi.GdkPixbuf) {
+            let GdkPixbuf = imports.gi.GdkPixbuf;
+            let pixbuf = GdkPixbuf.Pixbuf.new_from_file(filePath.get_path());
+            let outFilename = this._subworkdir.get_child(filename.replace(/ppm$/, 'png'));
+                    pixbuf.savev(outFilename.get_path(), "png", [], []);
+            GSystem.file_unlink(filePath, this._cancellable);
+        }
     },
 
     _idleScreenshot: function() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]