[gnome-continuous: 4/4] applicationstest: Use a list for the apps, rather than a hashmap



commit dc11c8f5948e4f8b6fddb4f2c6636c958275e690
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Nov 15 19:07:40 2013 -0500

    applicationstest: Use a list for the apps, rather than a hashmap
    
    It's easier to scan, and easier to parse from JS.

 extras/build.gnome.org/controllers.js |   26 +++++++++++++++-----------
 src/js/tasks/task-applicationstest.js |   16 ++++++++++------
 2 files changed, 25 insertions(+), 17 deletions(-)
---
diff --git a/extras/build.gnome.org/controllers.js b/extras/build.gnome.org/controllers.js
index af484ec..ab572a8 100644
--- a/extras/build.gnome.org/controllers.js
+++ b/extras/build.gnome.org/controllers.js
@@ -36,19 +36,23 @@
 
         var apps = [];
         $http.get(buildRoot + 'applicationstest/apps.json').success(function(data) {
-            var appsDict = data['apps'];
-            Object.keys(appsDict).forEach(function(id) {
-                var app = appsDict[id];
-                var icon = app.icon ? (ROOT + app.icon) : '/images/app-generic.png';
-                apps.push({ id: id,
-                            name: id, /* XXX */
-                            screenshot: (ROOT + app.screenshot),
-                            status: (app.state == "success") ? 'good' : 'bad',
-                            icon: icon });
+            var apps = data['apps'];
+            apps.forEach(function(app) {
+                // Mangle the data a bit
+
+                app.name = app.id; /* XXX */
+                app.status = (app.state == "success") ? 'good' : 'bad';
+
+                // XXX -- this should probably be in the template
+                if (app.icon)
+                    app.icon = ROOT + app.icon;
+                else
+                    app.icon = '/images/app-generic.png';
+
+                app.screenshot = ROOT + app.screenshot;
             });
+            $scope.apps = apps;
         });
-        $scope.apps = apps;
-
     });
 
     bgoControllers.controller('ContinuousHomeCtrl', function($scope, $http) {
diff --git a/src/js/tasks/task-applicationstest.js b/src/js/tasks/task-applicationstest.js
index 6f18437..8d8b023 100644
--- a/src/js/tasks/task-applicationstest.js
+++ b/src/js/tasks/task-applicationstest.js
@@ -82,7 +82,7 @@ const TaskApplicationsTest = new Lang.Class({
 
     _screenshotTaken: function(path) {
         if (this._testingApp) {
-            let app = this._allApps[this._testingApp];
+            let app = this._testingApp;
             app.screenshot = this.workdir.get_relative_path(path);
         }
     },
@@ -91,21 +91,25 @@ const TaskApplicationsTest = new Lang.Class({
         if (msgId == 'TestingAppStart') {
             let [appId, iconTuple] = value.deep_unpack();
             print("got testingAppStart id=" + appId);
-            this._testingApp = appId;
             let app = {};
+            app.id = appId;
+
             let icon = this._extractIcon(appId, iconTuple, null);
             if (icon)
                 app.icon = this.workdir.get_relative_path(icon);
+
             app.state = 'running';
-            this._allApps[this._testingApp] = app;
+            this._allApps.push(app);
+
+            this._testingApp = app;
             this._testingAppCoredumped = false;
         } else if (msgId == 'TestingAppTimedOut') {
             print("got TestingAppTimedOut");
-            let app = this._allApps[this._testingApp];
+            let app = this._testingApp;
             app.state = 'timeout';
             this._testingApp = null;
         } else if (msgId == 'TestingAppComplete') {
-            let app = this._allApps[this._testingApp];
+            let app = this._testingApp;
             let successfulStr = !this._testingAppCoredumped ? 'success' : 'failed';
             print("got TestingAppComplete success=" + successfulStr);
             app.state = successfulStr;
@@ -122,7 +126,7 @@ const TaskApplicationsTest = new Lang.Class({
     },
    
     _prepareDisk: function(mntdir, arch, cancellable) {
-        this._allApps = {};
+        this._allApps = [];
         let osname = this._buildData['snapshot']['osname'];
         let datadir = LibQA.getDatadir();
         let startStopAppsName = 'gnome-continuous-startstopapps';


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