Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: third_party/polymer/v0_8/components-chromium/iron-selector/test/activate-event.html

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rerun reproduce.sh Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v0_8/components-chromium/iron-selector/test/activate-event.html
diff --git a/third_party/polymer/v0_8/components-chromium/iron-selector/test/activate-event.html b/third_party/polymer/v0_8/components-chromium/iron-selector/test/activate-event.html
new file mode 100644
index 0000000000000000000000000000000000000000..f41c2ba9c0239051ddc7a9881acabe169aadf3b9
--- /dev/null
+++ b/third_party/polymer/v0_8/components-chromium/iron-selector/test/activate-event.html
@@ -0,0 +1,138 @@
+<!doctype html>
+<!--
+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>iron-selector-activate-event</title>
+ <meta charset="UTF-8">
+
+ <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="../iron-selector.html">
+
+ <style>
+ .iron-selected {
+ background: #ccc;
+ }
+ </style>
+
+</head>
+<body>
+
+ <test-fixture id="test">
+ <template>
+ <iron-selector id="selector" selected="0">
+ <div>Item 0</div>
+ <div>Item 1</div>
+ <div>Item 2</div>
+ <div>Item 3</div>
+ <div>Item 4</div>
+ </iron-selector>
+ </template>
+ </test-fixture>
+
+ <script>
+
+ suite('activate event', function() {
+
+ var s;
+
+ setup(function () {
+ s = fixture('test');
+ });
+
+ test('activates on click', function() {
+ assert.equal(s.selected, '0');
+
+ // select Item 1
+ s.children[1].dispatchEvent(new CustomEvent('click', {bubbles: true}));
+ assert.equal(s.selected, '1');
+ });
+
+ test('activates on click and fires iron-activate', function(done) {
+ assert.equal(s.selected, '0');
+
+ // attach iron-activate listener
+ s.addEventListener("iron-activate", function(event) {
+ assert.equal(event.detail.selected, '1');
+ assert.equal(event.detail.item, s.children[1]);
+ done();
+ });
+
+ // select Item 1
+ s.children[1].dispatchEvent(new CustomEvent('click', {bubbles: true}));
+ });
+
+ test('click on already selected and fires iron-activate', function(done) {
+ assert.equal(s.selected, '0');
+
+ // attach iron-activate listener
+ s.addEventListener("iron-activate", function(event) {
+ assert.equal(event.detail.selected, '0');
+ assert.equal(event.detail.item, s.children[0]);
+ done();
+ });
+
+ // select Item 0
+ s.children[0].dispatchEvent(new CustomEvent('click', {bubbles: true}));
+ });
+
+ test('activates on mousedown', function() {
+ // set activateEvent to mousedown
+ s.activateEvent = 'mousedown';
+ // select Item 2
+ s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true}));
+ assert.equal(s.selected, '2');
+ });
+
+ test('activates on mousedown and fires iron-activate', function(done) {
+ // attach iron-activate listener
+ s.addEventListener("iron-activate", function(event) {
+ assert.equal(event.detail.selected, '2');
+ assert.equal(event.detail.item, s.children[2]);
+ done();
+ });
+
+ // set activateEvent to mousedown
+ s.activateEvent = 'mousedown';
+ // select Item 2
+ s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true}));
+ });
+
+ test('no activation', function() {
+ assert.equal(s.selected, '0');
+ // set activateEvent to null
+ s.activateEvent = null;
+ // select Item 2
+ s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true}));
+ assert.equal(s.selected, '0');
+ });
+
+ test('activates on click and preventDefault', function() {
+ // attach iron-activate listener
+ s.addEventListener("iron-activate", function(event) {
+ event.preventDefault();
+ });
+ // select Item 2
+ s.children[2].dispatchEvent(new CustomEvent('click', {bubbles: true}));
+ // shouldn't got selected since we preventDefault in iron-activate
+ assert.equal(s.selected, '0');
+ });
+
+ });
+
+ </script>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698