|
| 1 | +/*============================================================================== |
| 2 | +
|
| 3 | + Copyright 2018 by Tracktion Corporation. |
| 4 | + For more information visit www.tracktion.com |
| 5 | +
|
| 6 | + You may also use this code under the terms of the GPL v3 (see |
| 7 | + www.gnu.org/licenses). |
| 8 | +
|
| 9 | + pluginval IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER |
| 10 | + EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE |
| 11 | + DISCLAIMED. |
| 12 | +
|
| 13 | + ==============================================================================*/ |
| 14 | + |
| 15 | +#include "../PluginTests.h" |
| 16 | +#include "../TestUtilities.h" |
| 17 | + |
| 18 | +//============================================================================== |
| 19 | +struct LocaleTest : public PluginTest |
| 20 | +{ |
| 21 | + LocaleTest() |
| 22 | + : PluginTest ("Ensuring that the locale does not change during execution", 1) |
| 23 | + { |
| 24 | + startupLocale = std::setlocale(LC_ALL, nullptr); |
| 25 | + } |
| 26 | + |
| 27 | + void runTest (PluginTests& ut, juce::AudioPluginInstance& instance) override |
| 28 | + { |
| 29 | + ut.logMessage (juce::String ("INFO: Startup Locale: [LOC]") |
| 30 | + .replace ("LOC",juce::String (startupLocale), false)); |
| 31 | + |
| 32 | + if (instance.hasEditor()) |
| 33 | + { |
| 34 | + ScopedPluginDeinitialiser scopedPluginDeinitialiser (instance); |
| 35 | + |
| 36 | + { |
| 37 | + ut.logMessage ("Opening editor..."); |
| 38 | + ScopedEditorShower editor (instance); |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + std::string newLocale = std::setlocale(LC_ALL, nullptr); |
| 43 | + ut.expectEquals (startupLocale, newLocale, "Plugin changed locale. This can cause unexpected behavior."); |
| 44 | + ut.logMessage (juce::String ("INFO: Shutdown Locale: [LOC]") |
| 45 | + .replace ("LOC",juce::String (newLocale), false)); |
| 46 | + |
| 47 | + } |
| 48 | + |
| 49 | +private: |
| 50 | + std::string startupLocale; |
| 51 | +}; |
| 52 | + |
| 53 | +static LocaleTest localeTest; |
| 54 | + |
0 commit comments