| | 1 | | using NUnit.Framework; |
| | 2 | | using UnityEditor; |
| | 3 | |
|
| | 4 | | namespace Tests |
| | 5 | | { |
| | 6 | | public class SceneContextMenuShould |
| | 7 | | { |
| | 8 | | private SceneCardViewContextMenu contextMenu; |
| | 9 | |
|
| | 10 | | [SetUp] |
| | 11 | | public void SetUp() |
| | 12 | | { |
| | 13 | | const string prefabAssetPath = |
| | 14 | | "Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Prefabs/SceneCardViewContextMenu.pr |
| 3 | 15 | | var prefab = AssetDatabase.LoadAssetAtPath<SceneCardViewContextMenu>(prefabAssetPath); |
| 3 | 16 | | contextMenu = UnityEngine.Object.Instantiate(prefab); |
| 3 | 17 | | } |
| | 18 | |
|
| | 19 | | [TearDown] |
| 6 | 20 | | public void TearDown() { UnityEngine.Object.Destroy(contextMenu.gameObject); } |
| | 21 | |
|
| | 22 | | [Test] |
| | 23 | | [Explicit("Not valid for MVP version")] |
| | 24 | | public void ShowOptionsForOwnerDeployedScene() |
| | 25 | | { |
| 0 | 26 | | contextMenu.Show("", isSceneDeployed: true, isOwnerOrOperator: true, isContributor: false); |
| | 27 | |
|
| 0 | 28 | | Assert.IsFalse(contextMenu.deleteButton.gameObject.activeSelf, "Option should not be displayed"); |
| 0 | 29 | | Assert.IsFalse(contextMenu.shareButton.gameObject.activeSelf, "Option should not be displayed"); |
| 0 | 30 | | Assert.IsFalse(contextMenu.duplicateButton.gameObject.activeSelf, "Option should not be displayed"); |
| 0 | 31 | | Assert.IsFalse(contextMenu.quitContributorButton.gameObject.activeSelf, "Option should not be displayed"); |
| | 32 | |
|
| 0 | 33 | | Assert.IsTrue(contextMenu.settingsButton.gameObject.activeSelf, "Option should be displayed"); |
| 0 | 34 | | Assert.IsTrue(contextMenu.duplicateAsProjectButton.gameObject.activeSelf, "Option should be displayed"); |
| 0 | 35 | | Assert.IsTrue(contextMenu.downloadButton.gameObject.activeSelf, "Option should be displayed"); |
| 0 | 36 | | Assert.IsTrue(contextMenu.unpublishButton.gameObject.activeSelf, "Option should be displayed"); |
| 0 | 37 | | } |
| | 38 | |
|
| | 39 | | [Test] |
| | 40 | | public void ShowOptionsForOwnerDeployedSceneMVP() |
| | 41 | | { |
| 1 | 42 | | contextMenu.Show("", isSceneDeployed: true, isOwnerOrOperator: true, isContributor: false); |
| | 43 | |
|
| 1 | 44 | | Assert.IsFalse(contextMenu.deleteButton.gameObject.activeSelf, "Option should not be displayed"); |
| 1 | 45 | | Assert.IsFalse(contextMenu.shareButton.gameObject.activeSelf, "Option should not be displayed"); |
| 1 | 46 | | Assert.IsFalse(contextMenu.duplicateButton.gameObject.activeSelf, "Option should not be displayed"); |
| 1 | 47 | | Assert.IsFalse(contextMenu.quitContributorButton.gameObject.activeSelf, "Option should not be displayed"); |
| 1 | 48 | | Assert.IsFalse(contextMenu.settingsButton.gameObject.activeSelf, "Option should not be displayed"); |
| 1 | 49 | | Assert.IsFalse(contextMenu.duplicateAsProjectButton.gameObject.activeSelf, "Option should not be displayed") |
| 1 | 50 | | Assert.IsFalse(contextMenu.downloadButton.gameObject.activeSelf, "Option should not be displayed"); |
| 1 | 51 | | Assert.IsTrue(contextMenu.unpublishButton.gameObject.activeSelf, "Option should be displayed"); |
| 1 | 52 | | } |
| | 53 | |
|
| | 54 | | [Test] |
| | 55 | | [Explicit("Not valid for MVP version")] |
| | 56 | | public void ShowOptionsForContributorDeployedScene() |
| | 57 | | { |
| 0 | 58 | | contextMenu.Show("", isSceneDeployed: true, isOwnerOrOperator: false, isContributor: true); |
| | 59 | |
|
| 0 | 60 | | Assert.IsFalse(contextMenu.deleteButton.gameObject.activeSelf, "Option should not be displayed"); |
| 0 | 61 | | Assert.IsFalse(contextMenu.shareButton.gameObject.activeSelf, "Option should not be displayed"); |
| 0 | 62 | | Assert.IsFalse(contextMenu.duplicateButton.gameObject.activeSelf, "Option should not be displayed"); |
| 0 | 63 | | Assert.IsFalse(contextMenu.settingsButton.gameObject.activeSelf, "Option should not be displayed"); |
| 0 | 64 | | Assert.IsFalse(contextMenu.unpublishButton.gameObject.activeSelf, "Option should not be displayed"); |
| | 65 | |
|
| 0 | 66 | | Assert.IsTrue(contextMenu.duplicateAsProjectButton.gameObject.activeSelf, "Option should be displayed"); |
| 0 | 67 | | Assert.IsTrue(contextMenu.downloadButton.gameObject.activeSelf, "Option should be displayed"); |
| 0 | 68 | | Assert.IsTrue(contextMenu.quitContributorButton.gameObject.activeSelf, "Option should be displayed"); |
| 0 | 69 | | } |
| | 70 | |
|
| | 71 | | [Test] |
| | 72 | | public void ShowOptionsForOwnerProjectScene() |
| | 73 | | { |
| 1 | 74 | | contextMenu.Show("", isSceneDeployed: false, isOwnerOrOperator: true, isContributor: false); |
| | 75 | |
|
| 1 | 76 | | Assert.IsFalse(contextMenu.quitContributorButton.gameObject.activeSelf, "Option should not be displayed"); |
| 1 | 77 | | Assert.IsFalse(contextMenu.duplicateAsProjectButton.gameObject.activeSelf, "Option should not be displayed") |
| 1 | 78 | | Assert.IsFalse(contextMenu.unpublishButton.gameObject.activeSelf, "Option should not be displayed"); |
| | 79 | |
|
| 1 | 80 | | Assert.IsTrue(contextMenu.duplicateButton.gameObject.activeSelf, "Option should be displayed"); |
| 1 | 81 | | Assert.IsTrue(contextMenu.settingsButton.gameObject.activeSelf, "Option should be displayed"); |
| 1 | 82 | | Assert.IsTrue(contextMenu.downloadButton.gameObject.activeSelf, "Option should be displayed"); |
| 1 | 83 | | Assert.IsTrue(contextMenu.deleteButton.gameObject.activeSelf, "Option should be displayed"); |
| 1 | 84 | | Assert.IsTrue(contextMenu.shareButton.gameObject.activeSelf, "Option should be displayed"); |
| 1 | 85 | | } |
| | 86 | |
|
| | 87 | | [Test] |
| | 88 | | public void ShowOptionsForContributorProjectScene() |
| | 89 | | { |
| 1 | 90 | | contextMenu.Show("", isSceneDeployed: false, isOwnerOrOperator: false, isContributor: true); |
| | 91 | |
|
| 1 | 92 | | Assert.IsFalse(contextMenu.duplicateAsProjectButton.gameObject.activeSelf, "Option should not be displayed") |
| 1 | 93 | | Assert.IsFalse(contextMenu.unpublishButton.gameObject.activeSelf, "Option should not be displayed"); |
| 1 | 94 | | Assert.IsFalse(contextMenu.settingsButton.gameObject.activeSelf, "Option should not be displayed"); |
| 1 | 95 | | Assert.IsFalse(contextMenu.deleteButton.gameObject.activeSelf, "Option should not be displayed"); |
| | 96 | |
|
| 1 | 97 | | Assert.IsTrue(contextMenu.duplicateButton.gameObject.activeSelf, "Option should be displayed"); |
| 1 | 98 | | Assert.IsTrue(contextMenu.downloadButton.gameObject.activeSelf, "Option should be displayed"); |
| 1 | 99 | | Assert.IsTrue(contextMenu.shareButton.gameObject.activeSelf, "Option should be displayed"); |
| 1 | 100 | | Assert.IsTrue(contextMenu.quitContributorButton.gameObject.activeSelf, "Option should be displayed"); |
| 1 | 101 | | } |
| | 102 | | } |
| | 103 | | } |