Added Polymer

This commit is contained in:
Thaum
2014-11-26 10:18:35 +00:00
parent 5eea4714b2
commit 3408ba9e8d
1210 changed files with 394645 additions and 47 deletions

View File

@@ -0,0 +1,18 @@
{
"name": "core-tests",
"private": true,
"dependencies": {
"polymer-test-tools": "Polymer/polymer-test-tools#^0.5.0"
},
"version": "0.5.1",
"homepage": "https://github.com/Polymer/core-tests",
"_release": "0.5.1",
"_resolution": {
"type": "version",
"tag": "0.5.1",
"commit": "ea4c9f5b48d6d24f4cbd1e738fb7ee70b78b8fe8"
},
"_source": "git://github.com/Polymer/core-tests.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/core-tests"
}

View File

@@ -0,0 +1,7 @@
DEPRECATED
==========
core-tests
==========
Tests for polymer elements. The tooling is at https://github.com/polymer/polymer-test-tools

View File

@@ -0,0 +1,8 @@
{
"name": "core-tests",
"private": true,
"dependencies": {
"polymer-test-tools": "Polymer/polymer-test-tools#^0.5.0"
},
"version": "0.5.1"
}

View File

@@ -0,0 +1,29 @@
<!doctype html>
<!--
Copyright (c) 2014 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>Core Elements Test Runner</title>
<meta charset="UTF-8">
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="tests/tests.html">
</head>
<body>
<div id="mocha"></div>
</body>
</html>

View File

@@ -0,0 +1,49 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-ajax</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../../polymer-test-tools/tools.html">
<script src="../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-ajax/core-ajax.html">
</head>
<body>
<core-ajax
url="http://gdata.youtube.com/feeds/api/videos/"
params='{"alt":"json", "q":"chrome"}'
handleAs="json"
auto
></core-ajax>
<script>
document.addEventListener('polymer-ready', function() {
var ajax = document.querySelector('core-ajax');
ajax.addEventListener("core-response", function(event) {
assert.isTrue(event.detail.response.feed.entry.length > 0);
done();
});
});
</script>
</body>
</html>

View File

@@ -0,0 +1,68 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-collapse</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../../polymer-test-tools/tools.html">
<script src="../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-collapse/core-collapse.html">
</head>
<body unresolved>
<button onclick="document.querySelector('#collapse').toggle()">toggle collapse</button>
<core-collapse id="collapse" duration="0.1" opened>
<div>
Forma temperiemque cornua sidera dissociata cornua recessit innabilis ligavit: solidumque coeptis nullus caelum sponte phoebe di regat mentisque tanta austro capacius amphitrite sui quin postquam semina fossae liquidum umor galeae coeptis caligine liberioris quin liquidum matutinis invasit posset: flexi glomeravit radiis certis invasit oppida postquam onerosior inclusum dominari opifex terris pace finxit quam aquae nunc sine altae auroram quam habentem homo totidemque scythiam in pondus ensis tegit caecoque poena lapidosos humanas coeperunt poena aetas totidem nec natura aethera locavit caelumque distinxit animalibus phoebe cingebant moderantum porrexerat terrae possedit sua sole diu summaque obliquis melioris orbem
</div>
</core-collapse>
<script>
var delay = 200;
document.addEventListener('polymer-ready', function() {
var c = document.querySelector('#collapse');
// verify take attribute for opened is correct
assert.equal(c.opened, true);
setTimeout(function() {
// get the height for the opened state
var h = getCollapseComputedStyle().height;
// verify the height is not 0px
assert.notEqual(getCollapseComputedStyle().height, '0px');
// close it
c.opened = false;
Platform.flush();
setTimeout(function() {
// verify is closed
assert.notEqual(getCollapseComputedStyle().height, h);
// open it
c.opened = true;
Platform.flush();
setTimeout(function() {
// verify is opened
assert.equal(getCollapseComputedStyle().height, h);
done();
}, delay);
}, delay);
}, delay);
});
function getCollapseComputedStyle() {
var b = document.querySelector('#collapse');
return getComputedStyle(b);
}
</script>
</body>
</html>

View File

@@ -0,0 +1,38 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-localstorage</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../../polymer-test-tools/tools.html">
<script src="../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-localstorage/core-localstorage.html">
</head>
<body>
<core-localstorage id="localstorage" name="polymer-localstorage-test"></core-localstorage>
<script>
document.addEventListener('polymer-ready', function() {
var s = document.querySelector('#localstorage');
var m = 'hello wold';
window.localStorage.setItem(s.name, m);
s.load();
assert.equal(s.value, m);
s.value = 'goodbye';
assert.equal(window.localStorage.getItem(s.name), m);
done();
});
</script>
</body>
</html>

View File

@@ -0,0 +1,55 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-selection-multi</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../../polymer-test-tools/tools.html">
<script src="../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-selection/core-selection.html">
</head>
<body>
<core-selection multi></core-selection>
<script>
document.addEventListener('polymer-ready', function() {
var s = document.querySelector('core-selection');
s.addEventListener("core-select", function(event) {
if (test === 1) {
// check test1
assert.isTrue(event.detail.isSelected);
assert.equal(event.detail.item, '(item1)');
assert.isTrue(s.isSelected(event.detail.item));
assert.equal(s.getSelection().length, 1);
// test2
test++;
s.select('(item2)');
} else if (test === 2) {
// check test2
assert.isTrue(event.detail.isSelected);
assert.equal(event.detail.item, '(item2)');
assert.isTrue(s.isSelected(event.detail.item));
assert.equal(s.getSelection().length, 2);
done();
}
});
// test1
var test = 1;
s.select('(item1)');
});
</script>
</body>
</html>

View File

@@ -0,0 +1,54 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-selection</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../../polymer-test-tools/tools.html">
<script src="../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-selection/core-selection.html">
</head>
<body>
<core-selection></core-selection>
<script>
document.addEventListener('polymer-ready', function() {
var s = document.querySelector('core-selection');
s.addEventListener("core-select", function(event) {
if (test === 1) {
// check test1
assert.isTrue(event.detail.isSelected);
assert.equal(event.detail.item, '(item)');
assert.isTrue(s.isSelected(event.detail.item));
assert.isFalse(s.isSelected('(some_item_not_selected)'));
// test2
test++;
s.select(null);
} else if (test === 2) {
// check test2
assert.isFalse(event.detail.isSelected);
assert.equal(event.detail.item, '(item)');
assert.isFalse(s.isSelected(event.detail.item));
done();
}
});
// test1
var test = 1;
s.select('(item)');
});
</script>
</body>
</html>

View File

@@ -0,0 +1,50 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-selector-activate-event</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../../polymer-test-tools/tools.html">
<script src="../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-selector/core-selector.html">
<style>
.core-selected {
background: #ccc;
}
</style>
</head>
<body>
<core-selector id="selector" selected="0">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</core-selector>
<script>
document.addEventListener('polymer-ready', function() {
var assert = chai.assert;
var s = document.querySelector('#selector');
s.addEventListener("core-activate", function(event) {
assert.equal(event.detail.item, s.children[1]);
assert.equal(s.selected, 1);
done();
});
assert.equal(s.selected, '0');
requestAnimationFrame(function() {
s.children[1].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
});
});
</script>
</body>
</html>

View File

@@ -0,0 +1,105 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-selector-basic</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../../polymer-test-tools/tools.html">
<script src="../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-selector/core-selector.html">
<style>
.core-selected {
background: #ccc;
}
.my-selected {
background: red;
}
</style>
</head>
<body>
<core-selector id="selector1">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</core-selector>
<br><br>
<core-selector id="selector2" selected="item3" selectedClass="my-selected" valueattr="id">
<div id="item1">Item 1</div>
<div id="item2">Item 2</div>
<div id="item3">Item 3</div>
<div id="item4">Item 4</div>
<div id="item5">Item 5</div>
</core-selector>
<script>
var async = requestAnimationFrame;
function oneMutation(node, options, cb) {
var o = new MutationObserver(function() {
cb();
o.disconnect();
});
o.observe(node, options);
}
document.addEventListener('polymer-ready', function() {
var assert = chai.assert;
// selector1
var s = document.querySelector('#selector1');
assert.equal(s.selected, null);
assert.equal(s.selectedClass, 'core-selected');
assert.isFalse(s.multi);
assert.equal(s.valueattr, 'name');
assert.equal(s.items.length, 5);
// selector2
s = document.querySelector('#selector2');
assert.equal(s.selected, "item3");
assert.equal(s.selectedClass, 'my-selected');
// setup listener for core-select event
var selectEventCounter = 0;
s.addEventListener('core-select', function(e) {
if (e.detail.isSelected) {
selectEventCounter++;
// selectedItem and detail.item should be the same
assert.equal(e.detail.item, s.selectedItem);
}
});
// set selected
s.selected = 'item5';
Platform.flush();
setTimeout(function() {
// check core-select event
assert.equal(selectEventCounter, 1);
// check selected class
assert.isTrue(s.children[4].classList.contains('my-selected'));
// check selectedItem
assert.equal(s.selectedItem, s.children[4]);
// selecting the same value shouldn't fire core-select
selectEventCounter = 0;
s.selected = 'item5';
Platform.flush();
// TODO(ffu): would be better to wait for something to happen
// instead of not to happen
setTimeout(function() {
assert.equal(selectEventCounter, 0);
done();
}, 50);
}, 50);
});
</script>
</body>
</html>

View File

@@ -0,0 +1,86 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-selector-multi</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../../polymer-test-tools/tools.html">
<script src="../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-selector/core-selector.html">
<style>
.core-selected {
background: #ccc;
}
</style>
</head>
<body>
<core-selector id="selector" multi>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</core-selector>
<script>
function oneMutation(node, options, cb) {
var o = new MutationObserver(function() {
cb();
o.disconnect();
});
o.observe(node, options);
}
document.addEventListener('polymer-ready', function() {
var assert = chai.assert;
//
var s = document.querySelector('#selector');
assert.equal(s.selected, null);
assert.equal(s.selectedClass, 'core-selected');
assert.isTrue(s.multi);
assert.equal(s.valueattr, 'name');
assert.equal(s.items.length, 5);
// setup listener for core-select event
var selectEventCounter = 0;
s.addEventListener('core-select', function(e) {
if (e.detail.isSelected) {
selectEventCounter++;
} else {
selectEventCounter--;
}
// check selectedItem in core-select event
assert.equal(this.selectedItem.length, selectEventCounter);
});
// set selected
s.selected = [0, 2];
Platform.flush();
setTimeout(function() {
// check core-select event
assert.equal(selectEventCounter, 2);
// check selected class
assert.isTrue(s.children[0].classList.contains('core-selected'));
assert.isTrue(s.children[2].classList.contains('core-selected'));
// check selectedItem
assert.equal(s.selectedItem.length, 2);
assert.equal(s.selectedItem[0], s.children[0]);
assert.equal(s.selectedItem[1], s.children[2]);
// tap on already selected element should unselect it
s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
// check selected
assert.equal(s.selected.length, 1);
assert.isFalse(s.children[0].classList.contains('core-selected'));
done();
}, 50);
});
</script>
</body>
</html>

View File

@@ -0,0 +1,48 @@
<!doctype html>
<!--
Copyright (c) 2014 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>core-shared-lib</title>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../../polymer-test-tools/tools.html">
<script src="../../polymer-test-tools/htmltest.js"></script>
<link rel="import" href="../../core-shared-lib/core-shared-lib.html">
</head>
<body>
<core-shared-lib url="https://apis.google.com/js/client.js?onload=%%callback%%"></core-shared-lib>
<template id="t" bind="{{}}">
<core-shared-lib url="https://apis.google.com/js/client.js?onload=%%callback%%"></core-shared-lib>
</template>
<script>
var count = 0;
addEventListener("core-shared-lib-load", function(event) {
if (++count === 2) {
done();
} else {
assert.isTrue(count < 2);
// request the api again
setTimeout(function() {
document.querySelector('#t').model = {};
}, 100);
}
});
</script>
</body>
</html>

View File

@@ -0,0 +1,46 @@
<!--
Copyright (c) 2014 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-test-tools/tools.html">
<script src="../../polymer-test-tools/mocha-htmltest.js"></script>
<script>
mocha.setup({ui: 'tdd', slow: 1000, timeout: 5000, htmlbase: ''});
htmlSuite('core-ajax', function() {
htmlTest('tests/core-ajax.html');
});
htmlSuite('core-collapse', function() {
htmlTest('tests/core-collapse.html');
});
htmlSuite('core-localstorage', function() {
htmlTest('tests/core-localstorage.html');
});
htmlSuite('core-selection', function() {
htmlTest('tests/core-selection.html');
htmlTest('tests/core-selection-multi.html');
});
htmlSuite('core-selector', function() {
htmlTest('tests/core-selector-basic.html');
htmlTest('tests/core-selector-activate-event.html');
htmlTest('tests/core-selector-multi.html');
});
htmlSuite('core-shared-lib', function() {
htmlTest('tests/core-shared-lib.html');
});
mocha.run();
</script>