public override IEnumerator RunTest() { // Show some empty view as a background for the toasts: ViewStackHelper.MainViewStack().ShowView(someUiScreenPrefabName); Toast.Show("Some toast 1", "Lorem ipsum 1"); yield return(new WaitForSeconds(1)); Toast.Show("Some toast 2"); // In between show another screen on the main view stack, to ensure it does not interrupt showing the toasts: ViewStackHelper.MainViewStack().SwitchToView(someUiScreenPrefabName); yield return(new WaitForSeconds(1)); var toast3 = Toast.Show("Some toast 3", "Lorem ipsum 3", 2500); AssertV2.IsFalse(toast3.IsDestroyed(), "Toast was already destroyed"); yield return(new WaitForSeconds(3)); AssertV2.IsTrue(toast3.IsDestroyed(), "Toast could not be destroyed"); RootCanvas.GetAllRootCanvases().Single().gameObject.Destroy(); Toast.Show("Some toast 4"); yield return(new WaitForSeconds(3)); }
private async Task ShowAllDialogs() { AssertVisually.SetupDefaultSingletonInDebugMode(); ViewStackHelper.MainViewStack().ShowView("Canvas/DefaultViewStackView"); await ShowCancelConfirmDialog(); await ShowInfoDialog(); await ShowWarningDialog(); await ShowErrorDialog(); await UseDialogLoaderManually(); }
private static GameObject AddViewToMainViewStack(Func <GameObject> viewInViewStackCreator) { GameObject mainViewStack = ViewStackHelper.MainViewStack().gameObject; GameObject viewInViewStack = viewInViewStackCreator(); mainViewStack.AddChild(viewInViewStack); viewInViewStack.name += " " + mainViewStack.GetChildCount(); viewInViewStack.GetOrAddComponent <RectTransform>().SetAnchorsStretchStretch(); SelectInHirarchyUi(viewInViewStack); return(viewInViewStack); }
public override IEnumerator RunTest() { // Create an immutable datastore that will contain the data model in this example: var log = Middlewares.NewLoggingMiddleware <MyDataModel3>(); IDataStore <MyDataModel3> store = new DataStore <MyDataModel3>(MainReducer, new MyDataModel3(), log); IoC.inject.SetSingleton(store); // Create a presenter that connectes the model with the view (the Unity UI): var currentUserPresenter = new MyUserUi3(); // Set the target view by loading it from a prefab and setting the root GO: currentUserPresenter.targetView = ViewStackHelper.MainViewStack().ShowView("MyUserUi1"); // Connect the model changes with the presenter: currentUserPresenter.ListenToStoreUpdates(store, state => state.currentUser); // Dispatch a first setUser action to update the UI: store.Dispatch(new ActionSetNewUser() { newUser = new MyUser3("Carl", 99) }); // Delay needed since the UI update simulates a delay too: yield return(new WaitForSeconds(0.5f)); // Check that the UI was automatically updated: AssertV2.AreEqual("Carl", currentUserPresenter.NameUi().text); AssertV2.AreEqual("99", currentUserPresenter.AgeUi().text); // Simulate that the user changed the model via the UI: store.Dispatch(new ActionUpdateUser() { target = store.GetState().currentUser, newValues = new MyUser3("Paul", 0) }); // Delay needed since the UI update simulates a delay too: yield return(new WaitForSeconds(2f)); // Check that the UI was automatically updated: AssertV2.AreEqual("Paul", currentUserPresenter.NameUi().text); AssertV2.AreEqual("0", currentUserPresenter.AgeUi().text); }
private static IEnumerable <GameObject> GetAllActiveViewsInMainViewStack() { return(ViewStackHelper.MainViewStack().gameObject.GetChildrenIEnumerable().Filter(v => v.activeInHierarchy)); }
public static IEnumerator RunTest <T>(string prefabName) where T : UnitTestMono { ViewStack viewStack = ViewStackHelper.MainViewStack(); yield return(RunTest <T>(viewStack, prefabName)); }