Torque3D Documentation / _generateds / processTest.cpp

processTest.cpp

Engine/source/core/util/journal/test/processTest.cpp

More...

Detailed Description

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2014 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#ifdef TORQUE_TESTS_ENABLED
25#include "testing/unitTesting.h"
26#include "core/util/journal/process.h"
27
28FIXTURE(Process)
29{
30public:
31   U32 remainingTicks;
32   void notification()
33   {
34      if(remainingTicks == 0)
35         Process::requestShutdown();
36      remainingTicks--;
37   }
38};
39
40TEST_FIX(Process, BasicAPI)
41{
42   // We'll run 30 ticks, then quit.
43   remainingTicks = 30;
44
45   // Register with the process list.
46   Process::notify(this, &ProcessFixture::notification);
47
48   // And do 30 notifies, making sure we end on the 30th.
49   for(S32 i = 0; i < 30; i++)
50   {
51      EXPECT_TRUE(Process::processEvents())
52         << "Should quit after 30 ProcessEvents() calls - not before!";
53   }
54
55   EXPECT_FALSE(Process::processEvents())
56      << "Should quit after the 30th ProcessEvent() call!";
57
58   Process::remove(this, &ProcessFixture::notification);
59};
60
61#endif
62