1 <!DOCTYPE html> 2 <!-- 3 Copyright 2016 The Chromium Authors. All rights reserved. 4 Use of this source code is governed by a BSD-style license that can be 5 found in the LICENSE file. 6 --> 7 8 <link rel="import" href="/dashboard/elements/bisect-button.html"> 9 <link rel="import" href="/dashboard/static/testing_common.html"> 10 11 <link rel="import" href="/tracing/core/test_utils.html"> 12 13 <script> 14 'use strict'; 15 16 tr.b.unittest.testSuite(function() { 17 18 var testOptions = { 19 tearDown: function() { 20 testing_common.clearXhrMock(); 21 testing_common.clearFixture(); 22 } 23 }; 24 25 test('instantiate_basic', function() { 26 var button = document.createElement('bisect-button'); 27 this.addHTMLOutput(button); 28 }, testOptions); 29 30 test('canBisect false if there is no bisectInfo', function() { 31 var button = document.createElement('bisect-button'); 32 testing_common.addToFixture(button); 33 button.bugId = 500500; 34 assert.isFalse(button.canBisect); 35 }, testOptions); 36 37 test('empty', function() { 38 }, testOptions); 39 40 test('canBisect set to true for valid tests after check', function() { 41 testing_common.addXhrMock( 42 '/can_bisect?test_path=ChromiumPerf%2Flinux%2Fsunspider%2FTotal' + 43 '&start_revision=323400&end_revision=323500', 44 'true'); 45 46 var button = document.createElement('bisect-button'); 47 testing_common.addToFixture(button); 48 button.bisectInfo = { 49 'testPath': 'ChromiumPerf/linux/sunspider/Total', 50 'goodRev': 323400, 51 'badRev': 323500 52 }; 53 54 return new Promise(function(resolve) { 55 function check() { 56 assert.isTrue(button.canBisect); 57 resolve(); 58 } 59 setTimeout(check, 10); 60 }); 61 }, testOptions); 62 63 test('canBisect set to false for invalid tests after check', function() { 64 testing_common.addXhrMock( 65 '/can_bisect?test_path=Chromium%2Flinux%2Fsizes' + 66 '&start_revision=323400&end_revision=323500', 67 'false'); 68 69 var button = document.createElement('bisect-button'); 70 testing_common.addToFixture(button); 71 button.bisectInfo = { 72 'testPath': 'Chromium/linux/sizes', 73 'goodRev': 323400, 74 'badRev': 323500 75 }; 76 77 return new Promise(function(resolve) { 78 function check() { 79 assert.isFalse(button.canBisect); 80 resolve(); 81 } 82 setTimeout(check, 100); 83 }); 84 }, testOptions); 85 86 }); 87 </script> 88