Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview Tests for settings.OpenSectionTransition and | |
| 7 * settings.CloseSectionTransition. | |
| 8 */ | |
| 9 | |
| 10 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ | |
| 11 var ROOT_PATH = '../../../../../'; | |
| 12 | |
| 13 // Polymer BrowserTest fixture. | |
| 14 GEN_INCLUDE( | |
| 15 [ROOT_PATH + 'chrome/test/data/webui/polymer_browser_test_base.js']); | |
| 16 | |
| 17 /** | |
| 18 * @constructor | |
| 19 * @extends PolymerTest | |
| 20 */ | |
| 21 function SettingsOpenSectionTransitionBrowserTest() {} | |
| 22 | |
| 23 SettingsOpenSectionTransitionBrowserTest.prototype = { | |
| 24 __proto__: PolymerTest.prototype, | |
| 25 | |
| 26 /** @override */ | |
| 27 browsePreload: | |
| 28 'chrome://md-settings/settings_page/open_section_transition.html', | |
| 29 | |
| 30 /** @override */ | |
| 31 extraLibraries: PolymerTest.getLibraries(ROOT_PATH), | |
| 32 | |
| 33 /** @override */ | |
| 34 isAsync: true, | |
| 35 | |
| 36 /** @override */ | |
| 37 runAccessibilityChecks: false, | |
| 38 }; | |
| 39 | |
| 40 TEST_F('SettingsOpenSectionTransitionBrowserTest', 'OpenSectionTransition', | |
| 41 function() { | |
| 42 suite('settings.animation.OpenSectionTransition', function() { | |
| 43 var container; | |
| 44 var section; | |
| 45 var card; | |
| 46 | |
| 47 suiteSetup(function() { | |
| 48 return PolymerTest.importHtml('/settings_page/settings_section.html'); | |
| 49 }); | |
| 50 | |
| 51 setup(function() { | |
| 52 container = document.createElement('div'); | |
| 53 container.style.height = '1000px'; | |
| 54 container.style.height = '800px'; | |
| 55 section = document.createElement('settings-section'); | |
| 56 section.style.height = '300px'; | |
| 57 card = section.$.card; | |
| 58 container.appendChild(section); | |
| 59 document.body.appendChild(container); | |
| 60 | |
| 61 // Simulate content and setup. | |
| 62 card.style.top = '10px'; | |
| 63 card.style.height = '200px'; | |
| 64 card.origHeight_ = card.clientHeight; | |
| 65 }); | |
| 66 | |
| 67 teardown(function() { | |
| 68 container.remove(); | |
| 69 }); | |
| 70 | |
| 71 test('transition finishes', function() { | |
| 72 settings.animation.Timing.DURATION = 200; | |
| 73 var openTransition = | |
| 74 new settings.OpenSectionTransition(section, container); | |
| 75 var startTime = performance.now(); | |
| 76 var finished = openTransition.play(); | |
| 77 expectEquals('fixed', getComputedStyle(card).position); | |
| 78 return finished.then(function() { | |
| 79 // Ensure the animation actually played over a length of time. | |
| 80 // TODO(michaelpg): Verify this is not flaky. | |
| 81 var totalTime = performance.now() - startTime; | |
| 82 expectLE(settings.animation.Timing.DURATION, totalTime); | |
| 83 expectEquals('', card.style.position); | |
| 84 | |
|
dschuyler
2016/06/30 01:24:04
extra blank line.
michaelpg
2016/07/07 05:27:43
Done.
| |
| 85 | |
| 86 var closeTransition = | |
| 87 new settings.CloseSectionTransition(section, container); | |
| 88 closeTransition.setUp(); | |
| 89 startTime = performance.now(); | |
| 90 finished = closeTransition.play(); | |
| 91 return finished.then(function() { | |
| 92 totalTime = performance.now() - startTime; | |
| 93 expectLE(settings.animation.Timing.DURATION, totalTime); | |
| 94 expectEquals('static', getComputedStyle(card).position); | |
| 95 }); | |
| 96 }); | |
| 97 }); | |
| 98 // TODO(michaelpg): More tests. | |
| 99 }); | |
| 100 | |
| 101 // Run all registered tests. | |
| 102 mocha.run(); | |
| 103 }); | |
| OLD | NEW |