2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2022-10-01 16:24:52 +08:00
|
|
|
https://axmolengine.github.io/
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
#ifndef __TEXT_INPUT_TEST_H__
|
|
|
|
#define __TEXT_INPUT_TEST_H__
|
|
|
|
|
2013-06-12 07:30:05 +08:00
|
|
|
#include "../BaseTest.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
class KeyboardNotificationLayer;
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(TextInputTests);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// KeyboardNotificationLayer for test IME keyboard notification.
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
class KeyboardNotificationLayer : public TestCase, public axis::IMEDelegate
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
KeyboardNotificationLayer();
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onClickTrackNode(bool bClicked, const axis::Vec2& touchPos) = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void keyboardWillShow(axis::IMEKeyboardNotificationInfo& info) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
bool onTouchBegan(axis::Touch* touch, axis::Event* event);
|
|
|
|
void onTouchEnded(axis::Touch* touch, axis::Event* event);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Node* _trackNode;
|
|
|
|
axis::Vec2 _beginPos;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextFieldTTFDefaultTest for test TextFieldTTF default behavior.
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TextFieldTTFDefaultTest : public KeyboardNotificationLayer
|
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(TextFieldTTFDefaultTest);
|
2012-04-19 14:35:52 +08:00
|
|
|
// KeyboardNotificationLayer
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onClickTrackNode(bool bClicked, const axis::Vec2& touchPos) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// Layer
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextFieldTTFActionTest
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
class TextFieldTTFActionTest : public KeyboardNotificationLayer, public axis::TextFieldDelegate
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::TextFieldTTF* _textField;
|
|
|
|
axis::Action* _textFieldAction;
|
2021-12-28 16:06:23 +08:00
|
|
|
bool _action;
|
|
|
|
size_t _charLimit; // the textfield max char limit
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(TextFieldTTFActionTest);
|
2021-12-28 16:06:23 +08:00
|
|
|
void callbackRemoveNodeWhenDidAction(Node* node);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// KeyboardNotificationLayer
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onClickTrackNode(bool bClicked, const axis::Vec2& touchPos) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// Layer
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// TextFieldDelegate
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual bool onTextFieldAttachWithIME(axis::TextFieldTTF* sender) override;
|
|
|
|
virtual bool onTextFieldDetachWithIME(axis::TextFieldTTF* sender) override;
|
|
|
|
virtual bool onTextFieldInsertText(axis::TextFieldTTF* sender, const char* text, size_t nLen) override;
|
|
|
|
virtual bool onTextFieldDeleteBackward(axis::TextFieldTTF* sender, const char* delText, size_t nLen) override;
|
|
|
|
virtual bool onDraw(axis::TextFieldTTF* sender);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2016-05-23 09:48:15 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextFieldTTFSecureTextEntryTest for test TextFieldTTF SecureTextEntry.
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TextFieldTTFSecureTextEntryTest : public TextFieldTTFDefaultTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(TextFieldTTFSecureTextEntryTest);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2016-05-23 09:48:15 +08:00
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
// Layer
|
|
|
|
virtual void onEnter() override;
|
|
|
|
};
|
2017-10-17 13:48:38 +08:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextFieldTTSetCursorFromPoint for test TextFieldTTF setCursorFromPoint.
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TextFieldTTSetCursorFromPoint : public KeyboardNotificationLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(TextFieldTTSetCursorFromPoint);
|
|
|
|
// KeyboardNotificationLayer
|
|
|
|
virtual std::string subtitle() const override;
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onClickTrackNode(bool bClicked, const axis::Vec2& touchPos) override;
|
2017-10-17 13:48:38 +08:00
|
|
|
|
|
|
|
// Layer
|
|
|
|
virtual void onEnter() override;
|
|
|
|
};
|
2021-12-28 16:06:23 +08:00
|
|
|
#endif // __TEXT_INPUT_TEST_H__
|