axmol/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp

393 lines
15 KiB
C++
Raw Normal View History

2013-09-16 20:54:13 +08:00
#include "UISceneManager.h"
#include "UIScene.h"
#include "UIButtonTest/UIButtonTest.h"
#include "UICheckBoxTest/UICheckBoxTest.h"
#include "UISliderTest/UISliderTest.h"
#include "UIImageViewTest/UIImageViewTest.h"
#include "UILoadingBarTest/UILoadingBarTest.h"
2014-03-04 16:51:35 +08:00
#include "UITextAtlasTest/UITextAtlasTest.h"
#include "UITextTest/UITextTest.h"
#include "UITextBMFontTest/UITextBMFontTest.h"
2013-09-16 20:54:13 +08:00
#include "UITextFieldTest/UITextFieldTest.h"
2013-12-23 15:35:35 +08:00
#include "UILayoutTest/UILayoutTest.h"
2013-09-16 20:54:13 +08:00
#include "UIScrollViewTest/UIScrollViewTest.h"
#include "UIPageViewTest/UIPageViewTest.h"
#include "UIListViewTest/UIListViewTest.h"
2013-12-23 15:35:35 +08:00
#include "UIWidgetAddNodeTest/UIWidgetAddNodeTest.h"
2014-03-06 20:52:29 +08:00
#include "UIRichTextTest/UIRichTextTest.h"
#include "UIFocusTest/UIFocusTest.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
2014-05-09 11:30:07 +08:00
#include "UIVideoPlayerTest/UIVideoPlayerTest.h"
#endif
2014-07-29 14:33:22 +08:00
#include "UIScale9SpriteTest.h"
2013-12-23 15:35:35 +08:00
/*
#include "UISwitchTest/UISwitchTest.h"
2014-03-04 16:51:35 +08:00
*/
/*
2013-12-23 15:35:35 +08:00
#include "UIProgressTimerTest/UIProgressTimerTest.h"
2014-03-04 16:51:35 +08:00
*/
/*
2013-12-23 15:35:35 +08:00
#include "UIPotentiometerTest/UIPotentiometerTest.h"
*/
2014-03-04 16:51:35 +08:00
/*
#include "UIGridViewTest/UIGridViewTest.h"
*/
/*
#include "UIPickerViewTest/UIPickerViewTest.h"
*/
2013-09-16 20:54:13 +08:00
USING_NS_CC;
static const char* s_testArray[] =
{
"UIButtonTest",
"UIButtonTest_Scale9",
"UIButtonTest_PressedAction",
2013-12-23 15:35:35 +08:00
"UIButtonTest_Title",
"UIButtonTest_RemoveSelf",
2013-09-16 20:54:13 +08:00
"UICheckBoxTest",
"UISliderTest",
"UISliderTest_Scale9",
2013-12-23 15:35:35 +08:00
/*
"UIPotentiometerTest",
2014-03-04 16:51:35 +08:00
*/
/*
2013-12-23 15:35:35 +08:00
"UISwitchTest_Horizontal",
"UISwitchTest_Vertical",
"UISwitchTest_VerticalAndTitleVertical",
*/
2013-09-16 20:54:13 +08:00
"UIImageViewTest",
"UIImageViewTest_Scale9",
"UIImageViewTest_ContentSize",
2013-09-16 20:54:13 +08:00
"UILoadingBarTest_Left",
"UILoadingBarTest_Right",
"UILoadingBarTest_Left_Scale9",
"UILoadingBarTest_Right_Scale9",
2013-12-23 15:35:35 +08:00
/*
"UIProgressTimerTest_Radial",
"UIProgressTimerTest_Horizontal",
"UIProgressTimerTest_Vertical",
"UIProgressTimerTest_RadialMidpointChanged",
"UIProgressTimerTest_BarVarious",
"UIProgressTimerTest_BarTintAndFade",
"UIProgressTimerTest_WithSpriteFrame",
*/
2014-03-04 16:51:35 +08:00
"UITextAtlasTest",
"UITextTest",
"UITextTest_LineWrap",
2014-06-09 14:34:46 +08:00
2013-12-23 15:35:35 +08:00
"UILabelTest_Effect",
2014-06-09 14:34:46 +08:00
2014-03-04 16:51:35 +08:00
"UITextTest_TTF",
"UITextBMFontTest",
2013-09-16 20:54:13 +08:00
"UITextFieldTest",
"UITextFieldTest_MaxLength",
"UITextFieldTest_Password",
2014-03-04 17:06:12 +08:00
"UITextFieldTest_LineWrap",
2014-07-14 14:29:28 +08:00
"UITextFieldTest_TrueTypeFont",
2013-12-23 15:35:35 +08:00
"UILayoutTest",
"UILayoutTest_Color",
"UILayoutTest_Gradient",
"UILayoutTest_BackGroundImage",
"UILayoutTest_BackGroundImage_Scale9",
"UILayoutTest_Layout_Linear_Vertical",
"UILayoutTest_Layout_Linear_Horizontal",
"UILayoutTest_Layout_Relative_Align_Parent",
"UILayoutTest_Layout_Relative_Location",
/*
"UILayoutTest_Layout_Grid",
*/
2013-09-16 20:54:13 +08:00
"UIScrollViewTest_Vertical",
"UIScrollViewTest_Horizontal",
2013-12-23 15:35:35 +08:00
"UIScrollViewTest_Both",
"UIScrollViewTest_ScrollToPercentBothDirection",
"UIScrollViewTest_ScrollToPercentBothDirection_Bounce",
2014-07-07 15:31:06 +08:00
"UIPageViewTest",
"UIPageViewButtonTest",
2013-09-16 20:54:13 +08:00
"UIListViewTest_Vertical",
"UIListViewTest_Horizontal",
2013-12-23 15:35:35 +08:00
/*
"UIGridViewTest_Mode_Column",
"UIGridViewTest_Mode_Row",
2014-03-04 16:51:35 +08:00
*/
/*
2013-12-23 15:35:35 +08:00
"UIPickerViewTest_Vertical",
"UIPickerViewTest_Horizontal",
*/
"UIWidgetAddNodeTest",
2014-03-06 20:52:29 +08:00
"UIRichTextTest",
"UIFocusTest-HBox",
2014-05-06 14:38:45 +08:00
"UIFocusTest-VBox",
2014-05-07 11:40:01 +08:00
"UIFocusTest-NestedLayout1",
2014-05-07 18:27:05 +08:00
"UIFocusTest-NestedLayout2",
"UIFocusTest-NestedLayout3",
2014-05-20 17:56:52 +08:00
"UIFocusTest-ListView",
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
2014-07-29 15:25:50 +08:00
"UIVideoPlayerTest",
#endif
2014-07-29 14:33:22 +08:00
"UIScale9SpriteTest",
"UIScale9SpriteHierarchialTest",
"UIScale9SpriteTouchTest",
"UIS9BatchNodeBasic",
"UIS9FrameNameSpriteSheet",
"UIS9FrameNameSpriteSheetRotated",
"UIS9BatchNodeScaledNoInsets",
"UIS9FrameNameSpriteSheetScaledNoInsets",
"UIS9FrameNameSpriteSheetRotatedScaledNoInsets",
"UIS9BatchNodeScaleWithCapInsets",
"UIS9FrameNameSpriteSheetInsets",
"UIS9FrameNameSpriteSheetInsetsScaled",
"UIS9FrameNameSpriteSheetRotatedInsets",
"UIS9_TexturePacker",
"UIS9FrameNameSpriteSheetRotatedInsetsScaled",
"UIS9FrameNameSpriteSheetRotatedSetCapInsetLater",
"UIS9CascadeOpacityAndColor",
"UIS9ZOrder",
"UIS9Flip",
2013-09-16 20:54:13 +08:00
};
static UISceneManager *sharedInstance = nullptr;
2013-09-16 20:54:13 +08:00
UISceneManager::UISceneManager()
{
2013-12-23 15:35:35 +08:00
_currentUISceneId = kUIButtonTest;
2013-09-16 20:54:13 +08:00
}
UISceneManager::~UISceneManager()
{
}
UISceneManager * UISceneManager::sharedUISceneManager()
{
if (sharedInstance == nullptr)
2013-09-16 20:54:13 +08:00
{
sharedInstance = new UISceneManager();
}
return sharedInstance;
}
void UISceneManager::purgeUISceneManager()
{
CC_SAFE_DELETE(sharedInstance);
}
Scene *UISceneManager::nextUIScene()
{
2013-12-23 15:35:35 +08:00
_currentUISceneId = _currentUISceneId + 1;
if (_currentUISceneId > _maxUISceneId)
{
_currentUISceneId = _minUISceneId;
}
2013-09-16 20:54:13 +08:00
return currentUIScene();
}
Scene *UISceneManager::previousUIScene()
{
2013-12-23 15:35:35 +08:00
_currentUISceneId = _currentUISceneId - 1;
if (_currentUISceneId < _minUISceneId)
2013-09-16 20:54:13 +08:00
{
2013-12-23 15:35:35 +08:00
_currentUISceneId = _maxUISceneId;
2013-09-16 20:54:13 +08:00
}
return currentUIScene();
}
Scene *UISceneManager::currentUIScene()
{
2013-12-23 15:35:35 +08:00
switch (_currentUISceneId)
2013-09-16 20:54:13 +08:00
{
case kUIButtonTest:
2013-12-23 15:35:35 +08:00
return UIButtonTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIButtonTest_Scale9:
2013-12-23 15:35:35 +08:00
return UIButtonTest_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIButtonTest_PressedAction:
2013-12-23 15:35:35 +08:00
return UIButtonTest_PressedAction::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUIButtonTest_Title:
return UIButtonTest_Title::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIButtonTest_RemoveSelf:
2014-07-25 14:40:58 +08:00
return UIButtonTestRemoveSelf::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUICheckBoxTest:
2013-12-23 15:35:35 +08:00
return UICheckBoxTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUISliderTest:
2013-12-23 15:35:35 +08:00
return UISliderTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUISliderTest_Scale9:
2013-12-23 15:35:35 +08:00
return UISliderTest_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIImageViewTest:
2013-12-23 15:35:35 +08:00
return UIImageViewTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIImageViewTest_Scale9:
2013-12-23 15:35:35 +08:00
return UIImageViewTest_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIImageViewTest_ContentSize:
return UIImageViewTest_ContentSize::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUILoadingBarTest_Left:
2013-12-23 15:35:35 +08:00
return UILoadingBarTest_Left::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUILoadingBarTest_Right:
2013-12-23 15:35:35 +08:00
return UILoadingBarTest_Right::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUILoadingBarTest_Left_Scale9:
2013-12-23 15:35:35 +08:00
return UILoadingBarTest_Left_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUILoadingBarTest_Right_Scale9:
2013-12-23 15:35:35 +08:00
return UILoadingBarTest_Right_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-03-04 16:51:35 +08:00
case kUITextAtlasTest:
return UITextAtlasTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2014-03-04 16:51:35 +08:00
case kUITextBMFontTest:
return UITextBMFontTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2014-03-04 16:51:35 +08:00
case kUITextTest:
return UITextTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-12-23 15:35:35 +08:00
2014-03-04 16:51:35 +08:00
case kUITextTest_LineWrap:
return UITextTest_LineWrap::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-12-23 15:35:35 +08:00
2014-06-09 14:34:46 +08:00
2013-12-23 15:35:35 +08:00
case kUILabelTest_Effect:
return UILabelTest_Effect::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-06-09 14:34:46 +08:00
2013-09-16 20:54:13 +08:00
2014-03-04 16:51:35 +08:00
case kUITextTest_TTF:
return UITextTest_TTF::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUITextFieldTest:
2013-12-23 15:35:35 +08:00
return UITextFieldTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUITextFieldTest_MaxLength:
2013-12-23 15:35:35 +08:00
return UITextFieldTest_MaxLength::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUITextFieldTest_Password:
2013-12-23 15:35:35 +08:00
return UITextFieldTest_Password::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2014-03-04 16:51:35 +08:00
case kUITextFieldTest_LineWrap:
return UITextFieldTest_LineWrap::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-07-14 14:29:28 +08:00
case kUITextFieldTest_TrueTypeFont:
return UITextFieldTest_TrueTypeFont::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-12-23 15:35:35 +08:00
case kUILayoutTest:
return UILayoutTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_Color:
return UILayoutTest_Color::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_Gradient:
return UILayoutTest_Gradient::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_BackGroundImage:
return UILayoutTest_BackGroundImage::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_BackGroundImage_Scale9:
return UILayoutTest_BackGroundImage_Scale9::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_Layout_Linear_Vertical:
return UILayoutTest_Layout_Linear_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUILayoutTest_Layout_Linear_Horizontal:
return UILayoutTest_Layout_Linear_Horizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUILayoutTest_Layout_Relative_Align_Parent:
return UILayoutTest_Layout_Relative_Align_Parent::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUILayoutTest_Layout_Relative_Location:
return UILayoutTest_Layout_Relative_Location::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIScrollViewTest_Vertical:
2013-12-23 15:35:35 +08:00
return UIScrollViewTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIScrollViewTest_Horizontal:
2013-12-23 15:35:35 +08:00
return UIScrollViewTest_Horizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIScrollViewTest_Both:
return UIScrollViewTest_Both::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIScrollViewTest_ScrollToPercentBothDirection:
return UIScrollViewTest_ScrollToPercentBothDirection::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIScrollViewTest_ScrollToPercentBothDirection_Bounce:
return UIScrollViewTest_ScrollToPercentBothDirection_Bounce::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIPageViewTest:
2013-12-23 15:35:35 +08:00
return UIPageViewTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-07-07 15:31:06 +08:00
case kUIPageViewButtonTest:
return UIPageViewButtonTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIListViewTest_Vertical:
2013-12-23 15:35:35 +08:00
return UIListViewTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
case kUIListViewTest_Horizontal:
2013-12-23 15:35:35 +08:00
return UIListViewTest_Horizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
2013-12-23 15:35:35 +08:00
case kUIWidgetAddNodeTest:
return UIWidgetAddNodeTest::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-03-06 20:52:29 +08:00
case kUIRichTextTest:
return UIRichTextTest::sceneWithTitle(s_testArray[_currentUISceneId]);
case KUIFocusTest_HBox:
return UIFocusTestHorizontal::sceneWithTitle(s_testArray[_currentUISceneId]);
case KUIFocusTest_VBox:
return UIFocusTestVertical::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-05-06 14:38:45 +08:00
case KUIFocusTest_NestedLayout1:
return UIFocusTestNestedLayout1::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-05-07 11:40:01 +08:00
case KUIFocusTest_NestedLayout2:
return UIFocusTestNestedLayout2::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-05-07 18:27:05 +08:00
case KUIFocusTest_NestedLayout3:
return UIFocusTestNestedLayout3::sceneWithTitle(s_testArray[_currentUISceneId]);
2014-05-20 17:56:52 +08:00
case kUIFocusTest_ListView:
return UIFocusTestListView::sceneWithTitle(s_testArray[_currentUISceneId]);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
2014-05-09 11:30:07 +08:00
case kUIVideoPlayerTest:
return VideoPlayerTest::sceneWithTitle(s_testArray[_currentUISceneId]);
#endif
2014-07-29 14:33:22 +08:00
case kUIScale9SpriteTest:
return UIScale9SpriteTest::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIScale9SpriteHierarchialTest:
return UIScale9SpriteHierarchialTest::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIScale9SpriteTouchTest:
return UIScale9SpriteTouchTest::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9BatchNodeBasic:
return UIS9BatchNodeBasic::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9FrameNameSpriteSheet:
return UIS9FrameNameSpriteSheet::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9FrameNameSpriteSheetRotated:
return UIS9FrameNameSpriteSheetRotated::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9BatchNodeScaledNoInsets:
return UIS9BatchNodeScaledNoInsets::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9FrameNameSpriteSheetScaledNoInsets:
return UIS9FrameNameSpriteSheetScaledNoInsets::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9FrameNameSpriteSheetRotatedScaledNoInsets:
return UIS9FrameNameSpriteSheetRotatedScaledNoInsets::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9BatchNodeScaleWithCapInsets:
return UIS9BatchNodeScaleWithCapInsets::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9FrameNameSpriteSheetInsets:
return UIS9FrameNameSpriteSheetInsets::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9FrameNameSpriteSheetInsetsScaled:
return UIS9FrameNameSpriteSheetInsetsScaled::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9FrameNameSpriteSheetRotatedInsets:
return UIS9FrameNameSpriteSheetRotatedInsets::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9_TexturePacker:
return UIS9_TexturePacker::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9FrameNameSpriteSheetRotatedInsetsScaled:
return UIS9FrameNameSpriteSheetRotatedInsetsScaled::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9FrameNameSpriteSheetRotatedSetCapInsetLater:
return UIS9FrameNameSpriteSheetRotatedSetCapInsetLater::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9CascadeOpacityAndColor:
return UIS9CascadeOpacityAndColor::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9ZOrder:
return UIS9ZOrder::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIS9Flip:
return UIS9Flip::sceneWithTitle(s_testArray[_currentUISceneId]);
2013-09-16 20:54:13 +08:00
}
return nullptr;
}