| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | 'use strict';
|
| |
|
| | goog.require('goog.testing');
|
| |
|
| | function widgetdiv_testHelper_makeBBox(left, top, width, height) {
|
| | return {
|
| | left: left,
|
| | right: left + width,
|
| | top: top,
|
| | bottom: top + height
|
| | };
|
| | }
|
| |
|
| | function widgetdiv_testHelper_makeSize(width, height) {
|
| | return {
|
| | width: width,
|
| | height: height
|
| | };
|
| | }
|
| |
|
| | var widgetDiv_test_viewport = widgetdiv_testHelper_makeBBox(0, 0, 1000, 1000);
|
| | var widgetDiv_test_widgetSize = widgetdiv_testHelper_makeSize(100, 100);
|
| |
|
| |
|
| | var widgetDiv_test_anchorSize = 90;
|
| |
|
| | function widgetdiv_testHelper_makeAnchor(left, top) {
|
| | return {
|
| | left: left,
|
| | right: left + widgetDiv_test_anchorSize,
|
| | top: top,
|
| | bottom: top + widgetDiv_test_anchorSize
|
| | };
|
| | }
|
| |
|
| | function test_widgetDiv_topConflict() {
|
| | var anchorTop = 50;
|
| |
|
| | var anchorBBox = widgetdiv_testHelper_makeAnchor(500, anchorTop);
|
| |
|
| |
|
| | var calculated = Blockly.WidgetDiv.calculateY_(widgetDiv_test_viewport,
|
| | anchorBBox, widgetDiv_test_widgetSize);
|
| | assertEquals(anchorTop + widgetDiv_test_anchorSize, calculated);
|
| | }
|
| |
|
| | function test_widgetDiv_bottomConflict() {
|
| | var anchorTop = 900;
|
| |
|
| | var anchorBBox = widgetdiv_testHelper_makeAnchor(500, anchorTop);
|
| |
|
| |
|
| | var calculated = Blockly.WidgetDiv.calculateY_(widgetDiv_test_viewport,
|
| | anchorBBox, widgetDiv_test_widgetSize);
|
| | assertEquals(anchorTop - widgetDiv_test_widgetSize.height, calculated);
|
| | }
|
| |
|
| | function test_widgetDiv_noYConflict() {
|
| | var anchorTop = 500;
|
| |
|
| | var anchorBBox = widgetdiv_testHelper_makeAnchor(500, anchorTop);
|
| |
|
| |
|
| | var calculated = Blockly.WidgetDiv.calculateY_(widgetDiv_test_viewport,
|
| | anchorBBox, widgetDiv_test_widgetSize);
|
| | assertEquals(anchorTop + widgetDiv_test_anchorSize, calculated);
|
| | }
|
| |
|
| |
|
| | function test_widgetDiv_leftConflict_LTR() {
|
| | var anchorLeft = 50;
|
| |
|
| | var anchorBBox = widgetdiv_testHelper_makeAnchor(anchorLeft, 500);
|
| |
|
| |
|
| | var calculated = Blockly.WidgetDiv.calculateX_(widgetDiv_test_viewport,
|
| | anchorBBox, widgetDiv_test_widgetSize, false );
|
| | assertEquals(anchorLeft, calculated);
|
| | }
|
| |
|
| | function test_widgetDiv_rightConflict_LTR() {
|
| | var anchorLeft = 950;
|
| |
|
| | var anchorBBox = widgetdiv_testHelper_makeAnchor(anchorLeft, 500);
|
| |
|
| |
|
| |
|
| | var calculated = Blockly.WidgetDiv.calculateX_(widgetDiv_test_viewport,
|
| | anchorBBox, widgetDiv_test_widgetSize, false );
|
| | assertEquals(1000 - widgetDiv_test_widgetSize.width, calculated);
|
| | }
|
| |
|
| | function test_widgetDiv_noXConflict_LTR() {
|
| | var anchorLeft = 500;
|
| |
|
| | var anchorBBox = widgetdiv_testHelper_makeAnchor(anchorLeft, 500);
|
| |
|
| | var calculated = Blockly.WidgetDiv.calculateX_(widgetDiv_test_viewport,
|
| | anchorBBox, widgetDiv_test_widgetSize, false );
|
| | assertEquals(anchorLeft, calculated);
|
| | }
|
| |
|
| | function test_widgetDiv_leftConflict_RTL() {
|
| | var anchorLeft = 10;
|
| |
|
| | var anchorBBox = widgetdiv_testHelper_makeAnchor(anchorLeft, 500);
|
| |
|
| |
|
| | var calculated = Blockly.WidgetDiv.calculateX_(widgetDiv_test_viewport,
|
| | anchorBBox, widgetDiv_test_widgetSize, true );
|
| | assertEquals(0, calculated);
|
| | }
|
| |
|
| | function test_widgetDiv_rightConflict_RTL() {
|
| | var anchorLeft = 950;
|
| |
|
| | var anchorBBox = widgetdiv_testHelper_makeAnchor(anchorLeft, 500);
|
| |
|
| |
|
| |
|
| | var calculated = Blockly.WidgetDiv.calculateX_(widgetDiv_test_viewport,
|
| | anchorBBox, widgetDiv_test_widgetSize, true );
|
| | assertEquals(1000 - widgetDiv_test_widgetSize.width, calculated);
|
| | }
|
| |
|
| | function test_widgetDiv_noXConflict_RTL() {
|
| | var anchorLeft = 500;
|
| |
|
| | var anchorBBox = widgetdiv_testHelper_makeAnchor(anchorLeft, 500);
|
| |
|
| | var calculated = Blockly.WidgetDiv.calculateX_(widgetDiv_test_viewport,
|
| | anchorBBox, widgetDiv_test_widgetSize, true );
|
| | assertEquals(anchorBBox.right - widgetDiv_test_widgetSize.width, calculated);
|
| | }
|
| |
|
| |
|