~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/paper-input/test/paper-input-char-counter.html

  • Committer: Didier Roche
  • Date: 2016-05-10 23:09:11 UTC
  • Revision ID: didier.roche@canonical.com-20160510230911-c7xr490zrj3yrzxd
New version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!doctype html>
 
2
<!--
 
3
@license
 
4
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
 
5
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
 
6
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
 
7
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
 
8
Code distributed by Google as part of the polymer project is also
 
9
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
 
10
-->
 
11
<html>
 
12
<head>
 
13
 
 
14
  <title>paper-input-counter tests</title>
 
15
 
 
16
  <meta charset="utf-8">
 
17
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 
18
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
 
19
 
 
20
  <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
 
21
 
 
22
  <script src="../../web-component-tester/browser.js"></script>
 
23
  <script src="../../iron-test-helpers/test-helpers.js"></script>
 
24
 
 
25
  <link rel="import" href="../../iron-input/iron-input.html">
 
26
  <link rel="import" href="../paper-input-container.html">
 
27
  <link rel="import" href="../paper-input-char-counter.html">
 
28
  <link rel="import" href="../paper-textarea.html">
 
29
 
 
30
</head>
 
31
<body>
 
32
 
 
33
  <test-fixture id="counter">
 
34
    <template>
 
35
      <paper-input-container>
 
36
        <label id="l">label</label>
 
37
        <input id="i" value="foobar">
 
38
        <paper-input-char-counter id="c"></paper-input-char-counter>
 
39
      </paper-input-container>
 
40
    </template>
 
41
  </test-fixture>
 
42
 
 
43
  <test-fixture id="counter-with-max">
 
44
    <template>
 
45
      <paper-input-container>
 
46
        <label id="l">label</label>
 
47
        <input id="i" value="foobar" maxlength="10">
 
48
        <paper-input-char-counter id="c"></paper-input-char-counter>
 
49
      </paper-input-container>
 
50
    </template>
 
51
  </test-fixture>
 
52
 
 
53
  <test-fixture id="textarea">
 
54
    <template>
 
55
      <paper-textarea char-counter value="foobar"></paper-textarea>
 
56
    </template>
 
57
  </test-fixture>
 
58
 
 
59
  <test-fixture id="textarea-with-max">
 
60
    <template>
 
61
      <paper-textarea char-counter value="foobar" maxlength="100"></paper-textarea>
 
62
    </template>
 
63
  </test-fixture>
 
64
 
 
65
  <script>
 
66
 
 
67
    suite('basic', function() {
 
68
 
 
69
      test('character counter shows the value length', function() {
 
70
        var container = fixture('counter');
 
71
        var input = Polymer.dom(container).querySelector('#i');
 
72
        var counter = Polymer.dom(container).querySelector('#c');
 
73
        assert.equal(counter._charCounterStr, input.value.length, 'character counter shows input value length');
 
74
      });
 
75
 
 
76
      test('character counter shows the value length with maxlength', function() {
 
77
        var container = fixture('counter-with-max');
 
78
        var input = Polymer.dom(container).querySelector('#i');
 
79
        var counter = Polymer.dom(container).querySelector('#c');
 
80
        assert.equal(counter._charCounterStr, input.value.length + '/' + input.maxLength, 'character counter shows input value length and maxLength');
 
81
      });
 
82
 
 
83
      test('character counter shows the value length with maxlength', function() {
 
84
        var input = fixture('textarea-with-max');
 
85
        forceXIfStamp(input);
 
86
 
 
87
        var counter = Polymer.dom(input.root).querySelector('paper-input-char-counter');
 
88
        assert.ok(counter, 'paper-input-char-counter exists');
 
89
 
 
90
        assert.equal(counter._charCounterStr, input.value.length + '/' + input.inputElement.textarea.getAttribute('maxlength'), 'character counter shows input value length and maxLength');
 
91
      });
 
92
 
 
93
      test('character counter counts new lines in textareas correctly', function() {
 
94
        var input = fixture('textarea');
 
95
        input.value = 'foo\nbar';
 
96
        forceXIfStamp(input);
 
97
 
 
98
        var counter = Polymer.dom(input.root).querySelector('paper-input-char-counter')
 
99
        assert.ok(counter, 'paper-input-char-counter exists');
 
100
 
 
101
        assert.equal(counter._charCounterStr, input.value.length, 'character counter shows the value length');
 
102
      });
 
103
 
 
104
    });
 
105
 
 
106
  </script>
 
107
 
 
108
</body>
 
109
</html>