diff --git a/tests/js-tests/src/GUITest/UISceneManager.js b/tests/js-tests/src/GUITest/UISceneManager.js index 1090c5efa9..e1067915d9 100644 --- a/tests/js-tests/src/GUITest/UISceneManager.js +++ b/tests/js-tests/src/GUITest/UISceneManager.js @@ -477,6 +477,12 @@ func: function () { return new UIScrollViewTest_Vertical_Multiple(); } + }, + { + title:"UIScrollView Scroll Bar Test", + func: function () { + return new UIScrollViewTest_ScrollBar(); + } } ], "UIPageView": [ diff --git a/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js b/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js index 0ea3fe81db..f5b712264c 100644 --- a/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js +++ b/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js @@ -603,4 +603,48 @@ var UIScrollViewTest_Vertical_Multiple = UIMainLayer.extend({ scrollView.addChild(button_scale9); } } -}); \ No newline at end of file +}); + +var UIScrollViewTest_ScrollBar = UIMainLayer.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("Scroll bar is red, 65% opacity, auto hide time: 5 sec"); + this._topDisplayLabel.setFontSize(14); + this._topDisplayLabel.x = widgetSize.width / 2.0; + this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5; + + this._bottomDisplayLabel.setString(""); + this._bottomDisplayLabel.x = widgetSize.width / 2; + this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3; + + var background = this._widget.getChildByName("background_Panel"); + + // Create the scrollview + var scrollView = new ccui.ScrollView(); + scrollView.setTouchEnabled(true); + scrollView.setBounceEnabled(true); + scrollView.setBackGroundColor(cc.color.GREEN); + scrollView.setBackGroundColorType(ccui.Layout.BG_COLOR_SOLID); + scrollView.setDirection(ccui.ScrollView.DIR_BOTH); + scrollView.setInnerContainerSize(cc.size(480, 320)); + scrollView.setContentSize(cc.size(100, 100)); + var scrollViewSize = scrollView.getContentSize(); + + scrollView.x = (widgetSize.width - background.width) / 2 + (background.width - scrollViewSize.width) / 2; + scrollView.y = (widgetSize.height - background.height) / 2 + (background.height - scrollViewSize.height) / 2; + + this._mainNode.addChild(scrollView); + + scrollView.setScrollBarAutoHideTime(5); + scrollView.setScrollBarColor(cc.color.RED); + scrollView.setScrollBarOpacity(255 * 0.65); + scrollView.setScrollBarWidth(5); + + return true; + } + return false; + } +}); +