|
33 | 33 | #define DONT_SET_USING_JUCE_NAMESPACE 1 |
34 | 34 | #include "OpenShot.h" |
35 | 35 |
|
36 | | -using namespace std; |
37 | | -using namespace openshot; |
| 36 | +SUITE(POINT) { |
38 | 37 |
|
39 | | -TEST(Point_Default_Constructor) |
| 38 | +TEST(Default_Constructor) |
| 39 | +{ |
| 40 | + openshot::Point p; |
| 41 | + |
| 42 | + // Default values |
| 43 | + CHECK_EQUAL(1, p.co.X); |
| 44 | + CHECK_EQUAL(0, p.co.Y); |
| 45 | + CHECK_EQUAL(0.5, p.handle_left.X); |
| 46 | + CHECK_EQUAL(1.0, p.handle_left.Y); |
| 47 | + CHECK_EQUAL(0.5, p.handle_right.X); |
| 48 | + CHECK_EQUAL(0.0, p.handle_right.Y); |
| 49 | + CHECK_EQUAL(openshot::InterpolationType::BEZIER, p.interpolation); |
| 50 | + CHECK_EQUAL(openshot::HandleType::AUTO, p.handle_type); |
| 51 | +} |
| 52 | +TEST(XY_Constructor) |
40 | 53 | { |
41 | 54 | // Create a point with X and Y values |
42 | 55 | openshot::Point p1(2,9); |
43 | 56 |
|
44 | 57 | CHECK_EQUAL(2, p1.co.X); |
45 | 58 | CHECK_EQUAL(9, p1.co.Y); |
46 | | - CHECK_EQUAL(BEZIER, p1.interpolation); |
| 59 | + CHECK_EQUAL(openshot::InterpolationType::BEZIER, p1.interpolation); |
47 | 60 | } |
48 | 61 |
|
49 | | -TEST(Point_Constructor_With_Coordinate) |
| 62 | +TEST(Constructor_With_Coordinate) |
50 | 63 | { |
51 | 64 | // Create a point with a coordinate |
52 | | - Coordinate c1(3,7); |
| 65 | + openshot::Coordinate c1(3,7); |
53 | 66 | openshot::Point p1(c1); |
54 | 67 |
|
55 | 68 | CHECK_EQUAL(3, p1.co.X); |
56 | 69 | CHECK_EQUAL(7, p1.co.Y); |
57 | | - CHECK_EQUAL(BEZIER, p1.interpolation); |
| 70 | + CHECK_EQUAL(openshot::InterpolationType::BEZIER, p1.interpolation); |
58 | 71 | } |
59 | 72 |
|
60 | | -TEST(Point_Constructor_With_Coordinate_And_LINEAR_Interpolation) |
| 73 | +TEST(Constructor_With_Coordinate_And_LINEAR_Interpolation) |
61 | 74 | { |
62 | 75 | // Create a point with a coordinate and interpolation |
63 | | - Coordinate c1(3,9); |
64 | | - InterpolationType interp = LINEAR; |
| 76 | + openshot::Coordinate c1(3,9); |
| 77 | + auto interp = openshot::InterpolationType::LINEAR; |
65 | 78 | openshot::Point p1(c1, interp); |
66 | 79 |
|
67 | 80 | CHECK_EQUAL(3, c1.X); |
68 | 81 | CHECK_EQUAL(9, c1.Y); |
69 | | - CHECK_EQUAL(LINEAR, p1.interpolation); |
| 82 | + CHECK_EQUAL(openshot::InterpolationType::LINEAR, p1.interpolation); |
70 | 83 | } |
71 | 84 |
|
72 | | -TEST(Point_Constructor_With_Coordinate_And_BEZIER_Interpolation) |
| 85 | +TEST(Constructor_With_Coordinate_And_BEZIER_Interpolation) |
73 | 86 | { |
74 | 87 | // Create a point with a coordinate and interpolation |
75 | | - Coordinate c1(3,9); |
76 | | - InterpolationType interp = BEZIER; |
| 88 | + openshot::Coordinate c1(3,9); |
| 89 | + auto interp = openshot::InterpolationType::BEZIER; |
77 | 90 | openshot::Point p1(c1, interp); |
78 | 91 |
|
79 | 92 | CHECK_EQUAL(3, p1.co.X); |
80 | 93 | CHECK_EQUAL(9, p1.co.Y); |
81 | | - CHECK_EQUAL(BEZIER, p1.interpolation); |
| 94 | + CHECK_EQUAL(openshot::InterpolationType::BEZIER, p1.interpolation); |
82 | 95 | } |
83 | 96 |
|
84 | | -TEST(Point_Constructor_With_Coordinate_And_CONSTANT_Interpolation) |
| 97 | +TEST(Constructor_With_Coordinate_And_CONSTANT_Interpolation) |
85 | 98 | { |
86 | 99 | // Create a point with a coordinate and interpolation |
87 | | - Coordinate c1(2,8); |
88 | | - InterpolationType interp = CONSTANT; |
| 100 | + openshot::Coordinate c1(2,8); |
| 101 | + auto interp = openshot::InterpolationType::CONSTANT; |
89 | 102 | openshot::Point p1(c1, interp); |
90 | 103 |
|
91 | 104 | CHECK_EQUAL(2, p1.co.X); |
92 | 105 | CHECK_EQUAL(8, p1.co.Y); |
93 | | - CHECK_EQUAL(CONSTANT, p1.interpolation); |
| 106 | + CHECK_EQUAL(openshot::InterpolationType::CONSTANT, p1.interpolation); |
94 | 107 | } |
95 | 108 |
|
96 | | -TEST(Point_Constructor_With_Coordinate_And_BEZIER_And_AUTO_Handle) |
| 109 | +TEST(Constructor_With_Coordinate_And_BEZIER_And_AUTO_Handle) |
97 | 110 | { |
98 | 111 | // Create a point with a coordinate and interpolation |
99 | | - Coordinate c1(3,9); |
100 | | - openshot::Point p1(c1, BEZIER, AUTO); |
| 112 | + openshot::Coordinate c1(3,9); |
| 113 | + openshot::Point p1(c1, |
| 114 | + openshot::InterpolationType::BEZIER, |
| 115 | + openshot::HandleType::AUTO); |
101 | 116 |
|
102 | 117 | CHECK_EQUAL(3, p1.co.X); |
103 | 118 | CHECK_EQUAL(9, p1.co.Y); |
104 | | - CHECK_EQUAL(BEZIER, p1.interpolation); |
105 | | - CHECK_EQUAL(AUTO, p1.handle_type); |
| 119 | + CHECK_EQUAL(openshot::InterpolationType::BEZIER, p1.interpolation); |
| 120 | + CHECK_EQUAL(openshot::HandleType::AUTO, p1.handle_type); |
106 | 121 | } |
107 | 122 |
|
108 | | -TEST(Point_Constructor_With_Coordinate_And_BEZIER_And_MANUAL_Handle) |
| 123 | +TEST(Constructor_With_Coordinate_And_BEZIER_And_MANUAL_Handle) |
109 | 124 | { |
110 | 125 | // Create a point with a coordinate and interpolation |
111 | | - Coordinate c1(3,9); |
112 | | - openshot::Point p1(c1, BEZIER, MANUAL); |
| 126 | + openshot::Coordinate c1(3,9); |
| 127 | + openshot::Point p1(c1, |
| 128 | + openshot::InterpolationType::BEZIER, |
| 129 | + openshot::HandleType::MANUAL); |
113 | 130 |
|
114 | 131 | CHECK_EQUAL(3, p1.co.X); |
115 | 132 | CHECK_EQUAL(9, p1.co.Y); |
116 | | - CHECK_EQUAL(BEZIER, p1.interpolation); |
117 | | - CHECK_EQUAL(MANUAL, p1.handle_type); |
| 133 | + CHECK_EQUAL(openshot::InterpolationType::BEZIER, p1.interpolation); |
| 134 | + CHECK_EQUAL(openshot::HandleType::MANUAL, p1.handle_type); |
| 135 | +} |
| 136 | + |
| 137 | +TEST(Json) |
| 138 | +{ |
| 139 | + openshot::Point p1; |
| 140 | + openshot::Point p2(1, 0); |
| 141 | + auto json1 = p1.Json(); |
| 142 | + auto json2 = p2.JsonValue(); |
| 143 | + auto json_string2 = json2.toStyledString(); |
| 144 | + CHECK_EQUAL(json1, json_string2); |
118 | 145 | } |
| 146 | + |
| 147 | +TEST(SetJson) |
| 148 | +{ |
| 149 | + openshot::Point p1; |
| 150 | + std::stringstream json_stream; |
| 151 | + json_stream << R"json( |
| 152 | + { |
| 153 | + "co": { "X": 1.0, "Y": 0.0 }, |
| 154 | + "handle_left": { "X": 2.0, "Y": 3.0 }, |
| 155 | + "handle_right": { "X": 4.0, "Y": -2.0 }, |
| 156 | + "handle_type": )json"; |
| 157 | + json_stream << static_cast<float>(openshot::HandleType::MANUAL) << ","; |
| 158 | + json_stream << R"json( |
| 159 | + "interpolation": )json"; |
| 160 | + json_stream << static_cast<float>(openshot::InterpolationType::CONSTANT); |
| 161 | + json_stream << R"json( |
| 162 | + } |
| 163 | + )json"; |
| 164 | + p1.SetJson(json_stream.str()); |
| 165 | + CHECK_EQUAL(2.0, p1.handle_left.X); |
| 166 | + CHECK_EQUAL(3.0, p1.handle_left.Y); |
| 167 | + CHECK_EQUAL(4.0, p1.handle_right.X); |
| 168 | + CHECK_EQUAL(-2.0, p1.handle_right.Y); |
| 169 | + CHECK_EQUAL(openshot::HandleType::MANUAL, p1.handle_type); |
| 170 | + CHECK_EQUAL(openshot::InterpolationType::CONSTANT, p1.interpolation); |
| 171 | +} |
| 172 | + |
| 173 | +} // SUITE |
0 commit comments