| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(kjlubick): add tests for this code | 5 // TODO(kjlubick): add tests for this code |
| 6 | 6 |
| 7 this.swarming = this.swarming || {}; | 7 this.swarming = this.swarming || {}; |
| 8 this.swarming.alias = this.swarming.alias || (function(){ | 8 this.swarming.alias = this.swarming.alias || (function(){ |
| 9 var ANDROID_ALIASES = { | 9 var ANDROID_ALIASES = { |
| 10 "angler": "Nexus 6p", | 10 "angler": "Nexus 6p", |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // treat type as the actual alias | 75 // treat type as the actual alias |
| 76 return type + " ("+orig+")"; | 76 return type + " ("+orig+")"; |
| 77 } | 77 } |
| 78 var alias = aliaser(orig); | 78 var alias = aliaser(orig); |
| 79 if (alias !== "unknown") { | 79 if (alias !== "unknown") { |
| 80 return alias + " ("+orig+")"; | 80 return alias + " ("+orig+")"; |
| 81 } | 81 } |
| 82 return orig; | 82 return orig; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 alias.has = function(type) { |
| 86 return !!aliasMap[type]; |
| 87 }; |
| 88 |
| 85 alias.gpu = function(gpu) { | 89 alias.gpu = function(gpu) { |
| 86 return GPU_ALIASES[gpu] || UNKNOWN; | 90 return GPU_ALIASES[gpu] || UNKNOWN; |
| 87 }; | 91 }; |
| 88 | 92 |
| 89 // alias.unapply will return the base dimension/state with its alias removed | 93 // alias.unapply will return the base dimension/state with its alias removed |
| 90 // if it had one. This is handy for sorting and filtering. | 94 // if it had one. This is handy for sorting and filtering. |
| 91 alias.unapply = function(str) { | 95 alias.unapply = function(str) { |
| 92 var match = ALIAS_REGEXP.exec(str); | 96 var match = ALIAS_REGEXP.exec(str); |
| 93 if (match) { | 97 if (match) { |
| 94 return match[1]; | 98 return match[1]; |
| 95 } | 99 } |
| 96 return str; | 100 return str; |
| 97 }; | 101 }; |
| 98 | 102 |
| 99 var aliasMap = { | 103 var aliasMap = { |
| 100 "device_type": alias.android, | 104 "device_type": alias.android, |
| 101 "gpu": alias.gpu, | 105 "gpu": alias.gpu, |
| 102 } | 106 } |
| 103 | 107 |
| 104 return alias; | 108 return alias; |
| 105 })(); | 109 })(); |
| OLD | NEW |