ResourceLoaderMediaTests.cpp 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. #include "Wwise/WwiseUnitTests.h"
  16. #if WWISE_UNIT_TESTS
  17. #include "Wwise/WwiseResourceLoaderImpl.h"
  18. #include "Wwise/Mock/WwiseMockExternalSourceManager.h"
  19. #include "Wwise/Mock/WwiseMockMediaManager.h"
  20. #include "Wwise/Mock/WwiseMockSoundBankManager.h"
  21. #include <array>
  22. #include <atomic>
  23. WWISE_TEST_CASE(ResourceLoader_Media, "Wwise::ResourceLoader::ResourceLoader_Media", "[ApplicationContextMask][SmokeFilter]")
  24. {
  25. SECTION("Static")
  26. {
  27. static_assert(std::is_constructible<FWwiseResourceLoaderImpl>::value, "Resource Loader must be constructed without parameters");
  28. static_assert(!std::is_copy_constructible<FWwiseResourceLoaderImpl>::value, "Cannot copy a Resource Loader");
  29. static_assert(!std::is_copy_assignable<FWwiseResourceLoaderImpl>::value, "Cannot reassign a Resource Loader");
  30. static_assert(!std::is_move_constructible<FWwiseResourceLoaderImpl>::value, "Cannot move a Resource Loader");
  31. }
  32. SECTION("Instantiation")
  33. {
  34. FWwiseResourceLoaderImpl ResourceLoaderImpl;
  35. }
  36. SECTION("Singular Event")
  37. {
  38. FWwiseMockExternalSourceManager ExternalSourceManager;
  39. FWwiseMockMediaManager MediaManager;
  40. FWwiseMockSoundBankManager SoundBankManager;
  41. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  42. FWwiseLocalizedEventCookedData CookedData;
  43. {
  44. FWwiseEventCookedData Data1;
  45. FWwiseSoundBankCookedData SoundBank1;
  46. SoundBank1.SoundBankId = 1;
  47. Data1.SoundBanks.Emplace(SoundBank1);
  48. FWwiseMediaCookedData Media1;
  49. Media1.MediaId = 1;
  50. Data1.Media.Emplace(MoveTemp(Media1));
  51. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  52. }
  53. // Creating Node
  54. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  55. CHECK(Node);
  56. if (UNLIKELY(!Node))
  57. {
  58. return;
  59. }
  60. // Loading Node
  61. FWwiseLoadedEventPromise LoadPromise;
  62. auto LoadFuture = LoadPromise.GetFuture();
  63. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  64. auto Loaded = LoadFuture.Get(); // Synchronously
  65. CHECK(Loaded);
  66. if (UNLIKELY(!Loaded))
  67. {
  68. return;
  69. }
  70. CHECK(MediaManager.IsMediaLoaded(1));
  71. // Unloading Node
  72. FWwiseResourceUnloadPromise UnloadPromise;
  73. auto UnloadFuture = UnloadPromise.GetFuture();
  74. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(Loaded));
  75. UnloadFuture.Get(); // Synchronously
  76. CHECK(ExternalSourceManager.IsEmpty());
  77. CHECK(MediaManager.IsEmpty());
  78. CHECK(SoundBankManager.IsEmpty());
  79. CHECK(ResourceLoaderImpl.IsEmpty());
  80. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  81. }
  82. SECTION("Singular Event with required key")
  83. {
  84. FWwiseMockExternalSourceManager ExternalSourceManager;
  85. FWwiseMockMediaManager MediaManager;
  86. FWwiseMockSoundBankManager SoundBankManager;
  87. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  88. FWwiseGroupValueCookedData GroupValue;
  89. GroupValue.Id = 1;
  90. GroupValue.GroupId = 1;
  91. GroupValue.Type = EWwiseGroupType::Switch;
  92. FWwiseLocalizedEventCookedData CookedData;
  93. {
  94. FWwiseEventCookedData Data1;
  95. FWwiseSoundBankCookedData SoundBank1;
  96. SoundBank1.SoundBankId = 1;
  97. Data1.SoundBanks.Emplace(SoundBank1);
  98. FWwiseSwitchContainerLeafCookedData Leaf1;
  99. FWwiseMediaCookedData Leaf1Media;
  100. Leaf1Media.MediaId = 3;
  101. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  102. Leaf1.GroupValueSet.Emplace(GroupValue);
  103. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  104. Data1.RequiredGroupValueSet.Add(GroupValue);
  105. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  106. }
  107. // Creating Node
  108. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  109. CHECK(Node);
  110. if (UNLIKELY(!Node))
  111. {
  112. return;
  113. }
  114. // Loading Node
  115. FWwiseLoadedEventPromise LoadPromise;
  116. auto LoadFuture = LoadPromise.GetFuture();
  117. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  118. auto Loaded = LoadFuture.Get(); // Synchronously
  119. CHECK(Loaded);
  120. if (UNLIKELY(!Loaded))
  121. {
  122. return;
  123. }
  124. CHECK(MediaManager.IsMediaLoaded(3));
  125. // Unloading Node
  126. FWwiseResourceUnloadPromise UnloadPromise;
  127. auto UnloadFuture = UnloadPromise.GetFuture();
  128. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(Loaded));
  129. UnloadFuture.Get(); // Synchronously
  130. CHECK(!MediaManager.IsMediaLoaded(3));
  131. CHECK(ExternalSourceManager.IsEmpty());
  132. CHECK(MediaManager.IsEmpty());
  133. CHECK(SoundBankManager.IsEmpty());
  134. CHECK(ResourceLoaderImpl.IsEmpty());
  135. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  136. }
  137. SECTION("Another Event Loads the required Key for an Event")
  138. {
  139. FWwiseMockExternalSourceManager ExternalSourceManager;
  140. FWwiseMockMediaManager MediaManager;
  141. FWwiseMockSoundBankManager SoundBankManager;
  142. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  143. FWwiseGroupValueCookedData GroupValue;
  144. GroupValue.Id = 1;
  145. GroupValue.GroupId = 1;
  146. GroupValue.Type = EWwiseGroupType::Switch;
  147. FWwiseLocalizedEventCookedData CookedData;
  148. {
  149. FWwiseEventCookedData Data1;
  150. FWwiseSoundBankCookedData SoundBank1;
  151. SoundBank1.SoundBankId = 1;
  152. Data1.SoundBanks.Emplace(SoundBank1);
  153. Data1.RequiredGroupValueSet.Add(GroupValue);
  154. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  155. }
  156. // Creating Node
  157. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  158. CHECK(Node);
  159. if (UNLIKELY(!Node))
  160. {
  161. return;
  162. }
  163. FWwiseLocalizedEventCookedData CookedData2;
  164. {
  165. FWwiseEventCookedData Data2;
  166. FWwiseSoundBankCookedData SoundBank2;
  167. SoundBank2.SoundBankId = 2;
  168. Data2.SoundBanks.Emplace(SoundBank2);
  169. FWwiseSwitchContainerLeafCookedData Leaf1;
  170. FWwiseMediaCookedData Leaf1Media;
  171. Leaf1Media.MediaId = 3;
  172. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  173. Leaf1.GroupValueSet.Emplace(GroupValue);
  174. Data2.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  175. CookedData2.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data2));
  176. }
  177. // Creating Node
  178. auto* Node2 = ResourceLoaderImpl.CreateEventNode(CookedData2, nullptr);
  179. CHECK(Node2);
  180. if (UNLIKELY(!Node2))
  181. {
  182. return;
  183. }
  184. CHECK(!MediaManager.IsMediaLoaded(3));
  185. // Loading Node2
  186. FWwiseLoadedEventPromise LoadPromise2;
  187. auto LoadFuture2 = LoadPromise2.GetFuture();
  188. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise2), MoveTemp(Node2));
  189. auto Loaded2 = LoadFuture2.Get(); // Synchronously
  190. CHECK(Loaded2);
  191. if (UNLIKELY(!Loaded2))
  192. {
  193. return;
  194. }
  195. CHECK(!MediaManager.IsMediaLoaded(3));
  196. // Loading Node
  197. FWwiseLoadedEventPromise LoadPromise;
  198. auto LoadFuture = LoadPromise.GetFuture();
  199. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  200. auto Loaded = LoadFuture.Get(); // Synchronously
  201. CHECK(Loaded);
  202. if (UNLIKELY(!Loaded))
  203. {
  204. return;
  205. }
  206. CHECK(MediaManager.IsMediaLoaded(3));
  207. // Unloading Node
  208. FWwiseResourceUnloadPromise UnloadPromise;
  209. auto UnloadFuture = UnloadPromise.GetFuture();
  210. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(Loaded));
  211. UnloadFuture.Get(); // Synchronously
  212. // Unloading Node
  213. FWwiseResourceUnloadPromise UnloadPromise2;
  214. auto UnloadFuture2 = UnloadPromise2.GetFuture();
  215. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise2), MoveTemp(Loaded2));
  216. UnloadFuture2.Get(); // Synchronously
  217. CHECK(!MediaManager.IsMediaLoaded(3));
  218. CHECK(ExternalSourceManager.IsEmpty());
  219. CHECK(MediaManager.IsEmpty());
  220. CHECK(SoundBankManager.IsEmpty());
  221. CHECK(ResourceLoaderImpl.IsEmpty());
  222. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  223. }
  224. SECTION("Required Switch Container Not Loaded")
  225. {
  226. FWwiseMockExternalSourceManager ExternalSourceManager;
  227. FWwiseMockMediaManager MediaManager;
  228. FWwiseMockSoundBankManager SoundBankManager;
  229. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  230. FWwiseGroupValueCookedData GroupValue;
  231. GroupValue.Id = 1;
  232. GroupValue.GroupId = 1;
  233. GroupValue.Type = EWwiseGroupType::Switch;
  234. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  235. FWwiseLoadedGroupValuePtr LoadedGroupValue{nullptr};
  236. // Load Event
  237. do
  238. {
  239. FWwiseLocalizedEventCookedData CookedData;
  240. {
  241. FWwiseEventCookedData Data1;
  242. Data1.Media.Emplace(FWwiseMediaCookedData{});
  243. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  244. FWwiseSwitchContainerLeafCookedData Leaf1;
  245. FWwiseMediaCookedData Leaf1Media;
  246. Leaf1Media.MediaId = 3;
  247. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  248. Leaf1.GroupValueSet.Emplace(GroupValue);
  249. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  250. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  251. }
  252. // Creating Node
  253. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  254. CHECK(Node);
  255. if (UNLIKELY(!Node))
  256. {
  257. break;
  258. }
  259. // Loading Node
  260. FWwiseLoadedEventPromise LoadPromise;
  261. auto LoadFuture = LoadPromise.GetFuture();
  262. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  263. LoadedEvent = LoadFuture.Get(); // Synchronously
  264. CHECK(LoadedEvent);
  265. if (UNLIKELY(!LoadedEvent))
  266. {
  267. break;
  268. }
  269. }
  270. while (false);
  271. check(!MediaManager.IsMediaLoaded(1));
  272. // Unloading Event
  273. if (LIKELY(LoadedEvent))
  274. {
  275. FWwiseResourceUnloadPromise UnloadPromise;
  276. auto UnloadFuture = UnloadPromise.GetFuture();
  277. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  278. UnloadFuture.Get(); // Synchronously
  279. }
  280. CHECK(ExternalSourceManager.IsEmpty());
  281. CHECK(MediaManager.IsEmpty());
  282. CHECK(SoundBankManager.IsEmpty());
  283. CHECK(ResourceLoaderImpl.IsEmpty());
  284. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  285. }
  286. SECTION("Loading Event Before Switch Container")
  287. {
  288. FWwiseMockExternalSourceManager ExternalSourceManager;
  289. FWwiseMockMediaManager MediaManager;
  290. FWwiseMockSoundBankManager SoundBankManager;
  291. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  292. FWwiseGroupValueCookedData GroupValue;
  293. GroupValue.Id = 1;
  294. GroupValue.GroupId = 1;
  295. GroupValue.Type = EWwiseGroupType::Switch;
  296. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  297. FWwiseLoadedGroupValuePtr LoadedGroupValue{nullptr};
  298. // Load Event
  299. do
  300. {
  301. FWwiseLocalizedEventCookedData CookedData;
  302. {
  303. FWwiseEventCookedData Data1;
  304. Data1.Media.Emplace(FWwiseMediaCookedData{});
  305. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  306. FWwiseSwitchContainerLeafCookedData Leaf1;
  307. FWwiseMediaCookedData Leaf1Media;
  308. Leaf1Media.MediaId = 1;
  309. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  310. Leaf1.GroupValueSet.Emplace(GroupValue);
  311. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  312. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  313. }
  314. // Creating Node
  315. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  316. CHECK(Node);
  317. if (UNLIKELY(!Node))
  318. {
  319. break;
  320. }
  321. // Loading Node
  322. FWwiseLoadedEventPromise LoadPromise;
  323. auto LoadFuture = LoadPromise.GetFuture();
  324. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  325. LoadedEvent = LoadFuture.Get(); // Synchronously
  326. CHECK(LoadedEvent);
  327. if (UNLIKELY(!LoadedEvent))
  328. {
  329. break;
  330. }
  331. }
  332. while (false);
  333. // Load GroupValue
  334. do
  335. {
  336. // Creating Node
  337. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue);
  338. CHECK(Node);
  339. if (UNLIKELY(!Node))
  340. {
  341. break;
  342. }
  343. // Loading Node
  344. FWwiseLoadedGroupValuePromise LoadPromise;
  345. auto LoadFuture = LoadPromise.GetFuture();
  346. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  347. LoadedGroupValue = LoadFuture.Get(); // Synchronously
  348. CHECK(LoadedGroupValue);
  349. if (UNLIKELY(!LoadedGroupValue))
  350. {
  351. break;
  352. }
  353. }
  354. while(false);
  355. CHECK(MediaManager.IsMediaLoaded(1));
  356. // Unloading GroupValue
  357. if (LIKELY(LoadedGroupValue))
  358. {
  359. FWwiseResourceUnloadPromise UnloadPromise;
  360. auto UnloadFuture = UnloadPromise.GetFuture();
  361. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue));
  362. UnloadFuture.Get(); // Synchronously
  363. }
  364. CHECK(!MediaManager.IsMediaLoaded(1));
  365. // Unloading Event
  366. if (LIKELY(LoadedEvent))
  367. {
  368. FWwiseResourceUnloadPromise UnloadPromise;
  369. auto UnloadFuture = UnloadPromise.GetFuture();
  370. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  371. UnloadFuture.Get(); // Synchronously
  372. }
  373. CHECK(ExternalSourceManager.IsEmpty());
  374. CHECK(MediaManager.IsEmpty());
  375. CHECK(SoundBankManager.IsEmpty());
  376. CHECK(ResourceLoaderImpl.IsEmpty());
  377. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  378. }
  379. SECTION("Loading Event After Switch Container")
  380. {
  381. FWwiseMockExternalSourceManager ExternalSourceManager;
  382. FWwiseMockMediaManager MediaManager;
  383. FWwiseMockSoundBankManager SoundBankManager;
  384. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  385. FWwiseGroupValueCookedData GroupValue;
  386. GroupValue.Id = 1;
  387. GroupValue.GroupId = 1;
  388. GroupValue.Type = EWwiseGroupType::Switch;
  389. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  390. FWwiseLoadedGroupValuePtr LoadedGroupValue{nullptr};
  391. // Load GroupValue
  392. do
  393. {
  394. // Creating Node
  395. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue);
  396. CHECK(Node);
  397. if (UNLIKELY(!Node))
  398. {
  399. break;
  400. }
  401. // Loading Node
  402. FWwiseLoadedGroupValuePromise LoadPromise;
  403. auto LoadFuture = LoadPromise.GetFuture();
  404. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  405. LoadedGroupValue = LoadFuture.Get(); // Synchronously
  406. CHECK(LoadedGroupValue);
  407. if (UNLIKELY(!LoadedGroupValue))
  408. {
  409. break;
  410. }
  411. }
  412. while(false);
  413. // Load Event
  414. do
  415. {
  416. FWwiseLocalizedEventCookedData CookedData;
  417. {
  418. FWwiseEventCookedData Data1;
  419. Data1.Media.Emplace(FWwiseMediaCookedData{});
  420. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  421. FWwiseSwitchContainerLeafCookedData Leaf1;
  422. FWwiseMediaCookedData Leaf1Media;
  423. Leaf1Media.MediaId = 1;
  424. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  425. Leaf1.GroupValueSet.Emplace(GroupValue);
  426. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  427. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  428. }
  429. // Creating Node
  430. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  431. CHECK(Node);
  432. if (UNLIKELY(!Node))
  433. {
  434. break;
  435. }
  436. // Loading Node
  437. FWwiseLoadedEventPromise LoadPromise;
  438. auto LoadFuture = LoadPromise.GetFuture();
  439. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  440. LoadedEvent = LoadFuture.Get(); // Synchronously
  441. CHECK(LoadedEvent);
  442. if (UNLIKELY(!LoadedEvent))
  443. {
  444. break;
  445. }
  446. }
  447. while (false);
  448. CHECK(MediaManager.IsMediaLoaded(1));
  449. // Unloading Event
  450. if (LIKELY(LoadedEvent))
  451. {
  452. FWwiseResourceUnloadPromise UnloadPromise;
  453. auto UnloadFuture = UnloadPromise.GetFuture();
  454. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  455. UnloadFuture.Get(); // Synchronously
  456. }
  457. // Unloading GroupValue
  458. if (LIKELY(LoadedGroupValue))
  459. {
  460. FWwiseResourceUnloadPromise UnloadPromise;
  461. auto UnloadFuture = UnloadPromise.GetFuture();
  462. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue));
  463. UnloadFuture.Get(); // Synchronously
  464. }
  465. CHECK(!MediaManager.IsMediaLoaded(1));
  466. CHECK(ExternalSourceManager.IsEmpty());
  467. CHECK(MediaManager.IsEmpty());
  468. CHECK(SoundBankManager.IsEmpty());
  469. CHECK(ResourceLoaderImpl.IsEmpty());
  470. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  471. }
  472. SECTION("Sync 2 SwitchContainer with same ID")
  473. {
  474. FWwiseMockExternalSourceManager ExternalSourceManager;
  475. FWwiseMockMediaManager MediaManager;
  476. FWwiseMockSoundBankManager SoundBankManager;
  477. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  478. FWwiseGroupValueCookedData GroupValue;
  479. GroupValue.Id = 1;
  480. GroupValue.GroupId = 1;
  481. GroupValue.Type = EWwiseGroupType::Switch;
  482. FWwiseGroupValueCookedData GroupValue2;
  483. GroupValue2.Id = 1;
  484. GroupValue2.GroupId = 1;
  485. GroupValue2.Type = EWwiseGroupType::Switch;
  486. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  487. FWwiseLoadedGroupValuePtr LoadedGroupValue{nullptr};
  488. FWwiseLoadedGroupValuePtr LoadedGroupValue2{nullptr};
  489. // Load GroupValue
  490. do
  491. {
  492. // Creating Node
  493. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue);
  494. CHECK(Node);
  495. if (UNLIKELY(!Node))
  496. {
  497. break;
  498. }
  499. // Loading Node
  500. FWwiseLoadedGroupValuePromise LoadPromise;
  501. auto LoadFuture = LoadPromise.GetFuture();
  502. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  503. LoadedGroupValue = LoadFuture.Get(); // Synchronously
  504. CHECK(LoadedGroupValue);
  505. if (UNLIKELY(!LoadedGroupValue))
  506. {
  507. break;
  508. }
  509. }
  510. while(false);
  511. // Load GroupValue2
  512. do
  513. {
  514. // Creating Node
  515. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue2);
  516. CHECK(Node);
  517. if (UNLIKELY(!Node))
  518. {
  519. break;
  520. }
  521. // Loading Node
  522. FWwiseLoadedGroupValuePromise LoadPromise;
  523. auto LoadFuture = LoadPromise.GetFuture();
  524. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  525. LoadedGroupValue2 = LoadFuture.Get(); // Synchronously
  526. CHECK(LoadedGroupValue2);
  527. if (UNLIKELY(!LoadedGroupValue2))
  528. {
  529. break;
  530. }
  531. }
  532. while(false);
  533. // Load Event
  534. do
  535. {
  536. FWwiseLocalizedEventCookedData CookedData;
  537. {
  538. FWwiseEventCookedData Data1;
  539. Data1.Media.Emplace(FWwiseMediaCookedData{});
  540. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  541. FWwiseSwitchContainerLeafCookedData Leaf1;
  542. FWwiseMediaCookedData Leaf1Media;
  543. Leaf1Media.MediaId = 1;
  544. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  545. Leaf1.GroupValueSet.Emplace(GroupValue);
  546. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  547. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  548. }
  549. // Creating Node
  550. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  551. CHECK(Node);
  552. if (UNLIKELY(!Node))
  553. {
  554. break;
  555. }
  556. // Loading Node
  557. FWwiseLoadedEventPromise LoadPromise;
  558. auto LoadFuture = LoadPromise.GetFuture();
  559. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  560. LoadedEvent = LoadFuture.Get(); // Synchronously
  561. CHECK(LoadedEvent);
  562. if (UNLIKELY(!LoadedEvent))
  563. {
  564. break;
  565. }
  566. }
  567. while (false);
  568. CHECK(MediaManager.IsMediaLoaded(1));
  569. // Unloading GroupValue
  570. if (LIKELY(LoadedGroupValue))
  571. {
  572. FWwiseResourceUnloadPromise UnloadPromise;
  573. auto UnloadFuture = UnloadPromise.GetFuture();
  574. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue));
  575. UnloadFuture.Get(); // Synchronously
  576. }
  577. CHECK(MediaManager.IsMediaLoaded(1));
  578. if (LIKELY(LoadedGroupValue2))
  579. {
  580. FWwiseResourceUnloadPromise UnloadPromise;
  581. auto UnloadFuture = UnloadPromise.GetFuture();
  582. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue2));
  583. UnloadFuture.Get(); // Synchronously
  584. }
  585. CHECK(!MediaManager.IsMediaLoaded(1));
  586. // Unloading Event
  587. if (LIKELY(LoadedEvent))
  588. {
  589. FWwiseResourceUnloadPromise UnloadPromise;
  590. auto UnloadFuture = UnloadPromise.GetFuture();
  591. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  592. UnloadFuture.Get(); // Synchronously
  593. }
  594. CHECK(!MediaManager.IsMediaLoaded(1));
  595. CHECK(ExternalSourceManager.IsEmpty());
  596. CHECK(MediaManager.IsEmpty());
  597. CHECK(SoundBankManager.IsEmpty());
  598. CHECK(ResourceLoaderImpl.IsEmpty());
  599. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  600. }
  601. SECTION("2 SwitchContainer with different ID (media requires first SwitchContainer)")
  602. {
  603. FWwiseMockExternalSourceManager ExternalSourceManager;
  604. FWwiseMockMediaManager MediaManager;
  605. FWwiseMockSoundBankManager SoundBankManager;
  606. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  607. FWwiseGroupValueCookedData GroupValue;
  608. GroupValue.Id = 1;
  609. GroupValue.GroupId = 1;
  610. GroupValue.Type = EWwiseGroupType::Switch;
  611. FWwiseGroupValueCookedData GroupValue2;
  612. GroupValue2.Id = 2;
  613. GroupValue2.GroupId = 2;
  614. GroupValue2.Type = EWwiseGroupType::Switch;
  615. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  616. FWwiseLoadedGroupValuePtr LoadedGroupValue{nullptr};
  617. FWwiseLoadedGroupValuePtr LoadedGroupValue2{nullptr};
  618. // Load GroupValue
  619. do
  620. {
  621. // Creating Node
  622. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue);
  623. CHECK(Node);
  624. if (UNLIKELY(!Node))
  625. {
  626. break;
  627. }
  628. // Loading Node
  629. FWwiseLoadedGroupValuePromise LoadPromise;
  630. auto LoadFuture = LoadPromise.GetFuture();
  631. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  632. LoadedGroupValue = LoadFuture.Get(); // Synchronously
  633. CHECK(LoadedGroupValue);
  634. if (UNLIKELY(!LoadedGroupValue))
  635. {
  636. break;
  637. }
  638. }
  639. while(false);
  640. // Load GroupValue2
  641. do
  642. {
  643. // Creating Node
  644. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue2);
  645. CHECK(Node);
  646. if (UNLIKELY(!Node))
  647. {
  648. break;
  649. }
  650. // Loading Node
  651. FWwiseLoadedGroupValuePromise LoadPromise;
  652. auto LoadFuture = LoadPromise.GetFuture();
  653. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  654. LoadedGroupValue2 = LoadFuture.Get(); // Synchronously
  655. CHECK(LoadedGroupValue2);
  656. if (UNLIKELY(!LoadedGroupValue2))
  657. {
  658. break;
  659. }
  660. }
  661. while(false);
  662. // Load Event
  663. do
  664. {
  665. FWwiseLocalizedEventCookedData CookedData;
  666. {
  667. FWwiseEventCookedData Data1;
  668. Data1.Media.Emplace(FWwiseMediaCookedData{});
  669. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  670. FWwiseSwitchContainerLeafCookedData Leaf1;
  671. FWwiseMediaCookedData Leaf1Media;
  672. Leaf1Media.MediaId = 1;
  673. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  674. Leaf1.GroupValueSet.Emplace(GroupValue);
  675. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  676. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  677. }
  678. // Creating Node
  679. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  680. CHECK(Node);
  681. if (UNLIKELY(!Node))
  682. {
  683. break;
  684. }
  685. // Loading Node
  686. FWwiseLoadedEventPromise LoadPromise;
  687. auto LoadFuture = LoadPromise.GetFuture();
  688. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  689. LoadedEvent = LoadFuture.Get(); // Synchronously
  690. CHECK(LoadedEvent);
  691. if (UNLIKELY(!LoadedEvent))
  692. {
  693. break;
  694. }
  695. }
  696. while (false);
  697. CHECK(MediaManager.IsMediaLoaded(1));
  698. // Unloading GroupValue
  699. if (LIKELY(LoadedGroupValue))
  700. {
  701. FWwiseResourceUnloadPromise UnloadPromise;
  702. auto UnloadFuture = UnloadPromise.GetFuture();
  703. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue));
  704. UnloadFuture.Get(); // Synchronously
  705. }
  706. CHECK(!MediaManager.IsMediaLoaded(1));
  707. if (LIKELY(LoadedGroupValue2))
  708. {
  709. FWwiseResourceUnloadPromise UnloadPromise;
  710. auto UnloadFuture = UnloadPromise.GetFuture();
  711. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue2));
  712. UnloadFuture.Get(); // Synchronously
  713. }
  714. CHECK(!MediaManager.IsMediaLoaded(1));
  715. // Unloading Event
  716. if (LIKELY(LoadedEvent))
  717. {
  718. FWwiseResourceUnloadPromise UnloadPromise;
  719. auto UnloadFuture = UnloadPromise.GetFuture();
  720. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  721. UnloadFuture.Get(); // Synchronously
  722. }
  723. CHECK(!MediaManager.IsMediaLoaded(1));
  724. CHECK(ExternalSourceManager.IsEmpty());
  725. CHECK(MediaManager.IsEmpty());
  726. CHECK(SoundBankManager.IsEmpty());
  727. CHECK(ResourceLoaderImpl.IsEmpty());
  728. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  729. }
  730. SECTION("2 SwitchContainer with different ID (media requires second SwitchContainer)")
  731. {
  732. FWwiseMockExternalSourceManager ExternalSourceManager;
  733. FWwiseMockMediaManager MediaManager;
  734. FWwiseMockSoundBankManager SoundBankManager;
  735. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  736. FWwiseGroupValueCookedData GroupValue;
  737. GroupValue.Id = 1;
  738. GroupValue.GroupId = 1;
  739. GroupValue.Type = EWwiseGroupType::Switch;
  740. FWwiseGroupValueCookedData GroupValue2;
  741. GroupValue2.Id = 2;
  742. GroupValue2.GroupId = 2;
  743. GroupValue2.Type = EWwiseGroupType::Switch;
  744. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  745. FWwiseLoadedGroupValuePtr LoadedGroupValue{nullptr};
  746. FWwiseLoadedGroupValuePtr LoadedGroupValue2{nullptr};
  747. // Load GroupValue
  748. do
  749. {
  750. // Creating Node
  751. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue);
  752. CHECK(Node);
  753. if (UNLIKELY(!Node))
  754. {
  755. break;
  756. }
  757. // Loading Node
  758. FWwiseLoadedGroupValuePromise LoadPromise;
  759. auto LoadFuture = LoadPromise.GetFuture();
  760. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  761. LoadedGroupValue = LoadFuture.Get(); // Synchronously
  762. CHECK(LoadedGroupValue);
  763. if (UNLIKELY(!LoadedGroupValue))
  764. {
  765. break;
  766. }
  767. }
  768. while(false);
  769. // Load GroupValue2
  770. do
  771. {
  772. // Creating Node
  773. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue2);
  774. CHECK(Node);
  775. if (UNLIKELY(!Node))
  776. {
  777. break;
  778. }
  779. // Loading Node
  780. FWwiseLoadedGroupValuePromise LoadPromise;
  781. auto LoadFuture = LoadPromise.GetFuture();
  782. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  783. LoadedGroupValue2 = LoadFuture.Get(); // Synchronously
  784. CHECK(LoadedGroupValue2);
  785. if (UNLIKELY(!LoadedGroupValue2))
  786. {
  787. break;
  788. }
  789. }
  790. while(false);
  791. // Load Event
  792. do
  793. {
  794. FWwiseLocalizedEventCookedData CookedData;
  795. {
  796. FWwiseEventCookedData Data1;
  797. Data1.Media.Emplace(FWwiseMediaCookedData{});
  798. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  799. FWwiseSwitchContainerLeafCookedData Leaf1;
  800. FWwiseMediaCookedData Leaf1Media;
  801. Leaf1Media.MediaId = 1;
  802. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  803. Leaf1.GroupValueSet.Emplace(GroupValue2);
  804. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  805. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  806. }
  807. // Creating Node
  808. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  809. CHECK(Node);
  810. if (UNLIKELY(!Node))
  811. {
  812. break;
  813. }
  814. // Loading Node
  815. FWwiseLoadedEventPromise LoadPromise;
  816. auto LoadFuture = LoadPromise.GetFuture();
  817. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  818. LoadedEvent = LoadFuture.Get(); // Synchronously
  819. CHECK(LoadedEvent);
  820. if (UNLIKELY(!LoadedEvent))
  821. {
  822. break;
  823. }
  824. }
  825. while (false);
  826. CHECK(MediaManager.IsMediaLoaded(1));
  827. // Unloading GroupValue
  828. if (LIKELY(LoadedGroupValue))
  829. {
  830. FWwiseResourceUnloadPromise UnloadPromise;
  831. auto UnloadFuture = UnloadPromise.GetFuture();
  832. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue));
  833. UnloadFuture.Get(); // Synchronously
  834. }
  835. CHECK(MediaManager.IsMediaLoaded(1));
  836. if (LIKELY(LoadedGroupValue2))
  837. {
  838. FWwiseResourceUnloadPromise UnloadPromise;
  839. auto UnloadFuture = UnloadPromise.GetFuture();
  840. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue2));
  841. UnloadFuture.Get(); // Synchronously
  842. }
  843. CHECK(!MediaManager.IsMediaLoaded(1));
  844. // Unloading Event
  845. if (LIKELY(LoadedEvent))
  846. {
  847. FWwiseResourceUnloadPromise UnloadPromise;
  848. auto UnloadFuture = UnloadPromise.GetFuture();
  849. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  850. UnloadFuture.Get(); // Synchronously
  851. }
  852. CHECK(!MediaManager.IsMediaLoaded(1));
  853. CHECK(ExternalSourceManager.IsEmpty());
  854. CHECK(MediaManager.IsEmpty());
  855. CHECK(SoundBankManager.IsEmpty());
  856. CHECK(ResourceLoaderImpl.IsEmpty());
  857. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  858. }
  859. SECTION("2 SwitchContainer with different ID (media requires both SwitchContainer)")
  860. {
  861. FWwiseMockExternalSourceManager ExternalSourceManager;
  862. FWwiseMockMediaManager MediaManager;
  863. FWwiseMockSoundBankManager SoundBankManager;
  864. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  865. FWwiseGroupValueCookedData GroupValue;
  866. GroupValue.Id = 1;
  867. GroupValue.GroupId = 1;
  868. GroupValue.Type = EWwiseGroupType::Switch;
  869. FWwiseGroupValueCookedData GroupValue2;
  870. GroupValue2.Id = 2;
  871. GroupValue2.GroupId = 2;
  872. GroupValue2.Type = EWwiseGroupType::Switch;
  873. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  874. FWwiseLoadedGroupValuePtr LoadedGroupValue{nullptr};
  875. FWwiseLoadedGroupValuePtr LoadedGroupValue2{nullptr};
  876. // Load Event
  877. do
  878. {
  879. FWwiseLocalizedEventCookedData CookedData;
  880. {
  881. FWwiseEventCookedData Data1;
  882. Data1.Media.Emplace(FWwiseMediaCookedData{});
  883. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  884. FWwiseSwitchContainerLeafCookedData Leaf1;
  885. FWwiseMediaCookedData Leaf1Media;
  886. Leaf1Media.MediaId = 1;
  887. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  888. Leaf1.GroupValueSet.Emplace(GroupValue2);
  889. Leaf1.GroupValueSet.Add(GroupValue);
  890. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  891. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  892. }
  893. // Creating Node
  894. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  895. CHECK(Node);
  896. if (UNLIKELY(!Node))
  897. {
  898. break;
  899. }
  900. // Loading Node
  901. FWwiseLoadedEventPromise LoadPromise;
  902. auto LoadFuture = LoadPromise.GetFuture();
  903. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  904. LoadedEvent = LoadFuture.Get(); // Synchronously
  905. CHECK(LoadedEvent);
  906. if (UNLIKELY(!LoadedEvent))
  907. {
  908. break;
  909. }
  910. }
  911. while (false);
  912. CHECK(!MediaManager.IsMediaLoaded(1));
  913. // Load GroupValue
  914. do
  915. {
  916. // Creating Node
  917. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue);
  918. CHECK(Node);
  919. if (UNLIKELY(!Node))
  920. {
  921. break;
  922. }
  923. // Loading Node
  924. FWwiseLoadedGroupValuePromise LoadPromise;
  925. auto LoadFuture = LoadPromise.GetFuture();
  926. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  927. LoadedGroupValue = LoadFuture.Get(); // Synchronously
  928. CHECK(LoadedGroupValue);
  929. if (UNLIKELY(!LoadedGroupValue))
  930. {
  931. break;
  932. }
  933. }
  934. while(false);
  935. CHECK(!MediaManager.IsMediaLoaded(1));
  936. // Load GroupValue2
  937. do
  938. {
  939. // Creating Node
  940. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue2);
  941. CHECK(Node);
  942. if (UNLIKELY(!Node))
  943. {
  944. break;
  945. }
  946. // Loading Node
  947. FWwiseLoadedGroupValuePromise LoadPromise;
  948. auto LoadFuture = LoadPromise.GetFuture();
  949. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  950. LoadedGroupValue2 = LoadFuture.Get(); // Synchronously
  951. CHECK(LoadedGroupValue2);
  952. if (UNLIKELY(!LoadedGroupValue2))
  953. {
  954. break;
  955. }
  956. }
  957. while(false);
  958. CHECK(MediaManager.IsMediaLoaded(1));
  959. // Unloading GroupValue
  960. if (LIKELY(LoadedGroupValue))
  961. {
  962. FWwiseResourceUnloadPromise UnloadPromise;
  963. auto UnloadFuture = UnloadPromise.GetFuture();
  964. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue));
  965. UnloadFuture.Get(); // Synchronously
  966. }
  967. CHECK(!MediaManager.IsMediaLoaded(1));
  968. // Unloading GroupValue2
  969. if (LIKELY(LoadedGroupValue2))
  970. {
  971. FWwiseResourceUnloadPromise UnloadPromise;
  972. auto UnloadFuture = UnloadPromise.GetFuture();
  973. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue2));
  974. UnloadFuture.Get(); // Synchronously
  975. }
  976. CHECK(!MediaManager.IsMediaLoaded(1));
  977. // Unloading Event
  978. if (LIKELY(LoadedEvent))
  979. {
  980. FWwiseResourceUnloadPromise UnloadPromise;
  981. auto UnloadFuture = UnloadPromise.GetFuture();
  982. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  983. UnloadFuture.Get(); // Synchronously
  984. }
  985. CHECK(!MediaManager.IsMediaLoaded(1));
  986. CHECK(ExternalSourceManager.IsEmpty());
  987. CHECK(MediaManager.IsEmpty());
  988. CHECK(SoundBankManager.IsEmpty());
  989. CHECK(ResourceLoaderImpl.IsEmpty());
  990. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  991. }
  992. SECTION("2 SwitchContainer with different ID (media requires both SwitchContainer). Switch Container 1 is Required key")
  993. {
  994. FWwiseMockExternalSourceManager ExternalSourceManager;
  995. FWwiseMockMediaManager MediaManager;
  996. FWwiseMockSoundBankManager SoundBankManager;
  997. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  998. FWwiseGroupValueCookedData GroupValue;
  999. GroupValue.Id = 1;
  1000. GroupValue.GroupId = 1;
  1001. GroupValue.Type = EWwiseGroupType::Switch;
  1002. FWwiseGroupValueCookedData GroupValue2;
  1003. GroupValue2.Id = 2;
  1004. GroupValue2.GroupId = 2;
  1005. GroupValue2.Type = EWwiseGroupType::Switch;
  1006. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  1007. FWwiseLoadedGroupValuePtr LoadedGroupValue2{nullptr};
  1008. // Load Event
  1009. do
  1010. {
  1011. FWwiseLocalizedEventCookedData CookedData;
  1012. {
  1013. FWwiseEventCookedData Data1;
  1014. Data1.Media.Emplace(FWwiseMediaCookedData{});
  1015. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  1016. FWwiseSwitchContainerLeafCookedData Leaf1;
  1017. FWwiseMediaCookedData Leaf1Media;
  1018. Leaf1Media.MediaId = 1;
  1019. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  1020. Leaf1.GroupValueSet.Emplace(GroupValue2);
  1021. Leaf1.GroupValueSet.Add(GroupValue);
  1022. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  1023. Data1.RequiredGroupValueSet.Add(GroupValue);
  1024. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  1025. }
  1026. // Creating Node
  1027. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  1028. CHECK(Node);
  1029. if (UNLIKELY(!Node))
  1030. {
  1031. break;
  1032. }
  1033. // Loading Node
  1034. FWwiseLoadedEventPromise LoadPromise;
  1035. auto LoadFuture = LoadPromise.GetFuture();
  1036. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1037. LoadedEvent = LoadFuture.Get(); // Synchronously
  1038. CHECK(LoadedEvent);
  1039. if (UNLIKELY(!LoadedEvent))
  1040. {
  1041. break;
  1042. }
  1043. }
  1044. while (false);
  1045. CHECK(!MediaManager.IsMediaLoaded(1));
  1046. // Load GroupValue2
  1047. do
  1048. {
  1049. // Creating Node
  1050. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue2);
  1051. CHECK(Node);
  1052. if (UNLIKELY(!Node))
  1053. {
  1054. break;
  1055. }
  1056. // Loading Node
  1057. FWwiseLoadedGroupValuePromise LoadPromise;
  1058. auto LoadFuture = LoadPromise.GetFuture();
  1059. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1060. LoadedGroupValue2 = LoadFuture.Get(); // Synchronously
  1061. CHECK(LoadedGroupValue2);
  1062. if (UNLIKELY(!LoadedGroupValue2))
  1063. {
  1064. break;
  1065. }
  1066. }
  1067. while(false);
  1068. CHECK(MediaManager.IsMediaLoaded(1));
  1069. //Unload GroupValue2
  1070. if (LIKELY(LoadedGroupValue2))
  1071. {
  1072. FWwiseResourceUnloadPromise UnloadPromise;
  1073. auto UnloadFuture = UnloadPromise.GetFuture();
  1074. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue2));
  1075. UnloadFuture.Get(); // Synchronously
  1076. }
  1077. CHECK(!MediaManager.IsMediaLoaded(1));
  1078. // Unloading Event
  1079. if (LIKELY(LoadedEvent))
  1080. {
  1081. FWwiseResourceUnloadPromise UnloadPromise;
  1082. auto UnloadFuture = UnloadPromise.GetFuture();
  1083. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  1084. UnloadFuture.Get(); // Synchronously
  1085. }
  1086. CHECK(!MediaManager.IsMediaLoaded(1));
  1087. CHECK(ExternalSourceManager.IsEmpty());
  1088. CHECK(MediaManager.IsEmpty());
  1089. CHECK(SoundBankManager.IsEmpty());
  1090. CHECK(ResourceLoaderImpl.IsEmpty());
  1091. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  1092. }
  1093. SECTION("2 SwitchContainer with different ID (media requires both SwitchContainer). Switch Container 1 & 2 are Required key")
  1094. {
  1095. FWwiseMockExternalSourceManager ExternalSourceManager;
  1096. FWwiseMockMediaManager MediaManager;
  1097. FWwiseMockSoundBankManager SoundBankManager;
  1098. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  1099. FWwiseGroupValueCookedData GroupValue;
  1100. GroupValue.Id = 1;
  1101. GroupValue.GroupId = 1;
  1102. GroupValue.Type = EWwiseGroupType::Switch;
  1103. FWwiseGroupValueCookedData GroupValue2;
  1104. GroupValue2.Id = 2;
  1105. GroupValue2.GroupId = 2;
  1106. GroupValue2.Type = EWwiseGroupType::Switch;
  1107. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  1108. // Load Event
  1109. do
  1110. {
  1111. FWwiseLocalizedEventCookedData CookedData;
  1112. {
  1113. FWwiseEventCookedData Data1;
  1114. Data1.Media.Emplace(FWwiseMediaCookedData{});
  1115. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  1116. FWwiseSwitchContainerLeafCookedData Leaf1;
  1117. FWwiseMediaCookedData Leaf1Media;
  1118. Leaf1Media.MediaId = 1;
  1119. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  1120. Leaf1.GroupValueSet.Emplace(GroupValue);
  1121. Leaf1.GroupValueSet.Add(GroupValue2);
  1122. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  1123. Data1.RequiredGroupValueSet.Add(GroupValue);
  1124. Data1.RequiredGroupValueSet.Add(GroupValue2);
  1125. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  1126. }
  1127. // Creating Node
  1128. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  1129. CHECK(Node);
  1130. if (UNLIKELY(!Node))
  1131. {
  1132. break;
  1133. }
  1134. // Loading Node
  1135. FWwiseLoadedEventPromise LoadPromise;
  1136. auto LoadFuture = LoadPromise.GetFuture();
  1137. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1138. LoadedEvent = LoadFuture.Get(); // Synchronously
  1139. CHECK(LoadedEvent);
  1140. if (UNLIKELY(!LoadedEvent))
  1141. {
  1142. break;
  1143. }
  1144. }
  1145. while (false);
  1146. CHECK(MediaManager.IsMediaLoaded(1));
  1147. // Unloading Event
  1148. if (LIKELY(LoadedEvent))
  1149. {
  1150. FWwiseResourceUnloadPromise UnloadPromise;
  1151. auto UnloadFuture = UnloadPromise.GetFuture();
  1152. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  1153. UnloadFuture.Get(); // Synchronously
  1154. }
  1155. CHECK(!MediaManager.IsMediaLoaded(1));
  1156. CHECK(ExternalSourceManager.IsEmpty());
  1157. CHECK(MediaManager.IsEmpty());
  1158. CHECK(SoundBankManager.IsEmpty());
  1159. CHECK(ResourceLoaderImpl.IsEmpty());
  1160. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  1161. }
  1162. SECTION("2 SwitchContainer with different ID (media requires both SwitchContainer). Switch Container 1 Loaded Manually. Switch Container 2 is a Required Key on another Event.")
  1163. {
  1164. FWwiseMockExternalSourceManager ExternalSourceManager;
  1165. FWwiseMockMediaManager MediaManager;
  1166. FWwiseMockSoundBankManager SoundBankManager;
  1167. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  1168. FWwiseGroupValueCookedData GroupValue;
  1169. GroupValue.Id = 1;
  1170. GroupValue.GroupId = 1;
  1171. GroupValue.Type = EWwiseGroupType::Switch;
  1172. FWwiseGroupValueCookedData GroupValue2;
  1173. GroupValue2.Id = 2;
  1174. GroupValue2.GroupId = 2;
  1175. GroupValue2.Type = EWwiseGroupType::Switch;
  1176. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  1177. FWwiseLoadedEventPtr LoadedEvent2{nullptr};
  1178. FWwiseLoadedGroupValuePtr LoadedGroupValue{nullptr};
  1179. // Load Event
  1180. do
  1181. {
  1182. FWwiseLocalizedEventCookedData CookedData;
  1183. {
  1184. FWwiseEventCookedData Data1;
  1185. Data1.Media.Emplace(FWwiseMediaCookedData{});
  1186. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  1187. FWwiseSwitchContainerLeafCookedData Leaf1;
  1188. FWwiseMediaCookedData Leaf1Media;
  1189. Leaf1Media.MediaId = 1;
  1190. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  1191. Leaf1.GroupValueSet.Emplace(GroupValue);
  1192. Leaf1.GroupValueSet.Add(GroupValue2);
  1193. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  1194. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  1195. }
  1196. // Creating Node
  1197. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  1198. CHECK(Node);
  1199. if (UNLIKELY(!Node))
  1200. {
  1201. break;
  1202. }
  1203. // Loading Node
  1204. FWwiseLoadedEventPromise LoadPromise;
  1205. auto LoadFuture = LoadPromise.GetFuture();
  1206. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1207. LoadedEvent = LoadFuture.Get(); // Synchronously
  1208. CHECK(LoadedEvent);
  1209. if (UNLIKELY(!LoadedEvent))
  1210. {
  1211. break;
  1212. }
  1213. }
  1214. while (false);
  1215. // Load GroupValue
  1216. do
  1217. {
  1218. // Creating Node
  1219. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue);
  1220. CHECK(Node);
  1221. if (UNLIKELY(!Node))
  1222. {
  1223. break;
  1224. }
  1225. // Loading Node
  1226. FWwiseLoadedGroupValuePromise LoadPromise;
  1227. auto LoadFuture = LoadPromise.GetFuture();
  1228. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1229. LoadedGroupValue = LoadFuture.Get(); // Synchronously
  1230. CHECK(LoadedGroupValue);
  1231. if (UNLIKELY(!LoadedGroupValue))
  1232. {
  1233. break;
  1234. }
  1235. }
  1236. while(false);
  1237. CHECK(!MediaManager.IsMediaLoaded(1));
  1238. // Load Event 2 with Required Key
  1239. do
  1240. {
  1241. FWwiseLocalizedEventCookedData CookedData;
  1242. {
  1243. FWwiseEventCookedData Data1;
  1244. Data1.RequiredGroupValueSet.Add(GroupValue2);
  1245. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  1246. }
  1247. // Creating Node
  1248. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  1249. CHECK(Node);
  1250. if (UNLIKELY(!Node))
  1251. {
  1252. break;
  1253. }
  1254. // Loading Node
  1255. FWwiseLoadedEventPromise LoadPromise;
  1256. auto LoadFuture = LoadPromise.GetFuture();
  1257. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1258. LoadedEvent2 = LoadFuture.Get(); // Synchronously
  1259. CHECK(LoadedEvent2);
  1260. if (UNLIKELY(!LoadedEvent2))
  1261. {
  1262. break;
  1263. }
  1264. }
  1265. while (false);
  1266. CHECK(MediaManager.IsMediaLoaded(1));
  1267. // Unloading Event 2
  1268. if (LIKELY(LoadedEvent2))
  1269. {
  1270. FWwiseResourceUnloadPromise UnloadPromise;
  1271. auto UnloadFuture = UnloadPromise.GetFuture();
  1272. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent2));
  1273. UnloadFuture.Get(); // Synchronously
  1274. }
  1275. CHECK(!MediaManager.IsMediaLoaded(1));
  1276. //Unloading group value
  1277. if (LIKELY(LoadedGroupValue))
  1278. {
  1279. FWwiseResourceUnloadPromise UnloadPromise;
  1280. auto UnloadFuture = UnloadPromise.GetFuture();
  1281. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue));
  1282. UnloadFuture.Get(); // Synchronously
  1283. }
  1284. // Unloading Event
  1285. if (LIKELY(LoadedEvent))
  1286. {
  1287. FWwiseResourceUnloadPromise UnloadPromise;
  1288. auto UnloadFuture = UnloadPromise.GetFuture();
  1289. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  1290. UnloadFuture.Get(); // Synchronously
  1291. }
  1292. CHECK(!MediaManager.IsMediaLoaded(1));
  1293. CHECK(ExternalSourceManager.IsEmpty());
  1294. CHECK(MediaManager.IsEmpty());
  1295. CHECK(SoundBankManager.IsEmpty());
  1296. CHECK(ResourceLoaderImpl.IsEmpty());
  1297. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  1298. }
  1299. SECTION("2 SwitchContainer with different ID (media requires both SwitchContainer). Switch Container 1 is a Required key on Event with the Media. Switch Container 2 is a Required Key on another Event.")
  1300. {
  1301. FWwiseMockExternalSourceManager ExternalSourceManager;
  1302. FWwiseMockMediaManager MediaManager;
  1303. FWwiseMockSoundBankManager SoundBankManager;
  1304. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  1305. FWwiseGroupValueCookedData GroupValue;
  1306. GroupValue.Id = 1;
  1307. GroupValue.GroupId = 1;
  1308. GroupValue.Type = EWwiseGroupType::Switch;
  1309. FWwiseGroupValueCookedData GroupValue2;
  1310. GroupValue2.Id = 2;
  1311. GroupValue2.GroupId = 2;
  1312. GroupValue2.Type = EWwiseGroupType::Switch;
  1313. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  1314. FWwiseLoadedEventPtr LoadedEvent2{nullptr};
  1315. // Load Event
  1316. do
  1317. {
  1318. FWwiseLocalizedEventCookedData CookedData;
  1319. {
  1320. FWwiseEventCookedData Data1;
  1321. Data1.Media.Emplace(FWwiseMediaCookedData{});
  1322. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  1323. FWwiseSwitchContainerLeafCookedData Leaf1;
  1324. FWwiseMediaCookedData Leaf1Media;
  1325. Leaf1Media.MediaId = 1;
  1326. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  1327. Leaf1.GroupValueSet.Emplace(GroupValue);
  1328. Leaf1.GroupValueSet.Add(GroupValue2);
  1329. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  1330. Data1.RequiredGroupValueSet.Add(GroupValue);
  1331. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  1332. }
  1333. // Creating Node
  1334. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  1335. CHECK(Node);
  1336. if (UNLIKELY(!Node))
  1337. {
  1338. break;
  1339. }
  1340. // Loading Node
  1341. FWwiseLoadedEventPromise LoadPromise;
  1342. auto LoadFuture = LoadPromise.GetFuture();
  1343. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1344. LoadedEvent = LoadFuture.Get(); // Synchronously
  1345. CHECK(LoadedEvent);
  1346. if (UNLIKELY(!LoadedEvent))
  1347. {
  1348. break;
  1349. }
  1350. }
  1351. while (false);
  1352. CHECK(!MediaManager.IsMediaLoaded(1));
  1353. // Load Event 2
  1354. do
  1355. {
  1356. FWwiseLocalizedEventCookedData CookedData;
  1357. {
  1358. FWwiseEventCookedData Data1;
  1359. Data1.RequiredGroupValueSet.Add(GroupValue2);
  1360. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  1361. }
  1362. // Creating Node
  1363. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  1364. CHECK(Node);
  1365. if (UNLIKELY(!Node))
  1366. {
  1367. break;
  1368. }
  1369. // Loading Node
  1370. FWwiseLoadedEventPromise LoadPromise;
  1371. auto LoadFuture = LoadPromise.GetFuture();
  1372. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1373. LoadedEvent2 = LoadFuture.Get(); // Synchronously
  1374. CHECK(LoadedEvent2);
  1375. if (UNLIKELY(!LoadedEvent2))
  1376. {
  1377. break;
  1378. }
  1379. }
  1380. while (false);
  1381. CHECK(MediaManager.IsMediaLoaded(1));
  1382. // Unloading Event
  1383. if (LIKELY(LoadedEvent))
  1384. {
  1385. FWwiseResourceUnloadPromise UnloadPromise;
  1386. auto UnloadFuture = UnloadPromise.GetFuture();
  1387. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  1388. UnloadFuture.Get(); // Synchronously
  1389. }
  1390. CHECK(!MediaManager.IsMediaLoaded(1));
  1391. // Unloading Event 2
  1392. if (LIKELY(LoadedEvent2))
  1393. {
  1394. FWwiseResourceUnloadPromise UnloadPromise;
  1395. auto UnloadFuture = UnloadPromise.GetFuture();
  1396. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent2));
  1397. UnloadFuture.Get(); // Synchronously
  1398. }
  1399. CHECK(!MediaManager.IsMediaLoaded(1));
  1400. CHECK(ExternalSourceManager.IsEmpty());
  1401. CHECK(MediaManager.IsEmpty());
  1402. CHECK(SoundBankManager.IsEmpty());
  1403. CHECK(ResourceLoaderImpl.IsEmpty());
  1404. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  1405. }
  1406. SECTION("2 SwitchContainer with different ID (media requires both SwitchContainer). Switch Container 1 & 2 are a Required Key on another Event.")
  1407. {
  1408. FWwiseMockExternalSourceManager ExternalSourceManager;
  1409. FWwiseMockMediaManager MediaManager;
  1410. FWwiseMockSoundBankManager SoundBankManager;
  1411. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  1412. FWwiseGroupValueCookedData GroupValue;
  1413. GroupValue.Id = 1;
  1414. GroupValue.GroupId = 1;
  1415. GroupValue.Type = EWwiseGroupType::Switch;
  1416. FWwiseGroupValueCookedData GroupValue2;
  1417. GroupValue2.Id = 2;
  1418. GroupValue2.GroupId = 2;
  1419. GroupValue2.Type = EWwiseGroupType::Switch;
  1420. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  1421. FWwiseLoadedEventPtr LoadedEvent2{nullptr};
  1422. FWwiseLoadedEventPtr LoadedEvent3{nullptr};
  1423. // Load Event
  1424. do
  1425. {
  1426. FWwiseLocalizedEventCookedData CookedData;
  1427. {
  1428. FWwiseEventCookedData Data1;
  1429. Data1.Media.Emplace(FWwiseMediaCookedData{});
  1430. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  1431. FWwiseSwitchContainerLeafCookedData Leaf1;
  1432. FWwiseMediaCookedData Leaf1Media;
  1433. Leaf1Media.MediaId = 1;
  1434. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  1435. Leaf1.GroupValueSet.Emplace(GroupValue);
  1436. Leaf1.GroupValueSet.Add(GroupValue2);
  1437. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  1438. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  1439. }
  1440. // Creating Node
  1441. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  1442. CHECK(Node);
  1443. if (UNLIKELY(!Node))
  1444. {
  1445. break;
  1446. }
  1447. // Loading Node
  1448. FWwiseLoadedEventPromise LoadPromise;
  1449. auto LoadFuture = LoadPromise.GetFuture();
  1450. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1451. LoadedEvent = LoadFuture.Get(); // Synchronously
  1452. CHECK(LoadedEvent);
  1453. if (UNLIKELY(!LoadedEvent))
  1454. {
  1455. break;
  1456. }
  1457. }
  1458. while (false);
  1459. CHECK(!MediaManager.IsMediaLoaded(1));
  1460. // Load Event 2
  1461. do
  1462. {
  1463. FWwiseLocalizedEventCookedData CookedData;
  1464. {
  1465. FWwiseEventCookedData Data1;
  1466. Data1.RequiredGroupValueSet.Add(GroupValue);
  1467. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  1468. }
  1469. // Creating Node
  1470. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  1471. CHECK(Node);
  1472. if (UNLIKELY(!Node))
  1473. {
  1474. break;
  1475. }
  1476. // Loading Node
  1477. FWwiseLoadedEventPromise LoadPromise;
  1478. auto LoadFuture = LoadPromise.GetFuture();
  1479. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1480. LoadedEvent2 = LoadFuture.Get(); // Synchronously
  1481. CHECK(LoadedEvent2);
  1482. if (UNLIKELY(!LoadedEvent2))
  1483. {
  1484. break;
  1485. }
  1486. }
  1487. while (false);
  1488. CHECK(!MediaManager.IsMediaLoaded(1));
  1489. // Load Event 3
  1490. do
  1491. {
  1492. FWwiseLocalizedEventCookedData CookedData;
  1493. {
  1494. FWwiseEventCookedData Data1;
  1495. Data1.RequiredGroupValueSet.Add(GroupValue2);
  1496. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  1497. }
  1498. // Creating Node
  1499. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  1500. CHECK(Node);
  1501. if (UNLIKELY(!Node))
  1502. {
  1503. break;
  1504. }
  1505. // Loading Node
  1506. FWwiseLoadedEventPromise LoadPromise;
  1507. auto LoadFuture = LoadPromise.GetFuture();
  1508. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1509. LoadedEvent3 = LoadFuture.Get(); // Synchronously
  1510. CHECK(LoadedEvent3);
  1511. if (UNLIKELY(!LoadedEvent3))
  1512. {
  1513. break;
  1514. }
  1515. }
  1516. while (false);
  1517. CHECK(MediaManager.IsMediaLoaded(1));
  1518. // Unloading Event 3
  1519. if (LIKELY(LoadedEvent3))
  1520. {
  1521. FWwiseResourceUnloadPromise UnloadPromise;
  1522. auto UnloadFuture = UnloadPromise.GetFuture();
  1523. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent3));
  1524. UnloadFuture.Get(); // Synchronously
  1525. }
  1526. CHECK(!MediaManager.IsMediaLoaded(1));
  1527. // Unloading Event 2
  1528. if (LIKELY(2))
  1529. {
  1530. FWwiseResourceUnloadPromise UnloadPromise;
  1531. auto UnloadFuture = UnloadPromise.GetFuture();
  1532. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent2));
  1533. UnloadFuture.Get(); // Synchronously
  1534. }
  1535. CHECK(!MediaManager.IsMediaLoaded(1));
  1536. // Unloading Event
  1537. if (LIKELY(LoadedEvent))
  1538. {
  1539. FWwiseResourceUnloadPromise UnloadPromise;
  1540. auto UnloadFuture = UnloadPromise.GetFuture();
  1541. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  1542. UnloadFuture.Get(); // Synchronously
  1543. }
  1544. CHECK(!MediaManager.IsMediaLoaded(1));
  1545. CHECK(ExternalSourceManager.IsEmpty());
  1546. CHECK(MediaManager.IsEmpty());
  1547. CHECK(SoundBankManager.IsEmpty());
  1548. CHECK(ResourceLoaderImpl.IsEmpty());
  1549. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  1550. }
  1551. SECTION("3 SwitchContainer with different ID (media requires all 3 SwitchContainer).")
  1552. {
  1553. FWwiseMockExternalSourceManager ExternalSourceManager;
  1554. FWwiseMockMediaManager MediaManager;
  1555. FWwiseMockSoundBankManager SoundBankManager;
  1556. FWwiseResourceLoaderImpl ResourceLoaderImpl(ExternalSourceManager, MediaManager, SoundBankManager);
  1557. FWwiseGroupValueCookedData GroupValue;
  1558. GroupValue.Id = 1;
  1559. GroupValue.GroupId = 1;
  1560. GroupValue.Type = EWwiseGroupType::Switch;
  1561. FWwiseGroupValueCookedData GroupValue2;
  1562. GroupValue2.Id = 2;
  1563. GroupValue2.GroupId = 2;
  1564. GroupValue2.Type = EWwiseGroupType::Switch;
  1565. FWwiseGroupValueCookedData GroupValue3;
  1566. GroupValue3.Id = 3;
  1567. GroupValue3.GroupId = 3;
  1568. GroupValue3.Type = EWwiseGroupType::Switch;
  1569. FWwiseLoadedEventPtr LoadedEvent{nullptr};
  1570. FWwiseLoadedGroupValuePtr LoadedGroupValue{nullptr};
  1571. FWwiseLoadedGroupValuePtr LoadedGroupValue2{nullptr};
  1572. FWwiseLoadedGroupValuePtr LoadedGroupValue3{nullptr};
  1573. // Load Event
  1574. do
  1575. {
  1576. FWwiseLocalizedEventCookedData CookedData;
  1577. {
  1578. FWwiseEventCookedData Data1;
  1579. Data1.Media.Emplace(FWwiseMediaCookedData{});
  1580. Data1.SoundBanks.Emplace(FWwiseSoundBankCookedData{});
  1581. FWwiseSwitchContainerLeafCookedData Leaf1;
  1582. FWwiseMediaCookedData Leaf1Media;
  1583. Leaf1Media.MediaId = 1;
  1584. Leaf1.Media.Emplace(MoveTemp(Leaf1Media));
  1585. Leaf1.GroupValueSet.Emplace(GroupValue);
  1586. Leaf1.GroupValueSet.Add(GroupValue2);
  1587. Leaf1.GroupValueSet.Add(GroupValue3);
  1588. Data1.SwitchContainerLeaves.Emplace(MoveTemp(Leaf1));
  1589. CookedData.EventLanguageMap.Emplace(FWwiseLanguageCookedData::Sfx, MoveTemp(Data1));
  1590. }
  1591. // Creating Node
  1592. auto* Node = ResourceLoaderImpl.CreateEventNode(CookedData, nullptr);
  1593. CHECK(Node);
  1594. if (UNLIKELY(!Node))
  1595. {
  1596. break;
  1597. }
  1598. // Loading Node
  1599. FWwiseLoadedEventPromise LoadPromise;
  1600. auto LoadFuture = LoadPromise.GetFuture();
  1601. ResourceLoaderImpl.LoadEventAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1602. LoadedEvent = LoadFuture.Get(); // Synchronously
  1603. CHECK(LoadedEvent);
  1604. if (UNLIKELY(!LoadedEvent))
  1605. {
  1606. break;
  1607. }
  1608. }
  1609. while (false);
  1610. CHECK(!MediaManager.IsMediaLoaded(1));
  1611. // Load GroupValue
  1612. do
  1613. {
  1614. // Creating Node
  1615. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue);
  1616. CHECK(Node);
  1617. if (UNLIKELY(!Node))
  1618. {
  1619. break;
  1620. }
  1621. // Loading Node
  1622. FWwiseLoadedGroupValuePromise LoadPromise;
  1623. auto LoadFuture = LoadPromise.GetFuture();
  1624. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1625. LoadedGroupValue = LoadFuture.Get(); // Synchronously
  1626. CHECK(LoadedGroupValue);
  1627. if (UNLIKELY(!LoadedGroupValue))
  1628. {
  1629. break;
  1630. }
  1631. }
  1632. while(false);
  1633. CHECK(!MediaManager.IsMediaLoaded(1));
  1634. // Load GroupValue 2
  1635. do
  1636. {
  1637. // Creating Node
  1638. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue2);
  1639. CHECK(Node);
  1640. if (UNLIKELY(!Node))
  1641. {
  1642. break;
  1643. }
  1644. // Loading Node
  1645. FWwiseLoadedGroupValuePromise LoadPromise;
  1646. auto LoadFuture = LoadPromise.GetFuture();
  1647. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1648. LoadedGroupValue2 = LoadFuture.Get(); // Synchronously
  1649. CHECK(LoadedGroupValue2);
  1650. if (UNLIKELY(!LoadedGroupValue2))
  1651. {
  1652. break;
  1653. }
  1654. }
  1655. while(false);
  1656. CHECK(!MediaManager.IsMediaLoaded(1));
  1657. // Load GroupValue 3
  1658. do
  1659. {
  1660. // Creating Node
  1661. auto* Node = ResourceLoaderImpl.CreateGroupValueNode(GroupValue3);
  1662. CHECK(Node);
  1663. if (UNLIKELY(!Node))
  1664. {
  1665. break;
  1666. }
  1667. // Loading Node
  1668. FWwiseLoadedGroupValuePromise LoadPromise;
  1669. auto LoadFuture = LoadPromise.GetFuture();
  1670. ResourceLoaderImpl.LoadGroupValueAsync(MoveTemp(LoadPromise), MoveTemp(Node));
  1671. LoadedGroupValue3 = LoadFuture.Get(); // Synchronously
  1672. CHECK(LoadedGroupValue3);
  1673. if (UNLIKELY(!LoadedGroupValue3))
  1674. {
  1675. break;
  1676. }
  1677. }
  1678. while(false);
  1679. CHECK(MediaManager.IsMediaLoaded(1));
  1680. // Unloading GroupValue3
  1681. if (LIKELY(LoadedGroupValue3))
  1682. {
  1683. FWwiseResourceUnloadPromise UnloadPromise;
  1684. auto UnloadFuture = UnloadPromise.GetFuture();
  1685. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue3));
  1686. UnloadFuture.Get(); // Synchronously
  1687. }
  1688. // Unloading GroupValue2
  1689. if (LIKELY(LoadedGroupValue2))
  1690. {
  1691. FWwiseResourceUnloadPromise UnloadPromise;
  1692. auto UnloadFuture = UnloadPromise.GetFuture();
  1693. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue2));
  1694. UnloadFuture.Get(); // Synchronously
  1695. }
  1696. // Unloading GroupValue1
  1697. if (LIKELY(LoadedGroupValue))
  1698. {
  1699. FWwiseResourceUnloadPromise UnloadPromise;
  1700. auto UnloadFuture = UnloadPromise.GetFuture();
  1701. ResourceLoaderImpl.UnloadGroupValueAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedGroupValue));
  1702. UnloadFuture.Get(); // Synchronously
  1703. }
  1704. // Unloading Event
  1705. if (LIKELY(LoadedEvent))
  1706. {
  1707. FWwiseResourceUnloadPromise UnloadPromise;
  1708. auto UnloadFuture = UnloadPromise.GetFuture();
  1709. ResourceLoaderImpl.UnloadEventAsync(MoveTemp(UnloadPromise), MoveTemp(LoadedEvent));
  1710. UnloadFuture.Get(); // Synchronously
  1711. }
  1712. CHECK(!MediaManager.IsMediaLoaded(1));
  1713. CHECK(ExternalSourceManager.IsEmpty());
  1714. CHECK(MediaManager.IsEmpty());
  1715. CHECK(SoundBankManager.IsEmpty());
  1716. CHECK(ResourceLoaderImpl.IsEmpty());
  1717. CHECK(ResourceLoaderImpl.TrimGroupValueInfo());
  1718. }
  1719. }
  1720. #endif // WWISE_UNIT_TESTS