public IEnumerator Setup() { var loginDone = false; var dataPath = Application.persistentDataPath; Autoya.TestEntryPoint(dataPath); Autoya.Auth_SetOnAuthenticated( () => { loginDone = true; } ); yield return(WaitUntil( () => { return loginDone; }, () => { throw new TimeoutException("timeout."); } )); // delete all. Autoya.Persist_DeleteByDomain(AutoyaFilePersistTestsFileDomain); }
[MSetup] public void Setup() { Autoya.ResetAllForceSetting(); DeleteAllData(AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); var authorized = false; Action onMainThread = () => { var dataPath = Application.persistentDataPath; Autoya.TestEntryPoint(dataPath); Autoya.Auth_SetOnAuthenticated( () => { authorized = true; } ); }; RunOnMainThread(onMainThread); WaitUntil( () => { return(authorized); }, 5, "timeout in setup." ); Assert(Autoya.Auth_IsAuthenticated(), "not logged in."); Autoya.forceMaintenance = true; }
[MSetup] public void Setup() { if (!IsTestRunningInPlayingMode()) { SkipCurrentTest("Purchase feature should run on MainThread."); return; } ; var authorized = false; Action onMainThread = () => { var dataPath = Application.persistentDataPath; var fwPath = Path.Combine(dataPath, AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); DeleteAllData(fwPath); Autoya.TestEntryPoint(dataPath); Autoya.Auth_SetOnAuthenticated( () => { authorized = true; } ); }; RunOnMainThread(onMainThread); WaitUntil( () => { return(authorized && Autoya.Purchase_IsReady()); }, 5, "failed to auth or failed to ready purchase." ); }
public IEnumerator StoredAssetBundleListIsEmptyOnBoot() { // 事前に保存済みのデータを消す、これでほかのテストの影響を受けない初期化されたデータだけができる。 Autoya.Persist_DeleteByDomain(AppSettings.APP_STORED_RUNTIME_MANIFEST_DOMAIN); Autoya.Persist_DeleteByDomain(AssetBundlesSettings.ASSETBUNDLES_LIST_STORED_DOMAIN); var dataPath = Application.persistentDataPath; Autoya.TestEntryPoint(dataPath); { var loginDone = false; Autoya.Auth_SetOnAuthenticated( () => { loginDone = true; } ); yield return(WaitUntil( () => { return loginDone; }, () => { throw new TimeoutException("timeout."); } )); } Assert.True(!Autoya.AssetBundle_IsAssetBundleFeatureReady(), "ready."); }
public IEnumerator Setup() { Autoya.ResetAllForceSetting(); DeleteAllData(AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); var authorized = false; var dataPath = Application.persistentDataPath; Autoya.TestEntryPoint(dataPath); Autoya.Auth_SetOnAuthenticated( () => { authorized = true; } ); yield return(WaitUntil( () => { return authorized; }, () => { throw new TimeoutException("timeout in setup."); } )); True(Autoya.Auth_IsAuthenticated(), "not logged in."); Autoya.forceMaintenance = true; }
IEnumerator Start() { /* * authentication is running. * wait finish of the authentication. */ var authenticated = false; Action done = () => { authenticated = true; }; /* * set the action to be called when authentication succeeds. */ Autoya.Auth_SetOnAuthenticated(done); while (!authenticated) { yield return(null); } Debug.Log("login is done! welcome to Autoya."); }
[MTest] public void UnauthorizedThenHttpGet() { var reauthenticationSucceeded = false; // forcibly get 401 response. Autoya.Http_Get( "https://httpbin.org/status/401", (conId, resultData) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { // these handler will be fired automatically. Autoya.Auth_SetOnAuthenticated( () => { Autoya.Http_Get( "https://httpbin.org/get", (conId2, data2) => { reauthenticationSucceeded = true; }, (conId2, code2, reason2, autoyaStatus2) => { // do nothing. } ); } ); } ); WaitUntil( () => reauthenticationSucceeded, 10, "failed to handle SetOnAuthenticated." ); }
[MSetup] public void Setup() { var authenticated = false; Action onMainThread = () => { var dataPath = Application.persistentDataPath; var fwPath = Path.Combine(dataPath, AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); DeleteAllData(fwPath); Autoya.TestEntryPoint(dataPath); Autoya.Auth_SetOnAuthenticated( () => { authenticated = true; } ); }; RunOnMainThread(onMainThread); WaitUntil( () => { return(authenticated); }, 5, "failed to auth." ); Assert(Autoya.Auth_IsAuthenticated(), "not logged in."); }
public IEnumerator Setup() { var dataPath = Application.persistentDataPath; var fwPath = Path.Combine(dataPath, AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); DeleteAllData(fwPath); Autoya.TestEntryPoint(dataPath); var authenticated = false; Autoya.Auth_SetOnAuthenticated( () => { authenticated = true; } ); yield return(WaitUntil( () => authenticated, () => { throw new TimeoutException("failed to auth."); } )); True(Autoya.Auth_IsAuthenticated(), "not logged in."); }
IEnumerator Start() { var authenticated = false; Autoya.Auth_SetOnAuthenticated( () => { authenticated = true; } ); while (!authenticated) { yield return(null); } // test method for set fake maintenance mode. Autoya.forceMaintenance = true; /* * ready for handle maintenance mode. * you can set the method which will be called on maintenance. */ Autoya.Maintenance_SetOnMaintenance( MyOnMaintenance ); // start connection -> Maintenance mode notification will return. Autoya.Http_Get( "https://github.com", (conId, data) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { /* * you can check if service is in maintenance mode or not from autoyaStatus. */ var isUnderMaintenance = autoyaStatus.inMaintenance; Debug.Log("connection failed by maintenance:" + isUnderMaintenance); // reset for end test. Autoya.forceMaintenance = false; } ); }
public IEnumerator UnauthorizedThenHttpGet() { var reauthenticationSucceeded = false; // forcibly get 401 response. Autoya.Http_Get( "https://httpbin.org/status/401", (conId, resultData) => { // do nothing. }, (conId, code, reason, autoyaStatus) => { // these handler will be fired automatically. Autoya.Auth_SetOnAuthenticated( () => { Autoya.Http_Get( "https://httpbin.org/get", (string conId2, string data2) => { reauthenticationSucceeded = true; }, (conId2, code2, reason2, autoyaStatus2) => { // do nothing. } ); } ); } ); yield return(WaitUntil( () => reauthenticationSucceeded, () => { throw new TimeoutException("failed to handle SetOnAuthenticated."); }, 10 )); }
public IEnumerator Setup() { Autoya.ResetAllForceSetting(); var dataPath = Application.persistentDataPath; var fwPath = Path.Combine(dataPath, AuthSettings.AUTH_STORED_FRAMEWORK_DOMAIN); DeleteAllData(fwPath); Autoya.TestEntryPoint(dataPath); while (!Autoya.Auth_IsAuthenticated()) { yield return(false); } var authenticated = false; Autoya.Auth_SetOnAuthenticated( () => { authenticated = true; } ); Autoya.Auth_SetOnBootAuthFailed( (code, reason) => { Debug.LogError("code:" + code + " reason:" + reason); } ); yield return(WaitUntil( () => authenticated, () => { throw new TimeoutException("failed to auth."); } )); True(Autoya.Auth_IsAuthenticated(), "not logged in."); }
[MSetup] public void Setup() { var loginDone = false; RunOnMainThread( () => { var dataPath = Application.persistentDataPath; Autoya.TestEntryPoint(dataPath); Autoya.Auth_SetOnAuthenticated( () => { loginDone = true; } ); } ); WaitUntil( () => { return(loginDone); }, 3 ); Autoya.Persist_DeleteByDomain(AutoyaFilePersistTestsFileDomain); }
public IEnumerator StoredAssetBundleListIsEnoughOnBoot() { // 事前に保存済みのデータを消す、これでほかのテストの影響を受けない初期化されたデータだけができる。 Autoya.Persist_DeleteByDomain(AppSettings.APP_STORED_RUNTIME_MANIFEST_DOMAIN); Autoya.Persist_DeleteByDomain(AssetBundlesSettings.ASSETBUNDLES_LIST_STORED_DOMAIN); var dataPath = Application.persistentDataPath; Autoya.TestEntryPoint(dataPath); { var loginDone = false; Autoya.Auth_SetOnAuthenticated( () => { loginDone = true; } ); yield return(WaitUntil( () => { return loginDone; }, () => { throw new TimeoutException("timeout."); } )); } var abReady = false; Autoya.AssetBundle_DownloadAssetBundleListsIfNeed( results => { abReady = true; }, (code, reason, status) => { Debug.LogError("failed to download ABList, code:" + code + " reason:" + reason); } ); while (!abReady) { yield return(null); } // reboot autoya. Autoya.TestEntryPoint(dataPath); { var loginDone = false; Autoya.Auth_SetOnAuthenticated( () => { loginDone = true; } ); yield return(WaitUntil( () => { return loginDone; }, () => { throw new TimeoutException("timeout."); } )); } Assert.True(Autoya.AssetBundle_IsAssetBundleFeatureReady(), "not ready."); }
public IEnumerator RemoveUnnecessaryStoredAssetBundleListOnBoot() { // 事前に保存済みのデータを消す、これでほかのテストの影響を受けない初期化されたデータだけができる。 Autoya.Persist_DeleteByDomain(AppSettings.APP_STORED_RUNTIME_MANIFEST_DOMAIN); Autoya.Persist_DeleteByDomain(AssetBundlesSettings.ASSETBUNDLES_LIST_STORED_DOMAIN); var dataPath = Application.persistentDataPath; Autoya.TestEntryPoint(dataPath); { var loginDone = false; Autoya.Auth_SetOnAuthenticated( () => { loginDone = true; } ); yield return(WaitUntil( () => { return loginDone; }, () => { throw new TimeoutException("timeout."); } )); } var abReady = false; Autoya.AssetBundle_DownloadAssetBundleListsIfNeed( results => { abReady = true; }, (code, reason, status) => { Debug.LogError("failed to download ABList, code:" + code + " reason:" + reason); } ); while (!abReady) { yield return(null); } var defaultGeneratedABListIdentities = Autoya.AssetBundle_AssetBundleLists().Select(list => list.identity).ToArray(); // このあとまたAutoyaを起動するので、ABListがあるdomainに存在するファイルに、独自の「アプリのアプデでいらなくなった」という状態のリストを追加する。 var dummyListIdentity = "dummy_reomved"; var removedABListStr = "{\"identity\":\"" + dummyListIdentity + "\",\"target\":\"iOS\",\"version\":\"1.0.0\",\"assetBundles\":[{\"bundleName\":\"sample\",\"assetNames\":[\"Assets/AutoyaTests/RuntimeData/AssetBundles/SubResources/sample.txt\"],\"dependsBundleNames\":[],\"crc\":1672014196,\"hash\":\"720461ec2bb1aecd2ce41903f3a7d205\",\"size\":754}]}"; Autoya.Persist_Update(AssetBundlesSettings.ASSETBUNDLES_LIST_STORED_DOMAIN, "dummyList.json", removedABListStr); Autoya.TestEntryPoint(dataPath); { var loginDone = false; Autoya.Auth_SetOnAuthenticated( () => { loginDone = true; } ); yield return(WaitUntil( () => { return loginDone; }, () => { throw new TimeoutException("timeout."); } )); } abReady = false; Autoya.AssetBundle_DownloadAssetBundleListsIfNeed( results => { abReady = true; }, (code, reason, status) => { Debug.LogError("failed to download ABList, code:" + code + " reason:" + reason); } ); while (!abReady) { yield return(null); } // dummy abList should be deleted. var lists = Autoya.AssetBundle_AssetBundleLists(); var storedIdentities = lists.Select(list => list.identity).ToArray(); Assert.True(!storedIdentities.Contains(dummyListIdentity), "contained."); // all identites are matched. foreach (var defaultGeneratedABListIdentitiy in defaultGeneratedABListIdentities) { Assert.True(storedIdentities.Contains(defaultGeneratedABListIdentitiy), "not contained."); } foreach (var storedIdentity in storedIdentities) { Assert.True(defaultGeneratedABListIdentities.Contains(storedIdentity), "not contained."); } }
public IEnumerator AvoidHttpAuthFailCascade() { Autoya.forceFailAuthentication = true; var retryActs = new List <Action>(); Action authDoneAct = () => { retryActs.ForEach(r => r()); retryActs.Clear(); }; Autoya.Auth_SetOnAuthenticated(authDoneAct); var conCount = 10; var doneConIds = new List <string>(); var onceFailed = new List <string>(); var connections = new List <Action>(); for (var i = 0; i < conCount; i++) { var index = i; var currentConId = i.ToString(); connections.Add( () => { Autoya.Http_Get( "https://httpbin.org/status/200", (conId, resultData) => { doneConIds.Add(conId); }, (conId, code, reason, autoyaStatus) => { if (autoyaStatus.isAuthFailed) { onceFailed.Add(conId); retryActs.Add(connections[index]); } }, null, 5, currentConId ); } ); } // 通信の全てが行われればOK foreach (var act in connections) { act(); } // once failed. yield return(WaitUntil( () => onceFailed.Count == conCount, () => { throw new TimeoutException("too late."); }, 10 )); // refreshの完全なfailまでには8秒以上あるので、ここでフラグを変更しても十分にリトライに間に合うはず Autoya.forceFailAuthentication = false; // once failed. yield return(WaitUntil( () => doneConIds.Count == conCount, () => { throw new TimeoutException("too late."); }, 10 )); }