Skip to content

Commit

Permalink
Unit tests: Don't use OpenShot.h header (#607)
Browse files Browse the repository at this point in the history
- To prevent slow compiles of unit tests, replace all of the
  '#include "OpenShot.h"' invocations with includes of the
  individual headers actually needed by each test file.
  • Loading branch information
ferdnyc committed Dec 27, 2020
1 parent 48d2aac commit 2699e7d
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 20 deletions.
7 changes: 6 additions & 1 deletion tests/Cache_Tests.cpp
Expand Up @@ -28,12 +28,17 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <memory>

#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "CacheDisk.h"
#include "CacheMemory.h"
#include "Json.h"

#include <QDir>

using namespace openshot;

TEST(Cache_Default_Constructor)
Expand Down
10 changes: 8 additions & 2 deletions tests/Clip_Tests.cpp
Expand Up @@ -28,6 +28,9 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <sstream>
#include <memory>

#include "UnitTest++.h"

// Work around older versions of UnitTest++ without REQUIRE
Expand All @@ -37,7 +40,11 @@

// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "Clip.h"
#include "Frame.h"
#include "Fraction.h"
#include "Timeline.h"
#include "Json.h"

using namespace openshot;

Expand Down Expand Up @@ -255,4 +262,3 @@ TEST(Verify_Parent_Timeline)
}

} // SUITE

7 changes: 6 additions & 1 deletion tests/Color_Tests.cpp
Expand Up @@ -28,10 +28,15 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <string>
#include <vector>

#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "Color.h"
#include "KeyFrame.h"
#include "Json.h"

SUITE(Color) {

Expand Down
3 changes: 1 addition & 2 deletions tests/Coordinate_Tests.cpp
Expand Up @@ -31,9 +31,8 @@
#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "Coordinate.h"

using namespace std;
using namespace openshot;

TEST(Coordinate_Default_Constructor)
Expand Down
9 changes: 7 additions & 2 deletions tests/DummyReader_Tests.cpp
Expand Up @@ -28,11 +28,16 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <memory>

#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1

#include "OpenShot.h"
#include "DummyReader.h"
#include "CacheMemory.h"
#include "Fraction.h"
#include "Frame.h"

using namespace std;
using namespace openshot;
Expand Down Expand Up @@ -146,4 +151,4 @@ TEST (DummyReader_Invalid_Fake_Frame) {
// Clean up
cache.Clear();
r.Close();
}
}
9 changes: 7 additions & 2 deletions tests/FFmpegReader_Tests.cpp
Expand Up @@ -28,10 +28,16 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <sstream>
#include <memory>

#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "FFmpegReader.h"
#include "Frame.h"
#include "Timeline.h"
#include "Json.h"

using namespace std;
using namespace openshot;
Expand Down Expand Up @@ -272,4 +278,3 @@ TEST(Verify_Parent_Timeline)
}

} // SUITE(FFmpegReader)

8 changes: 7 additions & 1 deletion tests/FFmpegWriter_Tests.cpp
Expand Up @@ -28,10 +28,16 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <sstream>
#include <memory>

#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "FFmpegWriter.h"
#include "FFmpegReader.h"
#include "Fraction.h"
#include "Frame.h"

using namespace std;
using namespace openshot;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fraction_Tests.cpp
Expand Up @@ -31,7 +31,7 @@
#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "Fraction.h"

using namespace std;
using namespace openshot;
Expand Down
7 changes: 6 additions & 1 deletion tests/Frame_Tests.cpp
Expand Up @@ -29,10 +29,15 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <sstream>
#include <memory>

#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "Frame.h"
#include "Clip.h"
#include "Fraction.h"

#include <QImage>

Expand Down
11 changes: 9 additions & 2 deletions tests/ImageWriter_Tests.cpp
Expand Up @@ -28,15 +28,22 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <sstream>
#include <memory>

#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"

#ifdef USE_IMAGEMAGICK
#include "ImageWriter.h"
#include "ImageReader.h"
#include "FFmpegReader.h"
#include "Frame.h"

using namespace std;
using namespace openshot;

#ifdef USE_IMAGEMAGICK
SUITE(ImageWriter)
{

Expand Down
5 changes: 4 additions & 1 deletion tests/KeyFrame_Tests.cpp
Expand Up @@ -31,7 +31,10 @@
#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "KeyFrame.h"
#include "Coordinate.h"
#include "Fraction.h"
#include "Point.h"

using namespace std;
using namespace openshot;
Expand Down
5 changes: 4 additions & 1 deletion tests/Point_Tests.cpp
Expand Up @@ -31,7 +31,10 @@
#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "Point.h"
#include "Enums.h"
#include "Coordinate.h"
#include "Json.h"

SUITE(POINT) {

Expand Down
7 changes: 6 additions & 1 deletion tests/ReaderBase_Tests.cpp
Expand Up @@ -28,10 +28,15 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <memory>

#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "ReaderBase.h"
#include "CacheBase.h"
#include "Frame.h"
#include "Json.h"

using namespace std;
using namespace openshot;
Expand Down
2 changes: 1 addition & 1 deletion tests/Settings_Tests.cpp
Expand Up @@ -31,7 +31,7 @@
#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "Settings.h"

using namespace std;
using namespace openshot;
Expand Down
11 changes: 10 additions & 1 deletion tests/Timeline_Tests.cpp
Expand Up @@ -28,10 +28,19 @@
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
*/

#include <sstream>
#include <memory>
#include <list>

#include "UnitTest++.h"
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "OpenShot.h"
#include "Timeline.h"
#include "Clip.h"
#include "Frame.h"
#include "Fraction.h"
#include "effects/Blur.h"
#include "effects/Negate.h"

using namespace std;
using namespace openshot;
Expand Down

0 comments on commit 2699e7d

Please sign in to comment.