mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
The fix adds a sanity check to the D3D and GL device enumeration function that exits early if there's no registered display from the OS(implying it's running in commandline). With newer versions of SDL, attempting to enumerate the GL device causes a segfault because the OS will return back a valid context, but the context isn't actually valid. So when tested against, it crashes. Avoiding enumerating the device when you're not in a position to render works around the issue. TODO: If the machine is running in terminal-only mode, and thus has no valid render context, but still has a monitor plugged into the machine, it can sidestep the sanity check and still result in a segfault. Need a more robust check for that circumstance in a future fix.
69 lines
2.6 KiB
C++
69 lines
2.6 KiB
C++
//-----------------------------------------------------------------------------
|
|
// Copyright (c) 2014 GarageGames, LLC
|
|
//
|
|
// 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:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// 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.
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#ifdef TORQUE_TESTS_ENABLED
|
|
#include "testing/unitTesting.h"
|
|
#include "windowManager/platformWindowMgr.h"
|
|
|
|
// Mysteriously, TEST(WindowManager, BasicAPI) gives an error. Huh.
|
|
TEST(WinMgr, BasicAPI)
|
|
{
|
|
PlatformWindowManager *pwm = CreatePlatformWindowManager();
|
|
EXPECT_TRUE(pwm)
|
|
<< "CreatePlatformWindowManager creation Failed!";
|
|
if (!pwm)
|
|
return;
|
|
|
|
S32 monitorCount = PlatformWindowManager::get()->getMonitorCount();
|
|
EXPECT_GT(monitorCount, 0)
|
|
<< "no monitor to test against!";
|
|
if (monitorCount == 0)
|
|
return;
|
|
|
|
// Check out the primary desktop area...
|
|
RectI primary = pwm->getPrimaryDesktopArea();
|
|
|
|
EXPECT_TRUE(primary.isValidRect())
|
|
<< "Got some sort of invalid rect from the window manager!";
|
|
|
|
// Now try to get info about all the monitors.
|
|
Vector<RectI> monitorRects;
|
|
pwm->getMonitorRegions(monitorRects);
|
|
|
|
EXPECT_GT(monitorRects.size(), 0)
|
|
<< "Should get at least one monitor rect back from getMonitorRegions!";
|
|
|
|
// This test is here just to detect overflow/runaway situations. -- BJG
|
|
EXPECT_LT(monitorRects.size(), 64)
|
|
<< "Either something's wrong, or you have a lot of monitors...";
|
|
|
|
for(S32 i=0; i<monitorRects.size(); i++)
|
|
{
|
|
EXPECT_TRUE(monitorRects[i].isValidRect())
|
|
<< "Got an invalid rect for this monitor - no good.";
|
|
}
|
|
|
|
// No way to destroy the window manager.
|
|
};
|
|
|
|
#endif
|