| <!DOCTYPE html> |
| <!-- |
| @license |
| Copyright (C) 2018 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-opacity-diff-mode</title> |
| |
| <link rel="import" href="../node_modules/polymer/polymer.html"> |
| <link rel="import" href="../node_modules/@polymer/test-fixture/test-fixture.html"> |
| <link rel="import" href="../node_modules/iron-test-helpers/iron-test-helpers.html"> |
| <link rel="import" href="./gr-opacity-diff-mode.html"> |
| |
| <script>void(0);</script> |
| |
| <script src="../node_modules/webcomponents.js/webcomponents-lite.min.js"></script> |
| <script src="../node_modules/web-component-tester/browser.js"></script> |
| <script src="../node_modules/@polymer/sinonjs/sinon.js"></script> |
| |
| <test-fixture id='opacity-diff-fixture'> |
| <template> |
| <gr-opacity-diff-mode></gr-opacity-diff-mode> |
| </template> |
| </test-fixture> |
| |
| <script> |
| suite('gr-opacity-diff-tool tests', () => { |
| let element; |
| |
| setup(() => { |
| stub('gr-opacity-diff-mode', { |
| attached() {}, |
| }); |
| element= fixture('opacity-diff-fixture'); |
| }); |
| |
| test('slider changes opacity of image', () => { |
| const arrayOfNumbers = [0.73, 0.5, 0.0]; |
| arrayOfNumbers.forEach(number => { |
| assert.notEqual(element.customStyle['--my-opacity-value'], number); |
| element.$.opacitySlider.value = number; |
| element.handleOpacityChange(); |
| assert.equal(element.customStyle['--my-opacity-value'], number); |
| }); |
| }); |
| |
| test('create the src string for images', () => { |
| element.revisionImage = { |
| type: 'IMG/src', |
| body: 'Zx3Cgffk=', |
| }; |
| const expectedOutcome = 'data:IMG/src;base64, Zx3Cgffk='; |
| assert.equal(element.computeSrcString(element.revisionImage), |
| expectedOutcome); |
| }); |
| }); |
| </script> |