Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
* @brief Unit tests for openshot::Profile
|
|
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
|
|
|
|
*
|
|
|
|
|
* @ref License
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Copyright (c) 2008-2023 OpenShot Studios, LLC
|
|
|
|
|
//
|
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
|
|
#include "openshot_catch.h"
|
2026-02-23 00:00:33 -06:00
|
|
|
#include <cstdlib>
|
2025-06-06 17:46:22 -05:00
|
|
|
#include <sstream>
|
2026-02-23 16:55:49 -06:00
|
|
|
#include <fstream>
|
2026-02-23 17:25:23 -06:00
|
|
|
#include <cstdio>
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
|
|
|
|
|
|
2026-02-23 16:55:49 -06:00
|
|
|
#include "Exceptions.h"
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
#include "Profiles.h"
|
|
|
|
|
|
2026-02-23 17:41:18 -06:00
|
|
|
static std::string get_temp_test_path(const std::string& file_name) {
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
const char* base = std::getenv("TEMP");
|
|
|
|
|
if (!base || !*base) {
|
|
|
|
|
base = std::getenv("TMP");
|
|
|
|
|
}
|
|
|
|
|
if (!base || !*base) {
|
|
|
|
|
base = ".";
|
|
|
|
|
}
|
|
|
|
|
return std::string(base) + "\\" + file_name;
|
|
|
|
|
#else
|
|
|
|
|
const char* base = std::getenv("TMPDIR");
|
|
|
|
|
if (!base || !*base) {
|
|
|
|
|
base = "/tmp";
|
|
|
|
|
}
|
|
|
|
|
return std::string(base) + "/" + file_name;
|
|
|
|
|
#endif
|
2026-02-23 00:00:33 -06:00
|
|
|
}
|
|
|
|
|
|
2026-02-27 12:29:48 -06:00
|
|
|
static std::string test_output_profile_path(const std::string& base_name) {
|
|
|
|
|
std::stringstream file_name;
|
|
|
|
|
file_name << base_name << "_" << std::rand() << ".profile";
|
|
|
|
|
return get_temp_test_path(file_name.str());
|
|
|
|
|
}
|
|
|
|
|
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
TEST_CASE( "empty constructor", "[libopenshot][profile]" )
|
|
|
|
|
{
|
|
|
|
|
openshot::Profile p1;
|
|
|
|
|
|
|
|
|
|
// Default values
|
2024-10-09 16:18:35 -05:00
|
|
|
CHECK(p1.info.description.empty());
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
CHECK(p1.info.width == 0);
|
|
|
|
|
CHECK(p1.info.height == 0);
|
|
|
|
|
CHECK(p1.info.fps.num == 0);
|
|
|
|
|
CHECK(p1.info.fps.den == 0);
|
|
|
|
|
CHECK(p1.info.display_ratio.num == 0);
|
|
|
|
|
CHECK(p1.info.display_ratio.den == 0);
|
|
|
|
|
CHECK(p1.info.pixel_ratio.num == 0);
|
|
|
|
|
CHECK(p1.info.pixel_ratio.den == 0);
|
|
|
|
|
CHECK(p1.info.interlaced_frame == false);
|
2025-05-20 16:02:23 -05:00
|
|
|
CHECK(p1.info.spherical == false);
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_CASE( "constructor with example profiles", "[libopenshot][profile]" )
|
|
|
|
|
{
|
|
|
|
|
std::stringstream profile1;
|
|
|
|
|
profile1 << TEST_MEDIA_PATH << "example_profile1";
|
|
|
|
|
|
|
|
|
|
openshot::Profile p1(profile1.str());
|
|
|
|
|
|
|
|
|
|
// Default values
|
2024-10-09 16:18:35 -05:00
|
|
|
CHECK(p1.info.description == "HD 720p 24 fps");
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
CHECK(p1.info.width == 1280);
|
|
|
|
|
CHECK(p1.info.height == 720);
|
|
|
|
|
CHECK(p1.info.fps.num == 24);
|
|
|
|
|
CHECK(p1.info.fps.den == 1);
|
|
|
|
|
CHECK(p1.info.display_ratio.num == 16);
|
|
|
|
|
CHECK(p1.info.display_ratio.den == 9);
|
|
|
|
|
CHECK(p1.info.pixel_ratio.num == 1);
|
|
|
|
|
CHECK(p1.info.pixel_ratio.den == 1);
|
|
|
|
|
CHECK(p1.info.interlaced_frame == false);
|
2025-05-20 16:02:23 -05:00
|
|
|
CHECK(p1.info.spherical == false);
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
|
2024-10-09 16:18:35 -05:00
|
|
|
// Export to JSON
|
|
|
|
|
openshot::Profile p1_json = openshot::Profile();
|
|
|
|
|
p1_json.SetJson(p1.Json());
|
|
|
|
|
|
|
|
|
|
CHECK(p1_json.info.description == "HD 720p 24 fps");
|
|
|
|
|
CHECK(p1_json.info.width == 1280);
|
|
|
|
|
CHECK(p1_json.info.height == 720);
|
|
|
|
|
CHECK(p1_json.info.fps.num == 24);
|
|
|
|
|
CHECK(p1_json.info.fps.den == 1);
|
|
|
|
|
CHECK(p1_json.info.display_ratio.num == 16);
|
|
|
|
|
CHECK(p1_json.info.display_ratio.den == 9);
|
|
|
|
|
CHECK(p1_json.info.pixel_ratio.num == 1);
|
|
|
|
|
CHECK(p1_json.info.pixel_ratio.den == 1);
|
|
|
|
|
CHECK(p1_json.info.interlaced_frame == false);
|
2025-05-20 16:02:23 -05:00
|
|
|
CHECK(p1_json.info.spherical == false);
|
2024-10-09 16:18:35 -05:00
|
|
|
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
std::stringstream profile2;
|
|
|
|
|
profile2 << TEST_MEDIA_PATH << "example_profile2";
|
|
|
|
|
|
|
|
|
|
openshot::Profile p2(profile2.str());
|
|
|
|
|
|
|
|
|
|
// Default values
|
2024-10-09 16:18:35 -05:00
|
|
|
CHECK(p2.info.description == "HD 1080i 29.97 fps");
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
CHECK(p2.info.width == 1920);
|
|
|
|
|
CHECK(p2.info.height == 1080);
|
|
|
|
|
CHECK(p2.info.fps.num == 30000);
|
|
|
|
|
CHECK(p2.info.fps.den == 1001);
|
|
|
|
|
CHECK(p2.info.display_ratio.num == 16);
|
|
|
|
|
CHECK(p2.info.display_ratio.den == 9);
|
|
|
|
|
CHECK(p2.info.pixel_ratio.num == 1);
|
|
|
|
|
CHECK(p2.info.pixel_ratio.den == 1);
|
|
|
|
|
CHECK(p2.info.interlaced_frame == true);
|
2025-05-20 16:02:23 -05:00
|
|
|
CHECK(p2.info.spherical == false);
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
}
|
|
|
|
|
|
2026-02-23 16:55:49 -06:00
|
|
|
TEST_CASE( "invalid profile path message", "[libopenshot][profile]" )
|
|
|
|
|
{
|
2026-02-23 17:41:18 -06:00
|
|
|
const std::string invalid_path = get_temp_test_path("__openshot_missing_test_profile__");
|
2026-02-23 17:25:23 -06:00
|
|
|
std::remove(invalid_path.c_str());
|
2026-02-23 16:55:49 -06:00
|
|
|
try {
|
|
|
|
|
openshot::Profile p(invalid_path);
|
|
|
|
|
FAIL("Expected InvalidFile for missing profile path");
|
|
|
|
|
} catch (const openshot::InvalidFile& e) {
|
|
|
|
|
const std::string message = e.what();
|
|
|
|
|
CHECK(message.find("Profile file could not be found or opened.") != std::string::npos);
|
|
|
|
|
CHECK(message.find(invalid_path) != std::string::npos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_CASE( "invalid profile parse message", "[libopenshot][profile]" )
|
|
|
|
|
{
|
2026-02-23 17:41:18 -06:00
|
|
|
const std::string invalid_profile = get_temp_test_path("openshot_invalid_profile_for_test.profile");
|
2026-02-23 16:55:49 -06:00
|
|
|
{
|
|
|
|
|
std::ofstream f(invalid_profile);
|
|
|
|
|
f << "width=abc\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
openshot::Profile p(invalid_profile);
|
|
|
|
|
FAIL("Expected InvalidFile for malformed profile contents");
|
|
|
|
|
} catch (const openshot::InvalidFile& e) {
|
|
|
|
|
const std::string message = e.what();
|
|
|
|
|
CHECK(message.find("Profile file could not be parsed (invalid format or values).") != std::string::npos);
|
|
|
|
|
CHECK(message.find(invalid_profile) != std::string::npos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).
* Add empty constructor for Profile class, and new Profile unit tets
* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09
* Clear setfill flag after creating Key() output
* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.
* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)
* Fix some whitespace issues
* Fix inline documentation mistype
* Fixed missing reuse licensing on new example profile files
* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that
* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually
* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
|
|
|
TEST_CASE( "24 fps names", "[libopenshot][profile]" )
|
|
|
|
|
{
|
|
|
|
|
std::stringstream path;
|
|
|
|
|
path << TEST_MEDIA_PATH << "example_profile1";
|
|
|
|
|
|
|
|
|
|
openshot::Profile p(path.str());
|
|
|
|
|
|
|
|
|
|
// Default values
|
|
|
|
|
CHECK(p.Key() == "01280x0720p0024_16-09");
|
|
|
|
|
CHECK(p.ShortName() == "1280x720p24");
|
|
|
|
|
CHECK(p.LongName() == "1280x720p @ 24 fps (16:9)");
|
|
|
|
|
CHECK(p.LongNameWithDesc() == "1280x720p @ 24 fps (16:9) HD 720p 24 fps");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_CASE( "29.97 fps names", "[libopenshot][profile]" )
|
|
|
|
|
{
|
|
|
|
|
std::stringstream path;
|
|
|
|
|
path << TEST_MEDIA_PATH << "example_profile2";
|
|
|
|
|
|
|
|
|
|
openshot::Profile p(path.str());
|
|
|
|
|
|
|
|
|
|
// Default values
|
|
|
|
|
CHECK(p.Key() == "01920x1080i2997_16-09");
|
|
|
|
|
CHECK(p.ShortName() == "1920x1080i29.97");
|
|
|
|
|
CHECK(p.LongName() == "1920x1080i @ 29.97 fps (16:9)");
|
|
|
|
|
CHECK(p.LongNameWithDesc() == "1920x1080i @ 29.97 fps (16:9) HD 1080i 29.97 fps");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_CASE( "compare profiles", "[libopenshot][profile]" )
|
|
|
|
|
{
|
|
|
|
|
// 720p24
|
|
|
|
|
std::stringstream profile1;
|
|
|
|
|
profile1 << TEST_MEDIA_PATH << "example_profile1";
|
|
|
|
|
openshot::Profile p1(profile1.str());
|
|
|
|
|
|
|
|
|
|
// 720p24 (copy)
|
|
|
|
|
openshot::Profile p1copy(profile1.str());
|
|
|
|
|
|
|
|
|
|
// 1080i2997
|
|
|
|
|
std::stringstream profile2;
|
|
|
|
|
profile2 << TEST_MEDIA_PATH << "example_profile2";
|
|
|
|
|
openshot::Profile p2(profile2.str());
|
|
|
|
|
|
|
|
|
|
// 1080i2997 (copy)
|
|
|
|
|
openshot::Profile p2copy(profile2.str());
|
|
|
|
|
|
|
|
|
|
CHECK(p1 < p2);
|
|
|
|
|
CHECK(p2 > p1);
|
|
|
|
|
CHECK(p1 == p1copy);
|
|
|
|
|
CHECK(p2 == p2copy);
|
|
|
|
|
|
|
|
|
|
// 720p60
|
|
|
|
|
openshot::Profile p3(profile1.str());
|
|
|
|
|
p3.info.fps.num = 60;
|
|
|
|
|
|
|
|
|
|
CHECK(p1 < p3);
|
|
|
|
|
CHECK_FALSE(p1 == p3);
|
|
|
|
|
|
|
|
|
|
// 72024, DAR: 4:3
|
|
|
|
|
p3.info.fps.num = 24;
|
|
|
|
|
p3.info.display_ratio.num = 4;
|
|
|
|
|
p3.info.display_ratio.den = 3;
|
|
|
|
|
|
|
|
|
|
CHECK(p1 > p3);
|
|
|
|
|
CHECK(p3 < p1);
|
|
|
|
|
CHECK_FALSE(p1 == p3);
|
|
|
|
|
}
|
2024-10-09 16:18:35 -05:00
|
|
|
|
|
|
|
|
TEST_CASE( "save profiles", "[libopenshot][profile]" )
|
|
|
|
|
{
|
|
|
|
|
// Load profile
|
|
|
|
|
std::stringstream profile1;
|
|
|
|
|
profile1 << TEST_MEDIA_PATH << "example_profile1";
|
|
|
|
|
openshot::Profile p1(profile1.str());
|
|
|
|
|
|
|
|
|
|
// Save copy
|
2026-02-23 00:00:33 -06:00
|
|
|
const std::string profile1_copy = test_output_profile_path("example_profile1_copy");
|
|
|
|
|
p1.Save(profile1_copy);
|
2024-10-09 16:18:35 -05:00
|
|
|
|
|
|
|
|
// Load saved copy
|
2026-02-23 00:00:33 -06:00
|
|
|
openshot::Profile p1_load_copy(profile1_copy);
|
2024-10-09 16:18:35 -05:00
|
|
|
|
|
|
|
|
// Default values
|
|
|
|
|
CHECK(p1_load_copy.info.description == "HD 720p 24 fps");
|
|
|
|
|
CHECK(p1_load_copy.info.width == 1280);
|
|
|
|
|
CHECK(p1_load_copy.info.height == 720);
|
|
|
|
|
CHECK(p1_load_copy.info.fps.num == 24);
|
|
|
|
|
CHECK(p1_load_copy.info.fps.den == 1);
|
|
|
|
|
CHECK(p1_load_copy.info.display_ratio.num == 16);
|
|
|
|
|
CHECK(p1_load_copy.info.display_ratio.den == 9);
|
|
|
|
|
CHECK(p1_load_copy.info.pixel_ratio.num == 1);
|
|
|
|
|
CHECK(p1_load_copy.info.pixel_ratio.den == 1);
|
|
|
|
|
CHECK(p1_load_copy.info.interlaced_frame == false);
|
2025-05-20 16:02:23 -05:00
|
|
|
CHECK(p1_load_copy.info.spherical == false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_CASE( "spherical profiles", "[libopenshot][profile]" )
|
|
|
|
|
{
|
|
|
|
|
// Create a new profile with spherical=true
|
|
|
|
|
openshot::Profile p;
|
|
|
|
|
p.info.description = "360° Test Profile";
|
|
|
|
|
p.info.width = 3840;
|
|
|
|
|
p.info.height = 1920;
|
|
|
|
|
p.info.fps.num = 30;
|
|
|
|
|
p.info.fps.den = 1;
|
|
|
|
|
p.info.display_ratio.num = 2;
|
|
|
|
|
p.info.display_ratio.den = 1;
|
|
|
|
|
p.info.pixel_ratio.num = 1;
|
|
|
|
|
p.info.pixel_ratio.den = 1;
|
|
|
|
|
p.info.interlaced_frame = false;
|
|
|
|
|
p.info.spherical = true;
|
|
|
|
|
|
|
|
|
|
// Test the name methods for spherical content
|
|
|
|
|
CHECK(p.Key() == "03840x1920p0030_02-01_360");
|
|
|
|
|
CHECK(p.ShortName() == "3840x1920p30 360°");
|
|
|
|
|
CHECK(p.LongName() == "3840x1920p @ 30 fps (2:1) 360°");
|
|
|
|
|
CHECK(p.LongNameWithDesc() == "3840x1920p @ 30 fps (2:1) 360° 360° Test Profile");
|
|
|
|
|
|
|
|
|
|
// Test JSON serialization and deserialization
|
|
|
|
|
std::string json = p.Json();
|
|
|
|
|
openshot::Profile p_json;
|
|
|
|
|
p_json.SetJson(json);
|
|
|
|
|
|
|
|
|
|
CHECK(p_json.info.spherical == true);
|
|
|
|
|
CHECK(p_json.ShortName() == "3840x1920p30 360°");
|
|
|
|
|
|
|
|
|
|
// Save and reload to test file I/O
|
2026-02-23 00:00:33 -06:00
|
|
|
const std::string profile_path = test_output_profile_path("example_profile_360");
|
|
|
|
|
p.Save(profile_path);
|
2025-05-20 16:02:23 -05:00
|
|
|
|
|
|
|
|
// Load the saved profile
|
2026-02-23 00:00:33 -06:00
|
|
|
openshot::Profile p_loaded(profile_path);
|
2025-05-20 16:02:23 -05:00
|
|
|
CHECK(p_loaded.info.spherical == true);
|
|
|
|
|
CHECK(p_loaded.ShortName() == "3840x1920p30 360°");
|
|
|
|
|
|
|
|
|
|
// Test comparison operators
|
|
|
|
|
openshot::Profile p_non_spherical = p;
|
|
|
|
|
p_non_spherical.info.spherical = false;
|
|
|
|
|
|
|
|
|
|
CHECK_FALSE(p == p_non_spherical);
|
2026-02-23 00:00:33 -06:00
|
|
|
}
|