|
| 1 | +/* |
| 2 | + * Copyright (C) 2024 Apple Inc. All rights reserved. |
| 3 | + * |
| 4 | + * Redistribution and use in source and binary forms, with or without |
| 5 | + * modification, are permitted provided that the following conditions |
| 6 | + * are met: |
| 7 | + * 1. Redistributions of source code must retain the above copyright |
| 8 | + * notice, this list of conditions and the following disclaimer. |
| 9 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | + * notice, this list of conditions and the following disclaimer in the |
| 11 | + * documentation and/or other materials provided with the distribution. |
| 12 | + * |
| 13 | + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | + * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | + */ |
| 25 | + |
| 26 | +describe('Data Import', function() { |
| 27 | + it('Fetch test data', async function() { |
| 28 | + this.timeout(200); |
| 29 | + |
| 30 | + const url = "data/two-suite-single-iteration-test-data.json"; |
| 31 | + const response = await fetch(url); |
| 32 | + expect(response.ok).to.be(true); |
| 33 | + |
| 34 | + this.json = await response.json(); |
| 35 | + expect(this.json.version).to.be('1.4'); |
| 36 | + }); |
| 37 | + |
| 38 | + it('Validate imported data', function() { |
| 39 | + expect(this.json.options instanceof Object).to.be(true); |
| 40 | + expect(this.json.data instanceof Array).to.be(true); |
| 41 | + }); |
| 42 | + |
| 43 | + it('Create results', function() { |
| 44 | + this.timeout(500); |
| 45 | + |
| 46 | + // Make the results analysis faster. |
| 47 | + this.json.options[Strings.json.bootstrapIterations] = 10; |
| 48 | + |
| 49 | + const dashboard = new ResultsDashboard(this.json.version, this.json.options, this.json.data); |
| 50 | + this.results = dashboard.results; |
| 51 | + expect(this.results instanceof Array).to.be(true); |
| 52 | + }); |
| 53 | + |
| 54 | + it('Validate results', function() { |
| 55 | + |
| 56 | + // Check that we have results, not their exact values. |
| 57 | + const firstResults = this.results[0]; |
| 58 | + |
| 59 | + expect(typeof firstResults[Strings.json.score]).to.be('number'); |
| 60 | + expect(typeof firstResults[Strings.json.scoreLowerBound]).to.be('number'); |
| 61 | + expect(typeof firstResults[Strings.json.scoreUpperBound]).to.be('number'); |
| 62 | + |
| 63 | + expect(firstResults[Strings.json.results.tests] instanceof Object).to.be(true); |
| 64 | + |
| 65 | + const testsResults = firstResults[Strings.json.results.tests]; |
| 66 | + expect(testsResults['MotionMark'] instanceof Object).to.be(true); |
| 67 | + |
| 68 | + const motionMarkResults = testsResults['MotionMark']; |
| 69 | + expect(motionMarkResults['Multiply'] instanceof Object).to.be(true); |
| 70 | + expect(motionMarkResults['Leaves'] instanceof Object).to.be(true); |
| 71 | + |
| 72 | + const multiplyResults = motionMarkResults['Multiply']; |
| 73 | + expect(typeof multiplyResults[Strings.json.score]).to.be('number'); |
| 74 | + expect(typeof multiplyResults[Strings.json.scoreLowerBound]).to.be('number'); |
| 75 | + expect(typeof multiplyResults[Strings.json.scoreUpperBound]).to.be('number'); |
| 76 | + }); |
| 77 | +}); |
0 commit comments