Port Android relocation packer to chromium build
[chromium-blink-merge.git] / third_party / polymer / components-chromium / core-selector / test / next-previous.html
blob43a25a2c5d8bb475238ccb3bc8d7afa0275f1b59
1 <!doctype html>
2 <!--
3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9 -->
10 <html>
11 <head>
12 <meta charset="UTF-8">
13 <title>core-selector-next-previous-wrap</title>
14 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
16 <script src="../../webcomponentsjs/webcomponents.js"></script>
17 <script src="../../web-component-tester/browser.js"></script>
19 <link rel="import" href="../core-selector.html">
21 <style>
22 .core-selected {
23 background: #ccc;
25 </style>
27 </head>
28 <body unresolved>
30 <core-selector id="selector" selected="0">
31 <div>Item 1</div>
32 <div>Item 2</div>
33 <div>Item 3</div>
34 </core-selector>
36 <script>
38 var s = document.querySelector('#selector');
40 function assertAndSelect(method, expectedIndex, wrap) {
41 return function(done) {
42 assert.equal(s.selected, expectedIndex);
43 s[method](wrap);
44 flush(done);
48 suite('next/previous', function() {
50 test('selectNext(true) wraps', function(done) {
51 assert.equal(s.selected, 0);
53 async.series([
54 assertAndSelect('selectNext', 0, true),
55 assertAndSelect('selectNext', 1, true),
56 assertAndSelect('selectNext', 2, true),
57 function(done) {
58 assert.equal(s.selected, 0);
59 done();
61 ], done);
62 });
64 test('selectPrevious(true) wraps', function(done) {
65 assert.equal(s.selected, 0);
67 async.series([
68 assertAndSelect('selectPrevious', 0, true),
69 assertAndSelect('selectPrevious', 2, true),
70 assertAndSelect('selectPrevious', 1, true),
71 function(done) {
72 assert.equal(s.selected, 0);
73 done();
75 ], done);
76 });
78 test('selectNext() does not wrap', function(done) {
79 assert.equal(s.selected, 0);
81 async.series([
82 assertAndSelect('selectNext', 0),
83 assertAndSelect('selectNext', 1),
84 assertAndSelect('selectNext', 2),
85 assertAndSelect('selectNext', 2),
86 assertAndSelect('selectNext', 2),
87 function(done) {
88 s.selected = 0;
89 asyncPlatformFlush(done);
91 ], done);
92 });
94 test('selectPrevious() does not wrap', function(done) {
95 assert.equal(s.selected, 0);
96 s.selected = 2;
98 async.series([
99 asyncPlatformFlush,
100 assertAndSelect('selectPrevious', 2),
101 assertAndSelect('selectPrevious', 1),
102 assertAndSelect('selectPrevious', 0),
103 assertAndSelect('selectPrevious', 0),
104 assertAndSelect('selectPrevious', 0),
105 ], done);
110 </script>
112 </body>
113 </html>