OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * GMActualResultsLoader: |
| 3 * Reads an actual-results.json file, and imports its data into $scope. |
| 4 */ |
| 5 var GMActualResultsLoader = angular.module( |
| 6 'GMActualResultsLoader', |
| 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 GMActualResultsLoader.controller( |
| 17 'GMActualResultsLoader.Controller', |
| 18 function($scope, $http) { |
| 19 /* When the changePlatformPath function is called, download actual-results
.json |
| 20 * from the desired platform directory. |
| 21 * |
| 22 * When the JSON is received, predigest it (combining actual and expected
results for each |
| 23 * test) and return it to the frontend as $scope.gmActualResults like so: |
| 24 * |
| 25 * [ |
| 26 * {"resultType": "failed", |
| 27 * "resultsOfThisType": [ |
| 28 * {"test":"bigmatrix", "config":"gpu", |
| 29 * "actualHashType": "bitmap-64bitMD5", "actualHashValue": "1234", |
| 30 * "expectedHashType": "bitmap-64bitMD5", "actualHashValue": "6789"}
, |
| 31 * {"test":"bigmatrix", "config":"8888", |
| 32 * "actualHashType": "bitmap-64bitMD5", "actualHashValue": "5678", |
| 33 * "expectedHashType": "bitmap-64bitMD5", "actualHashValue": "6789"}
, |
| 34 * more tests... |
| 35 * ]}, |
| 36 * {"resultType": "no-comparison", |
| 37 * "resultsOfThisType": [ |
| 38 * {"test":"aaclip", "config":"gpu", |
| 39 * "actualHashType": "bitmap-64bitMD5", "actualHashValue": "8765"}, |
| 40 * {"test":"aaclip", "config":"8888", |
| 41 * "actualHashType": "bitmap-64bitMD5", "actualHashValue": "4321"}, |
| 42 * more tests... |
| 43 * ]}, |
| 44 * more result types... |
| 45 * ] |
| 46 */ |
| 47 $scope.changePlatformPath = function() { |
| 48 $http.get($scope.platformPath + "/actual-results.json").success( |
| 49 function(response) { |
| 50 var jsonResults = []; |
| 51 var imageNameRegex = /^(.+)_([^_]+).png/; |
| 52 angular.forEach(response['actual-results'], function(resultsOfThis
Type, resultType) { |
| 53 var resultCollection = []; |
| 54 angular.forEach(resultsOfThisType, function(hashTypeAndValue, im
ageName) { |
| 55 var matched = imageNameRegex.exec(imageName); |
| 56 var thisResult = { |
| 57 test: matched[1], config: matched[2], |
| 58 actualHashType: hashTypeAndValue[0], actualHashValue: hashTy
peAndValue[1] }; |
| 59 var expectations = response['expected-results'][imageName]['al
lowed-digests']; |
| 60 if (expectations != null) { |
| 61 thisResult.expectedHashType = expectations[0][0]; |
| 62 thisResult.expectedHashValue = expectations[0][1]; |
| 63 } |
| 64 resultCollection.push(thisResult); |
| 65 }); |
| 66 var resultTypeAndCollection = { resultType: resultType, |
| 67 resultsOfThisType: resultCollect
ion }; |
| 68 jsonResults.push(resultTypeAndCollection); |
| 69 }); |
| 70 $scope.gmActualResults = jsonResults; |
| 71 } |
| 72 ); |
| 73 }; |
| 74 } |
| 75 ); |
OLD | NEW |