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



commit bf000501550efffa9cb13c214d74de729eeb80c6
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 +++++++++++--------
 .../partials/gnome-continuous-build.html           |    2 +-
 src/js/tasks/task-applicationstest.js              |   16 +++++++----
 3 files changed, 26 insertions(+), 18 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/extras/build.gnome.org/partials/gnome-continuous-build.html 
b/extras/build.gnome.org/partials/gnome-continuous-build.html
index bc99dc1..2627b7f 100644
--- a/extras/build.gnome.org/partials/gnome-continuous-build.html
+++ b/extras/build.gnome.org/partials/gnome-continuous-build.html
@@ -8,7 +8,7 @@
   </div>
 
   <div class="app-grid">
-    <a ng-repeat="app in apps" class="app" ng-class="app.status" title="{{ app.name }}" href="???">
+    <a ng-repeat="app in apps" class="app" ng-class="app.status" title="{{ app.name }}" href="{{ 
app.screenshot }}">
       <div class="icon">
         <img src="{{ app.icon }}">
         <div class="emblem"></div>
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]