Skip to content

Commit f970fda

Browse files
committed
freature: OverridePoints/OnAssetBundleListUpdated is added.
1 parent 270f850 commit f970fda

7 files changed

Lines changed: 123 additions & 5 deletions

File tree

Assets/Autoya/Backyard/AssetBundlesImplementation.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,25 @@ private IEnumerator OnUpdatingListReceived(AssetBundleList newList)
290290
// finish downloading new assetBundleList.
291291
newListDownloaderState = NewListDownloaderState.Ready;
292292

293-
OnAssetBundleListUpdated();
293+
/*
294+
start postprocess.
295+
*/
296+
var condition = GetCurrentAssetBundleUsingCondition(newList);
297+
var postProcessReady = false;
298+
299+
OnAssetBundleListUpdated(
300+
condition,
301+
() =>
302+
{
303+
postProcessReady = true;
304+
}
305+
);
306+
307+
while (!postProcessReady)
308+
{
309+
yield return null;
310+
}
311+
294312
yield break;
295313
}
296314

@@ -1004,6 +1022,14 @@ public static void Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList(Actio
10041022
};
10051023
}
10061024

1025+
public static void Debug_SetOnOverridePoint_OnAssetBundleListUpdated(Action<CurrentUsingBundleCondition, Action> debugAct)
1026+
{
1027+
autoya.OnAssetBundleListUpdated = (condition, ready) =>
1028+
{
1029+
debugAct(condition, ready);
1030+
};
1031+
}
1032+
10071033
public static void Debug_SetOverridePoint_OnNewAppRequested(Action<string> onNewAppDetected)
10081034
{
10091035
autoya.OnNewAppRequested = onNewAppDetected;

Assets/Autoya/Backyard/OverridePoints.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,15 @@ private void OnUpdateToNewAssetBundleList(string updatedAssetBundleListIdentity,
513513
}
514514

515515
/**
516-
fire when AssetBundleList update is finished.
516+
fire when AssetBundleList is updated to the new received one.
517+
you can get AssetBundle condition and need to fire ready() when you finish after doing post process.
517518
*/
518-
private void OnAssetBundleListUpdated()
519+
private Action<CurrentUsingBundleCondition, Action> OnAssetBundleListUpdated = (condition, ready) =>
519520
{
520521
// do something. e,g, Preload updated AssetBundles from updated AssetBundleList.
521-
}
522+
// finally, fire ready() for progress.
523+
ready();
524+
};
522525

523526
/**
524527
fire when failed to store new AssetBundleList to storage.

Assets/AutoyaTests/Tests/Backyard/AssetUpdateTests.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,81 @@ public IEnumerator ReceiveUpdatedListThenListWillBeUpdated()
290290
True(Autoya.Debug_AssetBundle_FeatureState() == Autoya.AssetBundlesFeatureState.Ready);
291291
}
292292

293+
[MTest]
294+
public IEnumerator ReceiveUpdatedListThenOnAssetBundleListUpdatedFired()
295+
{
296+
var done = false;
297+
Autoya.AssetBundle_DownloadAssetBundleListFromUrlManually(
298+
abListPath + "main_assets/" + AssetBundlesSettings.PLATFORM_STR + "/1.0.0/main_assets.json",
299+
status =>
300+
{
301+
done = true;
302+
},
303+
(code, reason, autoyaStatus) =>
304+
{
305+
// do nothing.
306+
}
307+
);
308+
309+
yield return WaitUntil(
310+
() => done,
311+
() => { throw new TimeoutException("faild to get assetBundleList."); }
312+
);
313+
314+
// リスト1.0.0が保持されている。
315+
// 通信のレスポンスヘッダーに特定の値が含まれていることで、listの更新リクエストを送り出す機構を着火する。
316+
317+
318+
// 新しいリストの取得判断の関数をセット(レスポンスを捕まえられるはず)
319+
Autoya.Debug_SetOverridePoint_ShouldRequestNewAssetBundleList(
320+
(identity, newVersion) =>
321+
{
322+
True(newVersion == "1.0.1");
323+
return RequestYes(identity, newVersion);
324+
}
325+
);
326+
327+
// リストの更新判断の関数をセット
328+
var isListUpdated = false;
329+
Autoya.Debug_SetOverridePoint_ShouldUpdateToNewAssetBundleList(
330+
(condition, proceed, cancel) =>
331+
{
332+
proceed();
333+
}
334+
);
335+
336+
Autoya.Debug_SetOnOverridePoint_OnAssetBundleListUpdated(
337+
(newVersion, ready) =>
338+
{
339+
ready();
340+
isListUpdated = true;
341+
}
342+
);
343+
344+
345+
Autoya.Http_Get(
346+
"https://httpbin.org/response-headers?" + resversionDesc + "=main_assets:1.0.1",
347+
(conId, data) =>
348+
{
349+
// pass.
350+
},
351+
(conId, code, reason, status) =>
352+
{
353+
Fail();
354+
}
355+
);
356+
357+
yield return WaitUntil(
358+
() => isListUpdated,
359+
() => { throw new TimeoutException("too late."); }
360+
);
361+
362+
// list is updated.
363+
True(Autoya.AssetBundle_AssetBundleLists()[0].version == "1.0.1");
364+
365+
True(Autoya.Debug_AssetBundle_FeatureState() == Autoya.AssetBundlesFeatureState.Ready);
366+
}
367+
293368
[MTest]
294369
public IEnumerator ReceiveUpdatedListThenIgnore()
295370
{

Assets/MiyamasuTestRunner/Runtime/Generated/GeneratedTestEntryPoints.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,20 @@ [UnityTest] public IEnumerator ReceiveUpdatedListThenListWillBeUpdated() {
11931193
rec.MarkAsPassed();
11941194

11951195

1196+
yield return instance.Teardown();
1197+
}
1198+
[UnityTest] public IEnumerator ReceiveUpdatedListThenOnAssetBundleListUpdatedFired() {
1199+
var rec = new Miyamasu.Recorder("AssetUpdateTests", "ReceiveUpdatedListThenOnAssetBundleListUpdatedFired");
1200+
var instance = new AssetUpdateTests();
1201+
instance.rec = rec;
1202+
1203+
1204+
yield return instance.Setup();
1205+
1206+
yield return instance.ReceiveUpdatedListThenOnAssetBundleListUpdatedFired();
1207+
rec.MarkAsPassed();
1208+
1209+
11961210
yield return instance.Teardown();
11971211
}
11981212
[UnityTest] public IEnumerator ReceiveUpdatedListThenIgnore() {

Assets/MiyamasuTestRunner/Runtime/Generated/GeneratedTestEntryPoints.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Autoya+AssetGraph.unitypackage

261 KB
Binary file not shown.

Autoya.unitypackage

93 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)