Added tests for opening a URL.

This commit is contained in:
Guy Kogus 2014-09-22 13:48:15 +01:00 committed by Sergey
parent 6e91c65e74
commit 908311ff7f
6 changed files with 77 additions and 1 deletions

View File

@ -0,0 +1,38 @@
#include "OpenURLTest.h"
OpenURLTest::OpenURLTest()
{
auto label = Label::createWithTTF("Open URL Test", "fonts/arial.ttf", 28);
addChild(label, 0);
label->setPosition(VisibleRect::center().x, VisibleRect::top().y - 50);
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesEnded = CC_CALLBACK_2(OpenURLTest::onTouchesEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
// create a label to display the tip string
_label = Label::createWithTTF("Touch the screen to open\nthe cocos2d-x home page", "fonts/arial.ttf", 22);
_label->setPosition(VisibleRect::center());
addChild(_label, 0);
_label->retain();
}
void OpenURLTest::onTouchesEnded(const std::vector<Touch*>& touches, Event *event)
{
Application::getInstance()->openURL("http://www.cocos2d-x.org/");
}
OpenURLTest::~OpenURLTest()
{
_label->release();
}
void OpenURLTestScene::runThisTest()
{
auto layer = new (std::nothrow) OpenURLTest();
addChild(layer);
Director::getInstance()->replaceScene(this);
layer->release();
}

View File

@ -0,0 +1,24 @@
#ifndef _OPEN_URL_TEST_H_
#define _OPEN_URL_TEST_H_
#include "cocos2d.h"
#include "../testBasic.h"
class OpenURLTest : public Layer
{
public:
OpenURLTest();
~OpenURLTest();
void onTouchesEnded(const std::vector<Touch*>& touches, cocos2d::Event *event);
private:
cocos2d::Label* _label;
};
class OpenURLTestScene : public TestScene
{
public:
virtual void runThisTest();
};
#endif // _OPEN_URL_TEST_H_

View File

@ -104,7 +104,8 @@ Controller g_aTestNames[] = {
{ "Touches", [](){return new PongScene();} },
{ "Transitions", [](){return new TransitionsTestScene();} },
{ "Unit Test", []() { return new UnitTestScene(); }},
{ "UserDefault", []() { return new UserDefaultTestScene(); } },
{ "URL Open Test", []() { return new OpenURLTestScene(); } },
{ "UserDefault", []() { return new UserDefaultTestScene(); } },
{ "Zwoptex", []() { return new ZwoptexTestScene(); } },
};

View File

@ -75,4 +75,6 @@
#include "Camera3DTest/Camera3DTest.h"
#include "BillBoardTest/BillBoardTest.h"
#include "OpenURLTest/OpenURLTest.h"
#endif

View File

@ -218,6 +218,7 @@
<ClCompile Include="..\..\Classes\LabelTest\LabelTestNew.cpp" />
<ClCompile Include="..\..\Classes\NewEventDispatcherTest\NewEventDispatcherTest.cpp" />
<ClCompile Include="..\..\Classes\NewRendererTest\NewRendererTest.cpp" />
<ClCompile Include="..\..\Classes\OpenURLTest\OpenURLTest.cpp" />
<ClCompile Include="..\..\Classes\PerformanceTest\PerformanceAllocTest.cpp" />
<ClCompile Include="..\..\Classes\PerformanceTest\PerformanceContainerTest.cpp" />
<ClCompile Include="..\..\Classes\PerformanceTest\PerformanceEventDispatcherTest.cpp" />
@ -421,6 +422,7 @@
<ClInclude Include="..\..\Classes\LabelTest\LabelTestNew.h" />
<ClInclude Include="..\..\Classes\NewEventDispatcherTest\NewEventDispatcherTest.h" />
<ClInclude Include="..\..\Classes\NewRendererTest\NewRendererTest.h" />
<ClInclude Include="..\..\Classes\OpenURLTest\OpenURLTest.h" />
<ClInclude Include="..\..\Classes\PerformanceTest\PerformanceAllocTest.h" />
<ClInclude Include="..\..\Classes\PerformanceTest\PerformanceContainerTest.h" />
<ClInclude Include="..\..\Classes\PerformanceTest\PerformanceEventDispatcherTest.h" />

View File

@ -325,6 +325,9 @@
<Filter Include="Classes\BillBoardTest">
<UniqueIdentifier>{4dadf399-3bf1-4d35-85d1-d8def766fe0f}</UniqueIdentifier>
</Filter>
<Filter Include="Classes\OpenURLTest">
<UniqueIdentifier>{f3b97ed6-a90e-4abc-b916-f91da5de888d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\Classes\AppDelegate.cpp">
@ -862,6 +865,9 @@
<ClCompile Include="..\..\Classes\BillBoardTest\BillBoardTest.cpp">
<Filter>Classes\BillBoardTest</Filter>
</ClCompile>
<ClCompile Include="..\..\Classes\OpenURLTest\OpenURLTest.cpp">
<Filter>Classes\OpenURLTest</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Classes\AppDelegate.h">
@ -1598,6 +1604,9 @@
<ClInclude Include="..\..\Classes\BillBoardTest\BillBoardTest.h">
<Filter>Classes\BillBoardTest</Filter>
</ClInclude>
<ClInclude Include="..\..\Classes\OpenURLTest\OpenURLTest.h">
<Filter>Classes\OpenURLTest</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\..\external\curl\prebuilt\wp8\arm\libcurl.dll" />