diff options
Diffstat (limited to 'catapult/third_party/polymer/components/neon-animation/test')
5 files changed, 378 insertions, 0 deletions
diff --git a/catapult/third_party/polymer/components/neon-animation/test/index.html b/catapult/third_party/polymer/components/neon-animation/test/index.html new file mode 100644 index 00000000..81555a2b --- /dev/null +++ b/catapult/third_party/polymer/components/neon-animation/test/index.html @@ -0,0 +1,28 @@ +<!DOCTYPE html><!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> + <title>neon-animation tests</title> + <script src="../../web-component-tester/browser.js"></script> +</head> +<body> + <script> + WCT.loadSuites([ + 'neon-animated-pages.html', + 'neon-animated-pages.html?dom=shadow', + 'neon-animated-pages-lazy.html', + 'neon-animated-pages-lazy.html?dom=shadow', + 'neon-animated-pages-descendant-selection.html', + 'neon-animated-pages-descendant-selection.html?dom=shadow', + ]); + </script> + + +</body></html> diff --git a/catapult/third_party/polymer/components/neon-animation/test/neon-animated-pages-descendant-selection.html b/catapult/third_party/polymer/components/neon-animation/test/neon-animated-pages-descendant-selection.html new file mode 100644 index 00000000..0904a395 --- /dev/null +++ b/catapult/third_party/polymer/components/neon-animation/test/neon-animated-pages-descendant-selection.html @@ -0,0 +1,118 @@ +<!DOCTYPE html> +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--> +<html> +<head> +<meta charset="utf-8"> +<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1"> +<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"> + +<script src="../../webcomponentsjs/webcomponents-lite.js"></script> +<script src="../../web-component-tester/browser.js"></script> +<script src="../../test-fixture/test-fixture-mocha.js"></script> + +<link rel="import" href="../../test-fixture/test-fixture.html"> +<link rel="import" href="../../neon-animation/neon-animated-pages.html"> +<link rel="import" href="../../neon-animation/neon-animation-behavior.html"> +<link rel="import" href="../../iron-selector/iron-selector.html"> + +</head> +<body> + +<test-fixture id="descendant-selection"> + <template> + <neon-animated-pages entry-animation="test-animation" animate-initial-selection> + <iron-selector selected="0" id="selector"> + <div>1</div> + <div id="target">2</div> + </iron-selector> + </neon-animated-pages> + </template> +</test-fixture> + +<test-fixture id="selecting-item"> + <template> + <neon-animated-pages entry-animation="test-animation" animate-initial-selection> + <x-selecting-element></x-selecting-element> + <div id="target"></div> + </neon-animated-pages> + </template> +</test-fixture> + +<dom-module id="x-selecting-element"> + <template> + <iron-selector selected="0" id="selector"> + <div>1</div> + <div id="target">2</div> + </iron-selector> + </template> +</dom-module> + +<dom-module id="test-element"> + <template> + <neon-animated-pages entry-animation="test-animation" animate-initial-selection> + <content></content> + </neon-animated-pages> + </template> +</dom-module> + +<script> + HTMLImports.whenReady(function() { + Polymer({ is: 'x-selecting-element' }); + Polymer({ is: 'test-element' }); + Polymer({ + is: 'test-animation', + behaviors: [ + Polymer.NeonAnimationBehavior + ], + configure: function(config) { + config.node.animated = true; + } + }); + }); +</script> + +<test-fixture id="distributed-children"> + <template> + <test-element> + <div>1</div> + <div id="target">2</div> + </test-element> + </template> +</test-fixture> + +<script> +suite('descendant selection', function() { + test('descendents of other selectors are not animated', function() { + var animatedPages = fixture('descendant-selection'); + var selector = Polymer.dom(animatedPages).querySelector('#selector'); + var target = Polymer.dom(animatedPages).querySelector('#target'); + Polymer.dom(selector).setAttribute('selected', '1'); + assert(!target.animated); + }); + test('elements distributed as children are animated', function() { + var testElement = fixture('distributed-children'); + var target = Polymer.dom(testElement).querySelector('#target'); + var animatedPages = Polymer.dom(testElement.root).querySelector("neon-animated-pages"); + Polymer.dom(animatedPages).setAttribute('selected', '1'); + assert(target.animated); + }); + test('ignores selection from shadow descendants of its items', function() { + var pages = fixture('selecting-item'); + var target = Polymer.dom(pages).querySelector('#target'); + var selecting = Polymer.dom(pages).querySelector('x-selecting-element'); + selecting.$.selector.selected = 1; + assert(!target.animated); + }); +}); +</script> + +</body> +</html> diff --git a/catapult/third_party/polymer/components/neon-animation/test/neon-animated-pages-lazy.html b/catapult/third_party/polymer/components/neon-animation/test/neon-animated-pages-lazy.html new file mode 100644 index 00000000..86ef1988 --- /dev/null +++ b/catapult/third_party/polymer/components/neon-animation/test/neon-animated-pages-lazy.html @@ -0,0 +1,73 @@ +<!doctype html> +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--> +<html> +<head> + + <title>neon-animated-pages tests</title> + + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> + <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"> + + <script src="../../webcomponentsjs/webcomponents-lite.js"></script> + + <script>Polymer = {lazyRegister: true}</script> + + <script src="../../web-component-tester/browser.js"></script> + <script src="../../test-fixture/test-fixture-mocha.js"></script> + + <link rel="import" href="../../test-fixture/test-fixture.html"> + <link rel="import" href="../neon-animated-pages.html"> + <link rel="import" href="../neon-animatable.html"> + <link rel="import" href="../animations/slide-from-left-animation.html"> + <link rel="import" href="../animations/slide-right-animation.html"> + <link rel="import" href="test-resizable-pages.html"> + +</head> +<body> + + <test-fixture id="animate-initial-selection"> + <template> + <neon-animated-pages entry-animation="slide-from-left-animation" exit-animation="slide-right-animation" animate-initial-selection> + <neon-animatable></neon-animatable> + <neon-animatable></neon-animatable> + </neon-animated-pages> + </template> + </test-fixture> + + <script> + suite('animations found when `lazRegister` setting is true', function() { + test('animations are registered', function(done) { + var animatedPages = fixture('animate-initial-selection'); + animatedPages._complete = sinon.spy(animatedPages._complete); + assert.isUndefined(animatedPages.selected); + var pages = Polymer.dom(animatedPages).children; + animatedPages.addEventListener('neon-animation-finish', function(event) { + if (animatedPages.selected === 0) { + animatedPages.selected = 1; + return; + } + assert.strictEqual(animatedPages.selected, 1); + assert.equal(event.detail.fromPage, pages[0]); + assert.equal(event.detail.toPage, pages[1]); + assert.isTrue(animatedPages._complete.calledTwice); + var a$ = animatedPages._complete.getCall(1).args[0]; + assert.isTrue(a$[0].neonAnimation.isNeonAnimation, 'entry animation is not a registered animation'); + assert.isTrue(a$[1].neonAnimation.isNeonAnimation, 'exit animation is not a registered animation'); + done(); + }); + animatedPages.selected = 0; + }); + }); + </script> + +</body> +</html> diff --git a/catapult/third_party/polymer/components/neon-animation/test/neon-animated-pages.html b/catapult/third_party/polymer/components/neon-animation/test/neon-animated-pages.html new file mode 100644 index 00000000..98220b67 --- /dev/null +++ b/catapult/third_party/polymer/components/neon-animation/test/neon-animated-pages.html @@ -0,0 +1,101 @@ +<!doctype html> +<!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--> +<html> +<head> + + <title>neon-animated-pages tests</title> + + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> + <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"> + + <script src="../../webcomponentsjs/webcomponents-lite.js"></script> + + <script src="../../web-component-tester/browser.js"></script> + <script src="../../test-fixture/test-fixture-mocha.js"></script> + + <link rel="import" href="../../test-fixture/test-fixture.html"> + <link rel="import" href="../neon-animated-pages.html"> + <link rel="import" href="../neon-animatable.html"> + <link rel="import" href="../animations/slide-from-left-animation.html"> + <link rel="import" href="../animations/slide-right-animation.html"> + <link rel="import" href="test-resizable-pages.html"> + +</head> +<body> + + <test-fixture id="basic"> + <template> + <neon-animated-pages> + </neon-animated-pages> + </template> + </test-fixture> + + <test-fixture id="notify-resize"> + <template> + <neon-animated-pages> + <a-resizable-page></a-resizable-page> + <b-resizable-page></b-resizable-page> + <c-resizable-page></c-resizable-page> + </neon-animated-pages> + </template> + </test-fixture> + + <test-fixture id="animate-initial-selection"> + <template> + <neon-animated-pages entry-animation="slide-from-left-animation" exit-animation="slide-right-animation" animate-initial-selection> + <neon-animatable></neon-animatable> + <neon-animatable></neon-animatable> + </neon-animated-pages> + </template> + </test-fixture> + + <script> + suite('basic', function() { + }); + suite('notify-resize', function() { + test('only a destination page recieves a resize event', function(done) { + var animatedPages = fixture('notify-resize'); + var resizables = Polymer.dom(animatedPages).children; + var recieves = {}; + resizables.forEach(function(page) { + page.addEventListener('iron-resize', function(event) { + var pageName = event.currentTarget.tagName; + recieves[pageName] = pageName in recieves ? recieves[pageName] + 1 : 1; + }); + }); + animatedPages.selected = 2; + setTimeout(function() { + assert.deepEqual(recieves, { + 'C-RESIZABLE-PAGE': 1 + }); + done(); + }, 50); + }); + }); + suite('animate-initial-selection', function() { + test('\'neon-animation-finish\' event fired after animating initial selection', function(done) { + var animatedPages = fixture('animate-initial-selection'); + assert.isUndefined(animatedPages.selected); + var pages = Polymer.dom(animatedPages).children; + animatedPages.addEventListener('neon-animation-finish', function(event) { + assert.strictEqual(animatedPages.selected, 0); + assert.isFalse(event.detail.fromPage); + assert.deepEqual(event.detail.toPage, pages[0]); + done(); + }); + animatedPages.selected = 0; + }); + }); + </script> + +</body> +</html> diff --git a/catapult/third_party/polymer/components/neon-animation/test/test-resizable-pages.html b/catapult/third_party/polymer/components/neon-animation/test/test-resizable-pages.html new file mode 100644 index 00000000..7330a1ff --- /dev/null +++ b/catapult/third_party/polymer/components/neon-animation/test/test-resizable-pages.html @@ -0,0 +1,58 @@ +<!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--> + +<link rel="import" href="../../polymer/polymer.html"> +<link rel="import" href="../neon-shared-element-animatable-behavior.html"> +<link rel="import" href="../../iron-resizable-behavior/iron-resizable-behavior.html"> + +<dom-module id="a-resizable-page"> + <template> + </template> +</dom-module> + +<dom-module id="b-resizable-page"> + <template> + </template> +</dom-module> + +<dom-module id="c-resizable-page"> + <template> + </template> +</dom-module> + +<script> +(function() { + + Polymer({ + is: 'a-resizable-page', + behaviors: [ + Polymer.NeonSharedElementAnimatableBehavior, + Polymer.IronResizableBehavior + ] + }); + + Polymer({ + is: 'b-resizable-page', + behaviors: [ + Polymer.NeonSharedElementAnimatableBehavior, + Polymer.IronResizableBehavior + ] + }); + + Polymer({ + is: 'c-resizable-page', + behaviors: [ + Polymer.NeonSharedElementAnimatableBehavior, + Polymer.IronResizableBehavior + ] + }); + +})(); +</script> |