| <!DOCTYPE html> |
| <!-- |
| Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| |
| <link rel="import" href="/extras/chrome/chrome_test_utils.html"> |
| <link rel="import" href="/extras/rail/rail_score.html"> |
| |
| <script> |
| 'use strict'; |
| |
| tr.b.unittest.testSuite(function() { |
| test('zeroInteractionRecords', function() { |
| var score = new tr.e.rail.RAILScore(); |
| assert.equal(0, score.interactionRecords.length); |
| assert.isUndefined(score.overallScore); |
| }); |
| |
| test('overallScore', function() { |
| var score = new tr.e.rail.RAILScore([ |
| {railScore: 0.9}, |
| {railScore: 1.0}, |
| {railScore: 0.89}, |
| {railScore: 1.0}, |
| {railScore: 0.1} |
| ]); |
| assert.equal(5, score.interactionRecords.length); |
| |
| var expectedOverallScore = 0.72; |
| assert.closeTo(score.overallScore, 0.72, 0.01); |
| }); |
| |
| test('fromModel', function() { |
| var model = tr.e.audits.newChromeModel(function(model) { |
| model.addInteractionRecord(new tr.e.rail.RAILInteractionRecord( |
| 'Idle', 'rail_idle', 0, 1)); |
| }); |
| var score = tr.e.rail.RAILScore.fromModel(model); |
| assert.equal(1, score.interactionRecords.length); |
| }); |
| |
| test('fromEmptyModel', function() { |
| var model = tr.e.audits.newChromeModel(function(model) { |
| }); |
| assert.isUndefined(tr.e.rail.RAILScore.fromModel(model)); |
| }); |
| }); |
| </script> |