PuzzleSDK
SchedulerTest.h
浏览该文件的文档.
1/****************************************************************************
2 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
3
4 http://www.cocos2d-x.org
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23 ****************************************************************************/
24
25#ifndef _SCHEDULER_TEST_H_
26#define _SCHEDULER_TEST_H_
27
28#include "cocos2d.h"
29#include "extensions/cocos-ext.h"
30#include "../BaseTest.h"
31
32
33DEFINE_TEST_SUITE(SchedulerTests);
34
36{
37public:
38};
39
41{
42public:
44
45 virtual void onEnter() override;
46 virtual std::string title() const override;
47 virtual std::string subtitle() const override;
48
49 void autoremove(float dt);
50 void tick(float dt);
51private:
52 float accum;
53};
54
56{
57public:
59
60 virtual void onEnter() override;
61 virtual std::string title() const override;
62 virtual std::string subtitle() const override;
63
64 void tick1(float dt);
65 void tick2(float dt);
66 using SchedulerTestLayer::pause;
67 void pause(float dt);
68};
69
71{
72public:
74
77 virtual void onEnter() override;
78 virtual void onExit() override;
79 virtual void update(float delta) override;
80 virtual std::string title() const override;
81 virtual std::string subtitle() const override;
82
83 void tick1(float dt);
84 void tick2(float dt);
85 using SchedulerTestLayer::pause;
86 void pause(float dt);
87 using SchedulerTestLayer::resume;
88 void resume(float dt);
89private:
90 std::set<void*> _pausedTargets;
91};
92
94{
95public:
97
100 virtual void onEnter() override;
101 virtual void onExit() override;
102 virtual std::string title() const override;
103 virtual std::string subtitle() const override;
104
105 void tick1(float dt);
106 void tick2(float dt);
107 using SchedulerTestLayer::pause;
108 void pause(float dt);
109 using SchedulerTestLayer::resume;
110 void resume(float dt);
111private:
112 std::set<void*> _pausedTargets;
113};
114
116{
117public:
119
120 virtual void onEnter() override;
121 virtual std::string title() const override;
122 virtual std::string subtitle() const override;
123
124 void tick1(float dt);
125 void tick2(float dt);
126 void tick3(float dt);
127 void tick4(float dt);
128 void unscheduleAll(float dt);
129};
130
132{
133public:
135
136 virtual void onEnter() override;
137 virtual void onExit() override;
138 virtual std::string title() const override;
139 virtual std::string subtitle() const override;
140
141 void tick1(float dt);
142 void tick2(float dt);
143 void tick3(float dt);
144 void tick4(float dt);
145 void unscheduleAll(float dt);
146private:
148};
149
151{
152public:
154
155 virtual void onEnter() override;
156 virtual std::string title() const override;
157 virtual std::string subtitle() const override;
158
159 void tick1(float dt);
160 void tick2(float dt);
161 void tick3(float dt);
162 void tick4(float dt);
163 void unscheduleAll(float dt);
164};
165
167{
168public:
170
171 virtual void onEnter() override;
172 virtual std::string title() const override;
173 virtual std::string subtitle() const override;
174
175 void tick1(float dt);
176 void tick2(float dt);
177 void tick3(float dt);
178 void tick4(float dt);
179 void scheduleAndUnschedule(float dt);
180};
181
183{
184public:
186
187 virtual void onEnter() override;
188 virtual std::string title() const override;
189 virtual std::string subtitle() const override;
190
191 void removeUpdates(float dt);
192};
193
195{
196public:
198
199 virtual void onEnter() override;
200 virtual std::string title() const override;
201 virtual std::string subtitle() const override;
202
203 void update(float dt) override;
204 void tick(float dt);
205 void stopSelectors(float dt);
206};
207
209{
210public:
212
213 virtual void onEnter() override;
214 virtual std::string title() const override;
215 virtual std::string subtitle() const override;
216
217 void update(float dt) override;
218 void schedUpdate(float dt);
219 void stopUpdate(float dt);
220};
221
222class TestNode : public cocos2d::Node
223{
224public:
226
227 ~TestNode();
228
229 void initWithString(const std::string& str, int priority);
230 virtual void update(float dt) override;
231private:
232 std::string _string;
233};
234
236{
237public:
239
240 virtual void onEnter() override;
241 virtual std::string title() const override;
242 virtual std::string subtitle() const override;
243
244 void schedUpdate(float dt);
245private:
248};
249
251{
252public:
254
255 virtual void onEnter() override;
256 virtual std::string title() const override;
257 virtual std::string subtitle() const override;
258 void update(float dt) override;
259};
260
262{
263public:
265
266 void onEnter() override;
267 void onExit() override;
268 virtual std::string title() const override;
269 virtual std::string subtitle() const override;
270 cocos2d::extension::ControlSlider* sliderCtl();
271 void sliderAction(cocos2d::Ref* sender, cocos2d::extension::Control::EventType controlEvent);
272 cocos2d::extension::ControlSlider* _sliderCtl;
273};
274
275
277{
278public:
280
281 virtual ~TwoSchedulers();
282 virtual std::string title() const override;
283 virtual std::string subtitle() const override;
284 void onEnter() override;
285 cocos2d::extension::ControlSlider* sliderCtl();
286 void sliderAction(cocos2d::Ref* sender, cocos2d::extension::Control::EventType controlEvent);
287 cocos2d::Scheduler* sched1;
288 cocos2d::Scheduler* sched2;
289 cocos2d::ActionManager* actionManager1;
290 cocos2d::ActionManager* actionManager2;
291
292 cocos2d::extension::ControlSlider* sliderCtl1;
293 cocos2d::extension::ControlSlider* sliderCtl2;
294};
295
297{
298public:
300
302 virtual std::string title() const override;
303 virtual std::string subtitle() const override;
304 void onEnter() override;
305 void update(float dt) override;
306
307private:
308 cocos2d::Node* testNode;
309};
310
312{
313public:
315
316 virtual std::string title() const override;
317 virtual std::string subtitle() const override;
318 void onEnter() override;
319};
320
322{
323public:
325
327 virtual std::string title() const override;
328 virtual std::string subtitle() const override;
329 void onEnter() override;
330
331 void callback(float dt);
332
333private:
334};
335
337{
338public:
340
341 virtual std::string title() const override;
342 virtual std::string subtitle() const override;
343 void onEnter() override;
344 void onExit() override;
345
346 virtual void update(float dt) override;
347
348 bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event);
349};
350
352{
353public:
355
356 virtual std::string title() const override;
357 virtual std::string subtitle() const override;
358
359 void onEnter() override;
360 void update(float dt) override;
361};
362
364{
365public:
367
368 virtual std::string title() const override;
369 virtual std::string subtitle() const override;
370 void onEnter() override;
371 void onExit() override;
372 void update(float dt) override;
373
374private:
375 cocos2d::Sprite *_sprite;
376};
377
379{
380public:
384
385 virtual std::string title() const override;
386 virtual std::string subtitle() const override;
387 virtual void onEnter() override;
388 virtual void update(float dt) override;
389
390private:
391 class ClassA
392 {
393 public:
394 ClassA();
395
396 void update(float dt);
397
401 };
402
403 class ClassB
404 {
405 public:
406 ClassB();
407 void update(float dt);
408
412 };
413
415};
416
418{
419public:
421
422 virtual std::string title() const override;
423 virtual std::string subtitle() const override;
424 virtual void onEnter() override;
425 virtual void onExit() override;
426
427private:
429 {
430 public:
431 TestClass(int index, TestClass *nextObj, cocos2d::Scheduler* scheduler);
432 void update(float dt);
433 private:
434 TestClass *_nextObj = nullptr;
435 int _index = 0;
436 cocos2d::Scheduler *_scheduler = nullptr;
437 bool _cleanedUp = false;
438 };
439 std::vector<TestClass *> _testvector;
440};
441
443{
444public:
446
447 virtual std::string title() const override;
448 virtual std::string subtitle() const override;
449 virtual void onEnter() override;
450 virtual void onExit() override;
451
452private:
453 void callback( float );
454
455private:
457};
458
459#endif
DEFINE_TEST_SUITE(SchedulerTests)
CREATE_FUNC(RescheduleSelector)
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
void schedUpdate(float dt)
CREATE_FUNC(ScheduleCallbackTest)
virtual std::string subtitle() const override
void onEnter() override
virtual std::string title() const override
void callback(float dt)
bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event)
virtual std::string subtitle() const override
CREATE_FUNC(ScheduleUpdatePriority)
virtual void update(float dt) override
virtual std::string title() const override
void tick(float dt)
virtual std::string title() const override
virtual void onEnter() override
void autoremove(float dt)
virtual std::string subtitle() const override
CREATE_FUNC(SchedulerAutoremove)
virtual std::string title() const override
void update(float dt) override
virtual void onEnter() override
virtual std::string subtitle() const override
CREATE_FUNC(SchedulerDelayAndRepeat)
virtual std::string title() const override
void update(float dt) override
void onEnter() override
CREATE_FUNC(SchedulerIssue10232)
virtual std::string subtitle() const override
virtual void onEnter() override
virtual void update(float dt) override
virtual std::string subtitle() const override
virtual std::string title() const override
CREATE_FUNC(SchedulerIssue17149)
void onEnter() override
void update(float dt) override
CREATE_FUNC(SchedulerIssue2268)
virtual std::string subtitle() const override
virtual std::string title() const override
cocos2d::Node * testNode
CREATE_FUNC(SchedulerIssueWithReschedule)
virtual std::string title() const override
virtual std::string subtitle() const override
CREATE_FUNC(SchedulerPauseResumeAll)
virtual void update(float delta) override
virtual void onEnter() override
std::set< void * > _pausedTargets
Definition: SchedulerTest.h:90
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onExit() override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual void onExit() override
std::set< void * > _pausedTargets
virtual std::string title() const override
CREATE_FUNC(SchedulerPauseResumeAllUser)
void pause(float dt)
CREATE_FUNC(SchedulerPauseResume)
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
void tick2(float dt)
void tick1(float dt)
CREATE_FUNC(SchedulerRemoveAllFunctionsToBePerformedInCocosThread)
virtual std::string subtitle() const override
TestClass * _nextObj
cocos2d::Scheduler * _scheduler
void update(float dt)
TestClass(int index, TestClass *nextObj, cocos2d::Scheduler *scheduler)
int _index
bool _cleanedUp
CREATE_FUNC(SchedulerRemoveEntryWhileUpdate)
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onExit() override
std::vector< TestClass * > _testvector
virtual void onEnter() override
CREATE_FUNC(SchedulerRemoveSelectorDuringCall)
virtual std::string title() const override
virtual void onEnter() override
virtual void onExit() override
virtual std::string subtitle() const override
CREATE_FUNC(SchedulerSchedulesAndRemove)
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
void scheduleAndUnschedule(float dt)
cocos2d::extension::ControlSlider * _sliderCtl
void sliderAction(cocos2d::Ref *sender, cocos2d::extension::Control::EventType controlEvent)
virtual std::string title() const override
CREATE_FUNC(SchedulerTimeScale)
void onExit() override
cocos2d::extension::ControlSlider * sliderCtl()
void onEnter() override
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual void onExit() override
CREATE_FUNC(SchedulerUnscheduleAllHard)
virtual std::string title() const override
virtual void onEnter() override
virtual std::string title() const override
CREATE_FUNC(SchedulerUnscheduleAll)
virtual std::string subtitle() const override
void unscheduleAll(float dt)
virtual void onEnter() override
CREATE_FUNC(SchedulerUnscheduleAllUserLevel)
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
CREATE_FUNC(SchedulerUpdateAndCustom)
void stopSelectors(float dt)
void update(float dt) override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
void update(float dt) override
CREATE_FUNC(SchedulerUpdateFromCustom)
virtual std::string subtitle() const override
virtual void onEnter() override
CREATE_FUNC(SchedulerUpdate)
void removeUpdates(float dt)
virtual std::string title() const override
CREATE_FUNC(TestNode)
std::string _string
virtual void update(float dt) override
void initWithString(const std::string &str, int priority)
cocos2d::Scheduler * sched2
cocos2d::Scheduler * sched1
cocos2d::ActionManager * actionManager2
cocos2d::extension::ControlSlider * sliderCtl()
void onEnter() override
cocos2d::ActionManager * actionManager1
cocos2d::extension::ControlSlider * sliderCtl2
virtual ~TwoSchedulers()
cocos2d::extension::ControlSlider * sliderCtl1
virtual std::string subtitle() const override
virtual std::string title() const override
CREATE_FUNC(TwoSchedulers)
void sliderAction(cocos2d::Ref *sender, cocos2d::extension::Control::EventType controlEvent)