mirror of
https://github.com/RaindropViewer/RaindropViewer.git
synced 2026-07-27 22:11:39 +00:00
test: fix GridDropdown_HasManyGrids regression from past refactoring
This commit is contained in:
committed by
alexiscatnip
parent
8b9fcdef8d
commit
68ce9a7fa6
+20
-28
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using NUnit.Framework;
|
||||
using Plugins.CommonDependencies;
|
||||
using Raindrop.Tests.RaindropIntegrationTests.Helpers;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
@@ -12,33 +13,19 @@ namespace Raindrop.Tests.RaindropIntegrationTests.GridSelectorTests
|
||||
public class GridSelectorTests
|
||||
{
|
||||
//https://forum.unity.com/threads/add-coroutine-version-of-onetimesetup.890092/
|
||||
private bool initialized = false;
|
||||
[UnitySetUp]
|
||||
public IEnumerator UnitySetup()
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = true;
|
||||
|
||||
//+++++++++++++load test scene+++++++
|
||||
// load the base scene
|
||||
yield return SceneLoader.LoadHeadlessScene();
|
||||
|
||||
//at this point, raindropInstance is ready.
|
||||
var instance = ServiceLocator.Instance.Get<RaindropInstance>();
|
||||
Assert.True(instance!=null, "instance is null");
|
||||
|
||||
//open up the dropdown small ui.
|
||||
string pathOfPrefabDirectory = "LoginUI/";
|
||||
string prefabName = "GridSelection";
|
||||
var dropdownUI = GameObject.Instantiate(
|
||||
Resources.Load(pathOfPrefabDirectory+prefabName)
|
||||
) as GameObject;
|
||||
Assert.True(dropdownUI!=null, "dropdown prefab not found in resources");
|
||||
//+++++++++++++finish load test scene+++++++
|
||||
yield return null;
|
||||
|
||||
}
|
||||
//+++++++++++++load test scene+++++++
|
||||
// load the base scene
|
||||
yield return SceneLoader.LoadHeadlessScene();
|
||||
|
||||
//at this point, raindropInstance is ready.
|
||||
var instance = ServiceLocator.Instance.Get<RaindropInstance>();
|
||||
Assert.True(instance!=null, "instance is null");
|
||||
|
||||
//+++++++++++++finish load test scene+++++++
|
||||
yield return null;
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
@@ -51,11 +38,16 @@ namespace Raindrop.Tests.RaindropIntegrationTests.GridSelectorTests
|
||||
[UnityTest]
|
||||
public IEnumerator GridDropdown_HasManyGrids()
|
||||
{
|
||||
//load and open up the dropdown small ui.
|
||||
string pathOfPrefabDirectory = "Assets/Raindrop/UI/Login/";
|
||||
string prefabName = "GridSelection.prefab";
|
||||
var prefab = AssetDatabase.LoadAssetAtPath(pathOfPrefabDirectory+prefabName, typeof(GameObject));
|
||||
GameObject dropdownUI = (GameObject) GameObject.Instantiate(prefab);
|
||||
Assert.True(dropdownUI!=null, "dropdown prefab not found in resources");
|
||||
|
||||
//click dropdown UI to reveal its full content
|
||||
var dropdown_GO = GameObject.Find("Dropdown");
|
||||
Assert.True(dropdown_GO,"the GO with name Dropdown is not found");
|
||||
GridSelectionView gridGridSelection = dropdown_GO.GetComponent<GridSelectionView>();
|
||||
Assert.True(gridGridSelection,"the dropdown doesnt have DropdownViewPresenter");
|
||||
GridSelectionView gridGridSelection = dropdownUI.GetComponent<GridSelectionView>();
|
||||
Assert.True(gridGridSelection,"the dropdown doesnt have GridSelectionView");
|
||||
|
||||
yield return new WaitForSeconds(2); // seems if you don't wait, the options count are not updated yet.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user