
Gr-tooltip is used for displaying the score explanation. In order to have gr-tooltip being applied, gr-label component was introduced as a <span> tag replacement. Gr-tooltip bug fixes: - Tooltip arrow now moves sideways if toolip was shown close to left window side. - Tooltip positioning was broken anywhere bug in fixed container's child. - Positioning math updated to use standart getBoundingClientRect instead of DOM traversal. Feature: Issue 4101 Change-Id: If62ecff33535b910b311c984993e402c6dc36be7
142 lines
4.6 KiB
HTML
142 lines
4.6 KiB
HTML
<!DOCTYPE html>
|
|
<!--
|
|
Copyright (C) 2016 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
|
<title>gr-api-interface</title>
|
|
|
|
<script src="../../../bower_components/webcomponentsjs/webcomponents.min.js"></script>
|
|
<script src="../../../bower_components/web-component-tester/browser.js"></script>
|
|
<link rel="import" href="gr-js-api-interface.html">
|
|
|
|
<test-fixture id="basic">
|
|
<template>
|
|
<gr-js-api-interface></gr-js-api-interface>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<script>
|
|
suite('gr-js-api-interface tests', function() {
|
|
var element;
|
|
var plugin;
|
|
var errorStub;
|
|
var throwErrFn = function() {
|
|
throw Error('Unfortunately, this handler has stopped');
|
|
};
|
|
|
|
setup(function() {
|
|
stub('gr-rest-api-interface', {
|
|
getAccount: function() {
|
|
return Promise.resolve({name: 'Judy Hopps'});
|
|
},
|
|
});
|
|
element = fixture('basic');
|
|
errorStub = sinon.stub(console, 'error');
|
|
Gerrit.install(function(p) { plugin = p; }, '0.1',
|
|
'http://test.com/plugins/testplugin/static/test.js');
|
|
});
|
|
|
|
teardown(function() {
|
|
element._removeEventCallbacks();
|
|
plugin = null;
|
|
errorStub.restore();
|
|
});
|
|
|
|
test('url', function() {
|
|
assert.equal(plugin.url(), 'http://test.com/plugins/testplugin/');
|
|
assert.equal(plugin.url('/static/test.js'),
|
|
'http://test.com/plugins/testplugin/static/test.js');
|
|
});
|
|
|
|
test('history event', function(done) {
|
|
plugin.on(element.EventType.HISTORY, throwErrFn);
|
|
plugin.on(element.EventType.HISTORY, function(path) {
|
|
assert.equal(path, '/path/to/awesomesauce');
|
|
assert.isTrue(errorStub.calledOnce);
|
|
done();
|
|
});
|
|
element.handleEvent(element.EventType.HISTORY,
|
|
{path: '/path/to/awesomesauce'});
|
|
});
|
|
|
|
test('showchange event', function(done) {
|
|
var testChange = {
|
|
_number: 42,
|
|
revisions: {
|
|
def: {_number: 2},
|
|
abc: {_number: 1},
|
|
},
|
|
};
|
|
plugin.on(element.EventType.SHOW_CHANGE, throwErrFn);
|
|
plugin.on(element.EventType.SHOW_CHANGE, function(change, revision) {
|
|
assert.deepEqual(change, testChange);
|
|
assert.deepEqual(revision, testChange.revisions.abc);
|
|
assert.isTrue(errorStub.calledOnce);
|
|
done();
|
|
});
|
|
element.handleEvent(element.EventType.SHOW_CHANGE,
|
|
{change: testChange, patchNum: 1});
|
|
});
|
|
|
|
test('comment event', function(done) {
|
|
var testCommentNode = {foo: 'bar'};
|
|
plugin.on(element.EventType.COMMENT, throwErrFn);
|
|
plugin.on(element.EventType.COMMENT, function(commentNode) {
|
|
assert.deepEqual(commentNode, testCommentNode);
|
|
assert.isTrue(errorStub.calledOnce);
|
|
done();
|
|
});
|
|
element.handleEvent(element.EventType.COMMENT, {node: testCommentNode});
|
|
});
|
|
|
|
test('labelchange event', function(done) {
|
|
var testChange = {_number: 42};
|
|
plugin.on(element.EventType.LABEL_CHANGE, throwErrFn);
|
|
plugin.on(element.EventType.LABEL_CHANGE, function(change) {
|
|
assert.deepEqual(change, testChange);
|
|
assert.isTrue(errorStub.calledOnce);
|
|
done();
|
|
});
|
|
element.handleEvent(element.EventType.LABEL_CHANGE, {change: testChange});
|
|
});
|
|
|
|
test('submitchange', function() {
|
|
plugin.on(element.EventType.SUBMIT_CHANGE, throwErrFn);
|
|
plugin.on(element.EventType.SUBMIT_CHANGE, function() { return true; });
|
|
assert.isTrue(element.canSubmitChange());
|
|
assert.isTrue(errorStub.calledOnce);
|
|
plugin.on(element.EventType.SUBMIT_CHANGE, function() { return false; });
|
|
plugin.on(element.EventType.SUBMIT_CHANGE, function() { return true; });
|
|
assert.isFalse(element.canSubmitChange());
|
|
assert.isTrue(errorStub.calledTwice);
|
|
});
|
|
|
|
test('versioning', function() {
|
|
var callback = sinon.spy();
|
|
Gerrit.install(callback, '0.0pre-alpha');
|
|
assert(callback.notCalled);
|
|
});
|
|
|
|
test('getAccount', function(done) {
|
|
Gerrit.getLoggedIn().then(function(loggedIn) {
|
|
assert.isTrue(loggedIn);
|
|
done();
|
|
});
|
|
});
|
|
|
|
});
|
|
</script>
|