Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
asset_explorer_test.cpp
Go to the documentation of this file.
1/*
2 * Asset Explorer Backend Test
3 *
4 * Simple test to verify the backend asset management API
5 * This is a manual test file - compile and run separately from main project
6 */
7
9#include <iostream>
10#include <cassert>
11
12using namespace Olympe;
13
15{
16 std::cout << "=== Test: Asset Scanning ===" << std::endl;
17
19
20 // Set asset root path
21 editor.SetAssetRootPath("Blueprints");
22
23 // Get asset tree
24 auto tree = editor.GetAssetTree();
25
26 if (tree)
27 {
28 std::cout << "✓ Asset tree created successfully" << std::endl;
29 std::cout << " Root: " << tree->name << std::endl;
30 std::cout << " Children: " << tree->children.size() << std::endl;
31 }
32 else
33 {
34 std::cout << "✗ Asset tree is null" << std::endl;
35 if (editor.HasError())
36 {
37 std::cout << " Error: " << editor.GetLastError() << std::endl;
38 }
39 }
40
41 std::cout << std::endl;
42}
43
45{
46 std::cout << "=== Test: Asset Queries ===" << std::endl;
47
49
50 // Get all assets
51 auto allAssets = editor.GetAllAssets();
52 std::cout << "Total assets: " << allAssets.size() << std::endl;
53
54 // Get assets by type
55 auto entityBlueprints = editor.GetAssetsByType("EntityBlueprint");
56 std::cout << "EntityBlueprints: " << entityBlueprints.size() << std::endl;
57
58 auto behaviorTrees = editor.GetAssetsByType("BehaviorTree");
59 std::cout << "BehaviorTrees: " << behaviorTrees.size() << std::endl;
60
61 std::cout << std::endl;
62}
63
65{
66 std::cout << "=== Test: Asset Search ===" << std::endl;
67
69
70 // Search for "guard"
71 auto results = editor.SearchAssets("guard");
72 std::cout << "Search 'guard': " << results.size() << " results" << std::endl;
73
74 for (const auto& asset : results)
75 {
76 std::cout << " - " << asset.name << " [" << asset.type << "]" << std::endl;
77 }
78
79 std::cout << std::endl;
80}
81
83{
84 std::cout << "=== Test: Asset Metadata ===" << std::endl;
85
87
88 // Test entity blueprint
89 auto metadata = editor.GetAssetMetadata("Blueprints/example_entity_simple.json");
90
91 if (metadata.isValid)
92 {
93 std::cout << "✓ Entity Blueprint loaded successfully" << std::endl;
94 std::cout << " Name: " << metadata.name << std::endl;
95 std::cout << " Type: " << metadata.type << std::endl;
96 std::cout << " Description: " << metadata.description << std::endl;
97 std::cout << " Components: " << metadata.componentCount << std::endl;
98
99 for (const auto& comp : metadata.components)
100 {
101 std::cout << " - " << comp << std::endl;
102 }
103 }
104 else
105 {
106 std::cout << "✗ Failed to load entity blueprint" << std::endl;
107 std::cout << " Error: " << metadata.errorMessage << std::endl;
108 }
109
110 std::cout << std::endl;
111}
112
114{
115 std::cout << "=== Test: Error Handling ===" << std::endl;
116
118
119 // Test with non-existent file
120 auto metadata = editor.GetAssetMetadata("Blueprints/nonexistent.json");
121
122 if (!metadata.isValid)
123 {
124 std::cout << "✓ Error handling works correctly" << std::endl;
125 std::cout << " Expected error: " << metadata.errorMessage << std::endl;
126 }
127 else
128 {
129 std::cout << "✗ Should have failed for non-existent file" << std::endl;
130 }
131
132 std::cout << std::endl;
133}
134
136{
137 std::cout << "=== Test: Multi-Folder Navigation ===" << std::endl;
138
140
141 auto tree = editor.GetAssetTree();
142
143 if (!tree)
144 {
145 std::cout << "✗ No asset tree available" << std::endl;
146 return;
147 }
148
149 std::cout << "Root directory: " << tree->name << std::endl;
150
151 // Count directories and files
152 int dirCount = 0;
153 int fileCount = 0;
154
155 std::function<void(const std::shared_ptr<AssetNode>&, int)> traverse =
156 [&](const std::shared_ptr<AssetNode>& node, int depth)
157 {
158 std::string indent(depth * 2, ' ');
159
160 if (node->isDirectory)
161 {
162 dirCount++;
163 std::cout << indent << "[DIR] " << node->name << std::endl;
164
165 for (const auto& child : node->children)
166 {
167 traverse(child, depth + 1);
168 }
169 }
170 else
171 {
172 fileCount++;
173 std::cout << indent << "[FILE] " << node->name << " [" << node->type << "]" << std::endl;
174 }
175 };
176
177 for (const auto& child : tree->children)
178 {
179 traverse(child, 0);
180 }
181
182 std::cout << "\nSummary:" << std::endl;
183 std::cout << " Directories: " << dirCount << std::endl;
184 std::cout << " Files: " << fileCount << std::endl;
185
186 std::cout << std::endl;
187}
188
189int main()
190{
191 std::cout << "=====================================" << std::endl;
192 std::cout << " Asset Explorer Backend Test Suite" << std::endl;
193 std::cout << "=====================================" << std::endl;
194 std::cout << std::endl;
195
196 // Initialize the editor
198
199 // Run tests
206
207 std::cout << "=====================================" << std::endl;
208 std::cout << " Test Suite Complete" << std::endl;
209 std::cout << "=====================================" << std::endl;
210
211 return 0;
212}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
void TestAssetQueries()
void TestMultiFolderNavigation()
void TestAssetScanning()
void TestAssetMetadata()
void TestAssetSearch()
int main()
void TestErrorHandling()
static BlueprintEditor & Get()