[gnome-continuous/wip/apps: 1/2] applicationtest: Extract the icons for every app tested



commit fe998b9d1b6d39c295180e4a20af3f829f5f424e
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Nov 13 14:07:48 2013 -0500

    applicationtest: Extract the icons for every app tested
    
    So we can display them on the web page

 src/js/tasks/task-applicationstest.js    |   14 ++++++++++++--
 src/tests/gnome-continuous-startstopapps |   17 ++++++++++++++---
 2 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/src/js/tasks/task-applicationstest.js b/src/js/tasks/task-applicationstest.js
index f992b64..4b24db1 100644
--- a/src/js/tasks/task-applicationstest.js
+++ b/src/js/tasks/task-applicationstest.js
@@ -64,9 +64,18 @@ const TaskApplicationsTest = new Lang.Class({
         }
     },
 
+    _copyIcon: function(appId, iconPath, cancellable) {
+        let src = this._deployDir.resolve_relative_path(iconPath);
+        let appName = appId.replace(/\.desktop$/, '');
+        let dst = Gio.File.new_for_path('icon-' + app + '.png');
+        src.copy(dst, Gio.FileCopyFlags.OVERWRITE, cancellable, null, null);
+    },
+
     _onCommandChannelAsyncMessage: function(msgId, value) {
         if (msgId == 'TestingAppStart') {
-            this._testingApp = value.deep_unpack();
+            let [appId, iconPath] = value.deep_unpack();
+            this._testingApp = appId;
+            this._copyIcon(appId, icon, null);
             print("got testingAppStart id=" + this._testingApp);
             this._allApps[this._testingApp] = {'state': 'running'};
             GSystem.file_ensure_directory(this._statusPath.get_parent(), true, null);
@@ -90,7 +99,7 @@ const TaskApplicationsTest = new Lang.Class({
         let appsDataPath = Gio.File.new_for_path('apps.json');
         JSONUtil.writeJsonFileAtomic(appsDataPath, {'apps': this._allApps }, null);
     },
-   
+
     _prepareDisk: function(mntdir, arch, cancellable) {
         this._allApps = {};
         let osname = this._buildData['snapshot']['osname'];
@@ -98,6 +107,7 @@ const TaskApplicationsTest = new Lang.Class({
         let startStopAppsName = 'gnome-continuous-startstopapps';
         let startStopAppsSrc = datadir.resolve_relative_path('tests/' + startStopAppsName);
         let [deployDir, deployEtcDir] = LibQA.getDeployDirs(mntdir, osname);
+        this._deployDir = deployDir;
         let startStopAppsDest = deployDir.resolve_relative_path('usr/bin/' + startStopAppsName);
         print("Copying to " + startStopAppsDest.get_path());
         startStopAppsSrc.copy(startStopAppsDest, Gio.FileCopyFlags.OVERWRITE, cancellable, null, null);
diff --git a/src/tests/gnome-continuous-startstopapps b/src/tests/gnome-continuous-startstopapps
index 23ae6bb..ce67037 100644
--- a/src/tests/gnome-continuous-startstopapps
+++ b/src/tests/gnome-continuous-startstopapps
@@ -17,11 +17,14 @@
 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 // Boston, MA 02111-1307, USA.
 
+const Gtk = imports.gi.Gtk;
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
 const Gio = imports.gi.Gio;
 const Lang = imports.lang;
 
+Gtk.init(null);
+
 const sessionBus = Gio.bus_get_sync(Gio.BusType.SESSION, null);
 
 const CLOSE_ALL_APPS = 'Shell.AppSystem.get_default().get_running().forEach(function (app) { 
app.request_quit(); });';
@@ -41,6 +44,15 @@ const StartStopApps = new GObject.Class({
        GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3, Lang.bind(this, this._startTesting));
     },
 
+    _getIconPath: function(app) {
+        const ICON_SIZE = 256;
+
+        let icon = app.get_icon();
+        let theme = Gtk.IconTheme.get_default();
+        let info = theme.lookup_by_gicon(icon, ICON_SIZE, 1, 0);
+        return info.get_filename();
+    },
+
     _startTesting: function() {
        this._shell = Gio.DBusProxy.new_sync(sessionBus, 0, null,
                                             "org.gnome.Shell", "/org/gnome/Shell",
@@ -73,9 +85,8 @@ const StartStopApps = new GObject.Class({
        let appid = this._testingApp.get_id();
        print("testing appid=" + appid);
 
-       this._shellEval(CLOSE_ALL_APPS, this._cancellable);
-
-       this._sendAsyncMessage('TestingAppStart', GLib.Variant.new("s", appid));
+        let icon = this._getIconPath(this._testingApp);
+       this._sendAsyncMessage('TestingAppStart', GLib.Variant.new("(ss)", [appid, icon]));
        this._testingApp.launch([], this._cancellable);
        this._appCheckRunningIterations = 0;
        this._appCheckRunningTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1,


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