~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to test/TestTerrain.cpp

  • Committer: Package Import Robot
  • Author(s): Olek Wojnar, Stephen M. Webb, Olek Wojnar
  • Date: 2016-08-06 18:39:19 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20160806183919-4g72j3flj7xe2stj
Tags: 0.7.2+dfsg-1
[ Stephen M. Webb ]
* debian/control: updated build-depends to newer minimum versions
  (closes: #704786)
* debian/control: updated Standards-Version to 3.9.4 (updated VCS-* fields)
* debian/patches/0001-ember.in-test-expr.patch: removed (fixed upstream)
* debian/patches/0002-add-update_lua_bindings.patch: removed (fixed upstream)
* debian/patches/0003-add-atlas-pkg.patch: removed (fixed upstream)
* debian/patches/0004-domain-bindings-lua-makefile.patch: refreshed
* debian/patches/0005-ember.in-prefix.patch: removed (fixed upstream)
* debian/patches/0006-spellcheck-similiar.patch: removed (fixed upstream)
* debian/patches/0007-revert-libwfut-version.patch: refreshed
* debian/patches/0008-replace-fastdeletegate-with-sigc++.patch: removed
 (fixed upstream)
* debian/patches/0009-spelling-bach.patch: removed (fixed upstream)
* debian/patches/0010-fix-ember-script-args.patch: removed (fixed upstream)
* debian/patches/0011-qualify-template-functions.patch: removed (fixed
  upstream)
* debian/patches/0012-fix-osdir-headers.patch: removed (fixed upstream)
* debian/patches/0013-remove-invalid-linker-flags.patch: removed (fixed
  upstream)
* debian/patches/0014-add-missing-ogrelodstrategy.patch: new
* debian/control: fixed Vcs-Browser URL
* debian/patches/0015-verbose-configure-errors.patch: new
* debian/patches/0016-boost-1.53.patch: new
* debian/control: bump boost build dependeny to 1.53

[ Olek Wojnar ]
* New upstream release (Closes: #799748)
* Add myself as new uploader
  - Remove Stephen Webb per his request
  - Thanks for all the contributions, Stephen!
* d/patches/0007-revert-libwfut-version.patch: removed (unnecessary)
* d/control
  - Remove pre-dependency on dpkg
  - Update standards to 3.9.8 (no changes)
  - Update Vcs lines for secure URIs
* Import patch from the wfmath package to replace MersenneTwister.h
  -- Avoids problems from ambiguous copyright of the original file
* Update dependencies for version 0.7.2
* Enable all hardening options
* Add three lintian overrides
  -- Ignore install into usr/bin (binary)
  -- Ignore .rc files needed for WIN32 build (source)
  -- Ignore false positive of spelling error (binary)
* d/copyright: Update contributors and dates
* d/rules
  -- Do not remove "sounddefinitions" directory
  -- Enable parallel build
  -- Do not install into games directories
  -- Remove dh_builddeb override since xz is now the default
* d/watch: update file extensions
* Remove three patches, add eight patches, update remaining patches
  -- 0004-domain-bindings-lua-makefile.patch (implemented upstream)
  -- 0014-add-missing-ogrelodstrategy.patch (implemented upstream)
  -- 0016-boost-1.53.patch (patch target file removed upstream)
  -- 0018-enable-subdir-objects.patch (Fix automake 1.14 warnings)
  -- 0019-update-boost-m4.patch (Fix invalid boost_major_version)
  -- 0020-remove-obsolete-includes.patch (Fix obsolete includes)
  -- 0021-GraphicalChangeAdapter-fix-for-newer-compilers.patch (Added)
  -- 0022-fix-typos.patch (Fix typos identified by lintian)
  -- 0023-add-keywords-to-desktop-file.patch (Add Keywords to .desktop file)
  -- 0024-fix-icon-location (Make icon location Icon Theme Spec-compliant)
  -- 0025-fix-duplicate-script-install.patch (Was causing build failures)

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#include "components/ogre/terrain/TerrainDefPoint.h"
12
12
#include "components/ogre/terrain/TerrainInfo.h"
13
13
#include "components/ogre/terrain/TerrainMod.h"
 
14
#include "components/ogre/terrain/TerrainPageSurfaceCompiler.h"
 
15
#include "components/ogre/ILightning.h"
14
16
 
15
17
#include "framework/Exception.h"
16
 
#include "main/Application.h"
 
18
#include "framework/TimeFrame.h"
 
19
#include "framework/MainLoopController.h"
17
20
 
18
21
#include <Eris/Entity.h>
19
22
 
28
31
#include <sigc++/signal.h>
29
32
#include <sigc++/trackable.h>
30
33
 
31
 
#include <boost/thread/condition_variable.hpp>
 
34
#include <condition_variable>
32
35
 
33
36
using namespace Ember::OgreView;
34
37
using namespace Ember::OgreView::Terrain;
37
40
namespace Ember
38
41
{
39
42
 
40
 
template<> Application *Singleton<Application>::ms_Singleton = 0;
41
 
 
42
 
void Application::requestQuit()
 
43
class DummyTerrainTechnique : public TerrainPageSurfaceCompilerTechnique
43
44
{
44
 
}
 
45
    virtual bool prepareMaterial()
 
46
    {
 
47
        return true;
 
48
    }
 
49
 
 
50
    virtual bool compileMaterial(Ogre::MaterialPtr material, std::set<std::string>& managedTextures) const
 
51
    {
 
52
        return true;
 
53
    }
 
54
 
 
55
    virtual bool compileCompositeMapMaterial(Ogre::MaterialPtr material, std::set<std::string>& managedTextures) const
 
56
    {
 
57
        return true;
 
58
    }
 
59
 
 
60
 
 
61
        virtual std::string getShadowTextureName(const Ogre::MaterialPtr& material) const
 
62
    {
 
63
        return "";
 
64
    }
 
65
 
 
66
 
 
67
        virtual bool requiresPregenShadow() const
 
68
        {
 
69
        return false;
 
70
    }
 
71
 
 
72
 
 
73
};
45
74
 
46
75
class DummyCompilerTechniqueProvider: public ICompilerTechniqueProvider
47
76
{
48
77
public:
49
78
        virtual TerrainPageSurfaceCompilerTechnique* createTechnique(const TerrainPageGeometryPtr& geometry, const SurfaceLayerStore& terrainPageSurfaces, const TerrainPageShadow* terrainPageShadow) const
50
79
        {
51
 
                return 0;
 
80
                return new DummyTerrainTechnique();
52
81
        }
53
82
 
54
83
};
81
110
                pageReady = true;
82
111
        }
83
112
 
 
113
        virtual bool isPageShown() const
 
114
        {
 
115
                return true;
 
116
        }
 
117
 
 
118
 
 
119
};
 
120
 
 
121
class DummyLightning : public ILightning {
 
122
public:
 
123
        /**
 
124
         * @brief Gets the direction of the main light, in world space.
 
125
         * @returns The direction of the main light, in world space.
 
126
         */
 
127
        virtual WFMath::Vector<3> getMainLightDirection() const
 
128
        {
 
129
                return WFMath::Vector<3>::ZERO();
 
130
        }
 
131
 
 
132
        /**
 
133
         * @brief Gets the default ambient light colour.
 
134
         * @returns The default ambient light colour.
 
135
         */
 
136
        virtual Ogre::ColourValue getAmbientLightColour() const
 
137
        {
 
138
                return Ogre::ColourValue::Black;
 
139
        }
84
140
};
85
141
 
86
142
class DummyEntity: public Eris::Entity
178
234
class CompleteEventListener: public virtual sigc::trackable
179
235
{
180
236
protected:
181
 
        boost::condition_variable mCondition;
182
 
        boost::mutex mMutex;
 
237
        std::condition_variable mCondition;
 
238
        std::mutex mMutex;
183
239
        int mCompletedCount;
184
240
 
185
241
        void handleEvent()
186
242
        {
187
243
                {
188
 
                        boost::lock_guard < boost::mutex > lock(mMutex);
 
244
                        std::lock_guard < std::mutex > lock(mMutex);
189
245
                        mCompletedCount++;
190
246
                }
191
247
                mCondition.notify_all();
199
255
 
200
256
        int waitForCompletion(long milliseconds)
201
257
        {
202
 
                boost::unique_lock < boost::mutex > lock(mMutex);
 
258
                std::unique_lock < std::mutex > lock(mMutex);
203
259
                if (mCompletedCount) {
204
260
                        return true;
205
261
                }
206
 
                mCondition.timed_wait(lock, boost::posix_time::milliseconds(milliseconds));
 
262
                mCondition.wait_for(lock, std::chrono::milliseconds(milliseconds));
207
263
                return mCompletedCount;
208
264
        }
209
265
 
233
289
{
234
290
protected:
235
291
 
236
 
        void eventListener(const std::vector<WFMath::AxisBox<2> >& areas, const std::set<TerrainPage*>& pages)
 
292
        void eventListener(const std::vector<WFMath::AxisBox<2>>& areas, const std::set<TerrainPage*>& pages)
237
293
        {
238
294
                handleEvent();
239
295
        }
240
296
 
241
297
public:
242
 
        AfterTerrainUpdateListener(sigc::signal<void, const std::vector<WFMath::AxisBox<2> >&, const std::set<TerrainPage*>&>& event)
 
298
        AfterTerrainUpdateListener(sigc::signal<void, const std::vector<WFMath::AxisBox<2>>&, const std::set<TerrainPage*>&>& event)
243
299
        {
244
300
                event.connect(sigc::mem_fun(*this, &AfterTerrainUpdateListener::eventListener));
245
301
        }
252
308
        TestTerrainHandler(int pageIndexSize, ICompilerTechniqueProvider& compilerTechniqueProvider) :
253
309
                Terrain::TerrainHandler(pageIndexSize, compilerTechniqueProvider)
254
310
        {
255
 
 
 
311
                mLightning = new DummyLightning();
256
312
        }
257
313
 
258
314
        Mercator::Terrain* getTerrain()
301
357
                terrainHandler.updateTerrain(terrainDefPoints);
302
358
                Timer timer;
303
359
                do {
304
 
                        terrainHandler.pollTasks();
 
360
                        terrainHandler.pollTasks(TimeFrame(boost::posix_time::seconds(10)));
305
361
                } while (!timer.hasElapsed(5000) && !worldSizeChangedListener.getCompletedCount());
306
362
                return worldSizeChangedListener.getCompletedCount() > 0;
307
363
        }
321
377
                {
322
378
                        Timer timer;
323
379
                        do {
324
 
                                terrainHandler.pollTasks();
 
380
                                terrainHandler.pollTasks(TimeFrame(boost::posix_time::seconds(10)));
325
381
                        } while ((!timer.hasElapsed(5000)) && (!bridge1->pageReady || !bridge2->pageReady || !bridge3->pageReady || !bridge4->pageReady));
326
382
                }
327
383
                CPPUNIT_ASSERT(bridge1->pageReady);
345
401
                {
346
402
                        Timer timer;
347
403
                        do {
348
 
                                terrainHandler.pollTasks();
 
404
                                terrainHandler.pollTasks(TimeFrame(boost::posix_time::seconds(10)));
349
405
                        } while ((!timer.hasElapsed(5000)) && afterTerrainUpdateListener.getCompletedCount() < 4);
350
406
                }
351
407
                CPPUNIT_ASSERT(afterTerrainUpdateListener.getCompletedCount() == 4);
356
412
class TerrainTestCase: public CppUnit::TestFixture
357
413
{
358
414
        CPPUNIT_TEST_SUITE( TerrainTestCase);
359
 
        CPPUNIT_TEST( testCreateTerrain);
360
 
        CPPUNIT_TEST( testAlterTerrain);
 
415
//      CPPUNIT_TEST( testCreateTerrain);
 
416
//      CPPUNIT_TEST( testAlterTerrain);
361
417
        CPPUNIT_TEST( testApplyMod);
362
 
        CPPUNIT_TEST( testUpdateMod);
 
418
//      CPPUNIT_TEST( testUpdateMod);
363
419
 
364
420
CPPUNIT_TEST_SUITE_END();
365
421
 
394
450
                TerrainSetup terrainSetup;
395
451
 
396
452
                Terrain::TerrainHandler& terrainHandler = terrainSetup.terrainHandler;
397
 
                CPPUNIT_ASSERT(terrainSetup.createBaseTerrain(25));
 
453
                CPPUNIT_ASSERT(terrainSetup.createBaseTerrain(25.0f));
398
454
                CPPUNIT_ASSERT(terrainSetup.createPages());
399
455
                CPPUNIT_ASSERT(terrainSetup.reloadTerrain());
400
456
 
411
467
                {
412
468
                        Timer timer;
413
469
                        do {
414
 
                                terrainHandler.pollTasks();
 
470
                                terrainHandler.pollTasks(TimeFrame(boost::posix_time::seconds(10)));
415
471
                        } while ((!timer.hasElapsed(5000)) && afterTerrainUpdateListener.getCompletedCount() < 4);
416
472
                }
417
473
                CPPUNIT_ASSERT(afterTerrainUpdateListener.getCompletedCount() == 4);
425
481
        void testApplyMod()
426
482
        {
427
483
 
 
484
                bool shouldQuit, pollEris;
 
485
                MainLoopController loopController(shouldQuit, pollEris);
428
486
                Ogre::Root root;
429
487
 
430
488
                TerrainSetup terrainSetup;
457
515
 
458
516
                entity.setAttr("terrainmod", mod);
459
517
 
460
 
                OgreView::Terrain::TerrainMod* terrainMod = new Terrain::TerrainMod(entity);
461
 
                terrainMod->init();
462
 
                terrainHandler.addTerrainMod(terrainMod);
 
518
                OgreView::Terrain::TerrainMod terrainMod(entity);
 
519
                terrainMod.init();
 
520
                terrainHandler.addTerrainMod(&terrainMod);
463
521
 
464
522
        }
465
523
 
511
569
                        {
512
570
                                Timer timer;
513
571
                                do {
514
 
                                        terrainHandler.pollTasks();
 
572
                                        terrainHandler.pollTasks(TimeFrame(boost::posix_time::seconds(10)));
515
573
                                } while (afterTerrainUpdateListener.getCompletedCount() < 4);
516
574
                        }
517
575
                        CPPUNIT_ASSERT(afterTerrainUpdateListener.getCompletedCount() == 4);
533
591
                        {
534
592
                                Timer timer;
535
593
                                do {
536
 
                                        terrainHandler.pollTasks();
 
594
                                        terrainHandler.pollTasks(TimeFrame(boost::posix_time::seconds(10)));
537
595
//                              } while ((!timer.hasElapsed(5000)) && afterTerrainUpdateListener.getCompletedCount() < 4);
538
596
                                } while (afterTerrainUpdateListener.getCompletedCount() < 4);
539
597
                        }
554
612
                        {
555
613
                                Timer timer;
556
614
                                do {
557
 
                                        terrainHandler.pollTasks();
 
615
                                        terrainHandler.pollTasks(TimeFrame(boost::posix_time::seconds(10)));
558
616
                                } while ((!timer.hasElapsed(5000)) && afterTerrainUpdateListener.getCompletedCount() < 4);
559
617
                        }
560
618
                        CPPUNIT_ASSERT(afterTerrainUpdateListener.getCompletedCount() == 4);