| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * GMExpectedResultsLoader: | |
| 3 * Reads an expected-results.json file, and imports its data into $scope. | |
| 4 */ | |
| 5 var GMExpectedResultsLoader = angular.module( | |
| 6 'GMExpectedResultsLoader', | |
| 7 [], | |
| 8 function($httpProvider) { | |
| 9 /* Override transformResponse so that the numeric checksums are interprete
d as | |
| 10 * strings instead, since Javascript cannot handle 64-bit integers. */ | |
| 11 $httpProvider.defaults.transformResponse = function(data, headersGetter) { | |
| 12 return JSON.parse(data.replace(/\s(\d+)\s/g, " \"$1\" ")); | |
| 13 } | |
| 14 } | |
| 15 ); | |
| 16 GMExpectedResultsLoader.controller( | |
| 17 'GMExpectedResultsLoader.Controller', | |
| 18 function($scope, $http) { | |
| 19 /* When the changePlatformPath function is called, download expected-resul
ts.json | |
| 20 * from the desired platform directory. | |
| 21 * | |
| 22 * When the JSON is received, predigest it and return it to the frontend a
s | |
| 23 * $scope.gmExpectedResults . | |
| 24 */ | |
| 25 $scope.changePlatformPath = function() { | |
| 26 $http.get($scope.platformPath + "/expected-results.json").success( | |
| 27 function(response) { | |
| 28 var jsonResults = []; | |
| 29 var imageNameRegex = /^(.+)_([^_]+).png/; | |
| 30 angular.forEach(response['expected-results'], function(imageExpect
ations, imageName) { | |
| 31 var matched = imageNameRegex.exec(imageName); | |
| 32 var allowedImages = []; | |
| 33 angular.forEach(imageExpectations['allowed-digests'], function(a
llowedDigest, key) { | |
| 34 var thisImage = { | |
| 35 hashType: allowedDigest[0], hashValue: allowedDigest[1] | |
| 36 }; | |
| 37 allowedImages.push(thisImage); | |
| 38 }); | |
| 39 var thisResult = { | |
| 40 test: matched[1], config: matched[2], | |
| 41 allowedImages: allowedImages, | |
| 42 bugs: imageExpectations['bugs'], | |
| 43 reviewedByHuman: imageExpectations['reviewed-by-human'] | |
| 44 }; | |
| 45 jsonResults.push(thisResult); | |
| 46 }); | |
| 47 $scope.gmExpectedResults = jsonResults; | |
| 48 } | |
| 49 ); | |
| 50 }; | |
| 51 } | |
| 52 ); | |
| OLD | NEW |