https://bugs.webkit.org/show_bug.cgi?id=156055
Reviewed by Joseph Pecoraro.
Removed Test.setParentTest. Keep track of the child-parent relationship using the static map instead.
Now each test only stores parent's id and uses the ID static map in Test.parentTest().
* public/v3/models/manifest.js:
(Manifest._didFetchManifest.buildObjectsFromIdMap): Removed the code to create the map of child-parent
relationship and call setParentTest.
* public/v3/models/test.js:
(Test): Updated a static map by the name of "childTestMap" to store itself. We should probably sort
child tests using some fixed criteria in the future instead of relying on the creation order but
preserve the old code's ordering for now.
(Test.prototype.parentTest): Look up the static map by the parent test's id.
(Test.prototype.onlyContainsSingleMetric):
(Test.prototype.setParentTest): Deleted.
(Test.prototype.childTests): Look up the child test map.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198923
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2016-03-30 Ryosuke Niwa <rniwa@webkit.org>
+ Simplify API of Test model by removing Test.setParentTest
+ https://bugs.webkit.org/show_bug.cgi?id=156055
+
+ Reviewed by Joseph Pecoraro.
+
+ Removed Test.setParentTest. Keep track of the child-parent relationship using the static map instead.
+
+ Now each test only stores parent's id and uses the ID static map in Test.parentTest().
+
+ * public/v3/models/manifest.js:
+ (Manifest._didFetchManifest.buildObjectsFromIdMap): Removed the code to create the map of child-parent
+ relationship and call setParentTest.
+ * public/v3/models/test.js:
+ (Test): Updated a static map by the name of "childTestMap" to store itself. We should probably sort
+ child tests using some fixed criteria in the future instead of relying on the creation order but
+ preserve the old code's ordering for now.
+ (Test.prototype.parentTest): Look up the static map by the parent test's id.
+ (Test.prototype.onlyContainsSingleMetric):
+ (Test.prototype.setParentTest): Deleted.
+ (Test.prototype.childTests): Look up the child test map.
+
+2016-03-30 Ryosuke Niwa <rniwa@webkit.org>
+
BuildRequest should have associated platform and test
https://bugs.webkit.org/show_bug.cgi?id=156054
var tests = [];
var testParentMap = {};
- for (var testId in rawResponse.tests) {
- var test = rawResponse.tests[testId];
- var topLevel = !test.parentId;
- if (test.parentId)
- testParentMap[testId] = parseInt(test.parentId);
- tests.push(new Test(testId, test, topLevel));
- }
- for (var testId in testParentMap)
- Test.findById(testId).setParentTest(Test.findById(testParentMap[testId]));
+ for (var testId in rawResponse.tests)
+ tests.push(new Test(testId, rawResponse.tests[testId]));
function buildObjectsFromIdMap(idMap, constructor, resolver) {
for (var id in idMap) {
'use strict';
class Test extends LabeledObject {
- constructor(id, object, isTopLevel)
+ constructor(id, object)
{
super(id, object);
this._url = object.url; // FIXME: Unused
- this._parent = null;
+ this._parentId = object.parentId;
this._childTests = [];
this._metrics = [];
- if (isTopLevel)
+ if (!this._parentId)
this.ensureNamedStaticMap('topLevelTests')[id] = this;
+ else {
+ var childMap = this.ensureNamedStaticMap('childTestMap');
+ if (!childMap[this._parentId])
+ childMap[this._parentId] = [this];
+ else
+ childMap[this._parentId].push(this);
+ }
}
static topLevelTests() { return this.sortByName(this.listForStaticMap('topLevelTests')); }
- parentTest() { return this._parent; }
+ parentTest() { return Test.findById(this._parentId); }
path()
{
return path;
}
- onlyContainsSingleMetric() { return !this._childTests.length && this._metrics.length == 1; }
-
- // FIXME: We should store the child test order in the server.
- childTests() { return this._childTests; }
- metrics() { return this._metrics; }
+ onlyContainsSingleMetric() { return !this.childTests().length && this._metrics.length == 1; }
- setParentTest(parent)
+ childTests()
{
- parent.addChildTest(this);
- this._parent = parent;
+ var childMap = this.namedStaticMap('childTestMap');
+ return childMap && this.id() in childMap ? childMap[this.id()] : [];
}
+ metrics() { return this._metrics; }
+
addChildTest(test) { this._childTests.push(test); }
addMetric(metric) { this._metrics.push(metric); }
}