Forráskód Böngészése

Fixes to tests, include additional unit tests

Signed-off-by: Danilo Aimini <[email protected]>
Danilo Aimini 2 éve
szülő
commit
2a03028e98

+ 1 - 1
Code/Framework/AzToolsFramework/AzToolsFramework/ActionManager/Action/EditorActionContext.h

@@ -21,7 +21,7 @@ namespace AzToolsFramework
     constexpr const char* DefaultModeIdentifier = "default";
     constexpr const char* DefaultModeIdentifier = "default";
 
 
     //! Editor Action Context class definition.
     //! Editor Action Context class definition.
-    //! Identifies a collection of Actions in the context of 
+    //! Identifies a collection of Actions and their accessibility in the context of the whole O3DE Editor.
     class EditorActionContext
     class EditorActionContext
         : public QObject
         : public QObject
     {
     {

+ 70 - 3
Code/Framework/AzToolsFramework/Tests/ActionManager/MenuManagerTests.cpp

@@ -779,16 +779,16 @@ namespace UnitTest
         EXPECT_EQ(menu->actions().size(), 0);
         EXPECT_EQ(menu->actions().size(), 0);
     }
     }
 
 
-    TEST_F(ActionManagerFixture, VerifyHideFromMenusWhenDisabledFalse)
+    TEST_F(ActionManagerFixture, VerifyMenuVisibilityAlwaysShow)
     {
     {
         // Register menu, get it and verify it's empty.
         // Register menu, get it and verify it's empty.
         m_menuManagerInterface->RegisterMenu("o3de.menu.test", {});
         m_menuManagerInterface->RegisterMenu("o3de.menu.test", {});
         QMenu* menu = m_menuManagerInternalInterface->GetMenu("o3de.menu.test");
         QMenu* menu = m_menuManagerInternalInterface->GetMenu("o3de.menu.test");
         EXPECT_EQ(menu->actions().size(), 0);
         EXPECT_EQ(menu->actions().size(), 0);
 
 
-        // Register a new action and add it to the menu. Have HideFromMenusWhenDisabled set to true.
+        // Register a new action and add it to the menu. Have MenuVisibility set to ALWAYS_SHOW.
         AzToolsFramework::ActionProperties actionProperties;
         AzToolsFramework::ActionProperties actionProperties;
-        actionProperties.m_hideFromMenusWhenDisabled = false;
+        actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::ALWAYS_SHOW;
 
 
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", actionProperties, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", actionProperties, []{});
@@ -821,6 +821,73 @@ namespace UnitTest
         EXPECT_EQ(menu->actions().size(), 1);
         EXPECT_EQ(menu->actions().size(), 1);
     }
     }
 
 
+    TEST_F(ActionManagerFixture, VerifyActionIsHiddenWhenChangingMode)
+    {
+        // Register menu, get it and verify it's empty.
+        m_menuManagerInterface->RegisterMenu("o3de.menu.test", {});
+        QMenu* menu = m_menuManagerInternalInterface->GetMenu("o3de.menu.test");
+        EXPECT_EQ(menu->actions().size(), 0);
+
+        // Register a new action and add it to the default mode.
+        m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
+        m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", {}, []{});
+        m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, "o3de.action.test");
+
+        // Add the action to the menu.
+        m_menuManagerInterface->AddActionToMenu("o3de.menu.test", "o3de.action.test", 42);
+
+        // Manually trigger Menu refresh - Editor will call this once per tick.
+        m_menuManagerInternalInterface->RefreshMenus();
+
+        // Verify the action is now in the menu.
+        EXPECT_EQ(menu->actions().size(), 1);
+
+        // Register a new mode and switch to it.
+        m_actionManagerInterface->RegisterActionContextMode("o3de.context.test", "testMode");
+        m_actionManagerInterface->SetActiveActionContextMode("o3de.context.test", "testMode");
+
+        // Manually trigger Menu refresh - Editor will call this once per tick.
+        m_menuManagerInternalInterface->RefreshMenus();
+
+        // Verify the action is no longer in the menu.
+        EXPECT_EQ(menu->actions().size(), 0);
+    }
+
+    TEST_F(ActionManagerFixture, VerifyMenuVisibilityAlwaysShowWhenChangingMode)
+    {
+        // Register menu, get it and verify it's empty.
+        m_menuManagerInterface->RegisterMenu("o3de.menu.test", {});
+        QMenu* menu = m_menuManagerInternalInterface->GetMenu("o3de.menu.test");
+        EXPECT_EQ(menu->actions().size(), 0);
+
+        // Register a new action and add it to the default mode. Have MenuVisibility set to ALWAYS_SHOW.
+        AzToolsFramework::ActionProperties actionProperties;
+        actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::ALWAYS_SHOW;
+
+        m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
+        m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", actionProperties, []{});
+        m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, "o3de.action.test");
+
+        // Add the action to the menu.
+        m_menuManagerInterface->AddActionToMenu("o3de.menu.test", "o3de.action.test", 42);
+
+        // Manually trigger Menu refresh - Editor will call this once per tick.
+        m_menuManagerInternalInterface->RefreshMenus();
+
+        // Verify the action is now in the menu.
+        EXPECT_EQ(menu->actions().size(), 1);
+
+        // Register a new mode and switch to it.
+        m_actionManagerInterface->RegisterActionContextMode("o3de.context.test", "testMode");
+        m_actionManagerInterface->SetActiveActionContextMode("o3de.context.test", "testMode");
+
+        // Manually trigger Menu refresh - Editor will call this once per tick.
+        m_menuManagerInternalInterface->RefreshMenus();
+
+        // Verify the action is still in the menu.
+        EXPECT_EQ(menu->actions().size(), 1);
+    }
+
     TEST_F(ActionManagerFixture, VerifySubMenuIsHiddenWhenEmptied)
     TEST_F(ActionManagerFixture, VerifySubMenuIsHiddenWhenEmptied)
     {
     {
         // Register menus
         // Register menus

+ 71 - 36
Code/Framework/AzToolsFramework/Tests/ActionManager/ToolBarManagerTests.cpp

@@ -153,12 +153,12 @@ namespace UnitTest
 
 
     TEST_F(ActionManagerFixture, VerifyActionInToolBar)
     TEST_F(ActionManagerFixture, VerifyActionInToolBar)
     {
     {
-        // Register toolbar, get it and verify it's empty.
+        // Register ToolBar, get it and verify it's empty.
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         EXPECT_EQ(toolBar->actions().size(), 0);
         EXPECT_EQ(toolBar->actions().size(), 0);
 
 
-        // Register a new action and add it to the toolbar.
+        // Register a new action and add it to the ToolBar.
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", {}, []{});
         auto outcome = m_toolBarManagerInterface->AddActionToToolBar("o3de.toolbar.test", "o3de.action.test", 42);
         auto outcome = m_toolBarManagerInterface->AddActionToToolBar("o3de.toolbar.test", "o3de.action.test", 42);
@@ -166,18 +166,18 @@ namespace UnitTest
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBars();
         m_toolBarManagerInternalInterface->RefreshToolBars();
 
 
-        // Verify the action is now in the toolbar.
+        // Verify the action is now in the ToolBar.
         EXPECT_EQ(toolBar->actions().size(), 1);
         EXPECT_EQ(toolBar->actions().size(), 1);
     }
     }
 
 
     TEST_F(ActionManagerFixture, VerifyActionOrderInToolBar)
     TEST_F(ActionManagerFixture, VerifyActionOrderInToolBar)
     {
     {
-        // Register toolbar, get it and verify it's empty.
+        // Register ToolBar, get it and verify it's empty.
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         EXPECT_EQ(toolBar->actions().size(), 0);
         EXPECT_EQ(toolBar->actions().size(), 0);
 
 
-        // Register a new action and add it to the toolbar.
+        // Register a new action and add it to the ToolBar.
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test1", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test1", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test2", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test2", {}, []{});
@@ -187,7 +187,7 @@ namespace UnitTest
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBars();
         m_toolBarManagerInternalInterface->RefreshToolBars();
 
 
-        // Verify the actions are now in the toolbar.
+        // Verify the actions are now in the ToolBar.
         EXPECT_EQ(toolBar->actions().size(), 2);
         EXPECT_EQ(toolBar->actions().size(), 2);
 
 
         // Verify the order is correct.
         // Verify the order is correct.
@@ -201,12 +201,12 @@ namespace UnitTest
 
 
     TEST_F(ActionManagerFixture, VerifyActionOrderInToolBarWithCollision)
     TEST_F(ActionManagerFixture, VerifyActionOrderInToolBarWithCollision)
     {
     {
-        // Register toolbar, get it and verify it's empty.
+        // Register ToolBar, get it and verify it's empty.
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         EXPECT_EQ(toolBar->actions().size(), 0);
         EXPECT_EQ(toolBar->actions().size(), 0);
         
         
-        // Register a new action and add it to the toolbar.
+        // Register a new action and add it to the ToolBar.
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test1", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test1", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test2", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test2", {}, []{});
@@ -216,7 +216,7 @@ namespace UnitTest
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBars();
         m_toolBarManagerInternalInterface->RefreshToolBars();
 
 
-        // Verify the actions are now in the toolbar.
+        // Verify the actions are now in the ToolBar.
         EXPECT_EQ(toolBar->actions().size(), 2);
         EXPECT_EQ(toolBar->actions().size(), 2);
 
 
         // Verify the order is correct (when a collision happens, items should be in order of addition).
         // Verify the order is correct (when a collision happens, items should be in order of addition).
@@ -230,18 +230,18 @@ namespace UnitTest
 
 
     TEST_F(ActionManagerFixture, VerifySeparatorInToolBar)
     TEST_F(ActionManagerFixture, VerifySeparatorInToolBar)
     {
     {
-        // Register toolbar, get it and verify it's empty.
+        // Register ToolBar, get it and verify it's empty.
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         EXPECT_EQ(toolBar->actions().size(), 0);
         EXPECT_EQ(toolBar->actions().size(), 0);
 
 
-        // Add a separator to the toolbar.
+        // Add a separator to the ToolBar.
         m_toolBarManagerInterface->AddSeparatorToToolBar("o3de.toolbar.test", 42);
         m_toolBarManagerInterface->AddSeparatorToToolBar("o3de.toolbar.test", 42);
 
 
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBars();
         m_toolBarManagerInternalInterface->RefreshToolBars();
 
 
-        // Verify the separator is now in the toolbar.
+        // Verify the separator is now in the ToolBar.
         const auto& actions = toolBar->actions();
         const auto& actions = toolBar->actions();
 
 
         EXPECT_EQ(actions.size(), 1);
         EXPECT_EQ(actions.size(), 1);
@@ -250,7 +250,7 @@ namespace UnitTest
 
 
     TEST_F(ActionManagerFixture, AddUnregisteredWidgetInToolBar)
     TEST_F(ActionManagerFixture, AddUnregisteredWidgetInToolBar)
     {
     {
-        // Register toolbar.
+        // Register ToolBar.
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
 
 
         // Try to add a nullptr widget.
         // Try to add a nullptr widget.
@@ -260,7 +260,7 @@ namespace UnitTest
 
 
     TEST_F(ActionManagerFixture, VerifyWidgetInToolBar)
     TEST_F(ActionManagerFixture, VerifyWidgetInToolBar)
     {
     {
-        // Register toolbar and widget action.
+        // Register ToolBar and widget action.
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
 
 
         QWidget* widget = new QWidget();
         QWidget* widget = new QWidget();
@@ -275,13 +275,13 @@ namespace UnitTest
             }
             }
         );
         );
 
 
-        // Add the widget to the toolbar.
+        // Add the widget to the ToolBar.
         m_toolBarManagerInterface->AddWidgetToToolBar("o3de.toolbar.test", "o3de.widgetAction.test", 42);
         m_toolBarManagerInterface->AddWidgetToToolBar("o3de.toolbar.test", "o3de.widgetAction.test", 42);
 
 
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBars();
         m_toolBarManagerInternalInterface->RefreshToolBars();
 
 
-        // Verify the separator is now in the menu.
+        // Verify the separator is now in the ToolBar.
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         const auto& actions = toolBar->actions();
         const auto& actions = toolBar->actions();
 
 
@@ -301,7 +301,7 @@ namespace UnitTest
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test1", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test1", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test2", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test2", {}, []{});
 
 
-        // Create a toolbar with this setup. Order of addition is intentionally scrambled to verify sortKeys.
+        // Create a ToolBar with this setup. Order of addition is intentionally scrambled to verify sortKeys.
         // - Test 1 Action
         // - Test 1 Action
         // - Separator
         // - Separator
         // - Test 2 Action
         // - Test 2 Action
@@ -309,7 +309,7 @@ namespace UnitTest
         m_toolBarManagerInterface->AddActionToToolBar("o3de.toolbar.test", "o3de.action.test1", 1);
         m_toolBarManagerInterface->AddActionToToolBar("o3de.toolbar.test", "o3de.action.test1", 1);
         m_toolBarManagerInterface->AddSeparatorToToolBar("o3de.toolbar.test", 10);
         m_toolBarManagerInterface->AddSeparatorToToolBar("o3de.toolbar.test", 10);
 
 
-        // Verify the actions are now in the toolbar in the expected order.
+        // Verify the actions are now in the ToolBar in the expected order.
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         QAction* test1 = m_actionManagerInternalInterface->GetAction("o3de.action.test1");
         QAction* test1 = m_actionManagerInternalInterface->GetAction("o3de.action.test1");
         QAction* test2 = m_actionManagerInternalInterface->GetAction("o3de.action.test2");
         QAction* test2 = m_actionManagerInternalInterface->GetAction("o3de.action.test2");
@@ -317,7 +317,7 @@ namespace UnitTest
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBars();
         m_toolBarManagerInternalInterface->RefreshToolBars();
 
 
-        // Note: separators and sub-menus are still QActions in the context of the toolbar.
+        // Note: separators are still QActions in the context of the ToolBar.
         const auto& actions = toolBar->actions();
         const auto& actions = toolBar->actions();
         EXPECT_EQ(actions.size(), 3);
         EXPECT_EQ(actions.size(), 3);
 
 
@@ -359,13 +359,13 @@ namespace UnitTest
         m_toolBarManagerInterface->RegisterToolBarArea("o3de.toolbararea.test", m_mainWindow, Qt::ToolBarArea::TopToolBarArea);
         m_toolBarManagerInterface->RegisterToolBarArea("o3de.toolbararea.test", m_mainWindow, Qt::ToolBarArea::TopToolBarArea);
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
 
 
-        // Add the toolbar to the toolbar area.
+        // Add the ToolBar to the toolbar area.
         m_toolBarManagerInterface->AddToolBarToToolBarArea("o3de.toolbararea.test", "o3de.toolbar.test", 42);
         m_toolBarManagerInterface->AddToolBarToToolBarArea("o3de.toolbararea.test", "o3de.toolbar.test", 42);
 
 
-        // Manually trigger toolbar refresh - Editor will call this once per tick.
+        // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBarAreas();
         m_toolBarManagerInternalInterface->RefreshToolBarAreas();
 
 
-        // Verify the toolbar is now in the toolbar area.
+        // Verify the ToolBar is now in the ToolBar Area.
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         EXPECT_EQ(m_mainWindow->toolBarArea(toolBar), Qt::ToolBarArea::TopToolBarArea);
         EXPECT_EQ(m_mainWindow->toolBarArea(toolBar), Qt::ToolBarArea::TopToolBarArea);
     }
     }
@@ -376,7 +376,7 @@ namespace UnitTest
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", {}, []{});
 
 
-        // Add the action to the toolbar.
+        // Add the action to the ToolBar.
         m_toolBarManagerInterface->AddActionToToolBar("o3de.toolbar.test", "o3de.action.test", 42);
         m_toolBarManagerInterface->AddActionToToolBar("o3de.toolbar.test", "o3de.action.test", 42);
 
 
         // Verify the API returns the correct sort key.
         // Verify the API returns the correct sort key.
@@ -400,7 +400,7 @@ namespace UnitTest
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", {}, []{});
 
 
-        // Verify the API fails as the action is registered but was not added to the toolbar.
+        // Verify the API fails as the action is registered but was not added to the ToolBar.
         auto outcome = m_toolBarManagerInterface->GetSortKeyOfActionInToolBar("o3de.toolbar.test", "o3de.action.test");
         auto outcome = m_toolBarManagerInterface->GetSortKeyOfActionInToolBar("o3de.toolbar.test", "o3de.action.test");
         EXPECT_FALSE(outcome.IsSuccess());
         EXPECT_FALSE(outcome.IsSuccess());
     }
     }
@@ -417,7 +417,7 @@ namespace UnitTest
             }
             }
         );
         );
 
 
-        // Add the widget to the toolBar.
+        // Add the widget to the ToolBar.
         m_toolBarManagerInterface->AddWidgetToToolBar("o3de.toolbar.test", "o3de.widgetAction.test", 42);
         m_toolBarManagerInterface->AddWidgetToToolBar("o3de.toolbar.test", "o3de.widgetAction.test", 42);
 
 
         // Verify the API returns the correct sort key.
         // Verify the API returns the correct sort key.
@@ -447,21 +447,21 @@ namespace UnitTest
             }
             }
         );
         );
 
 
-        // Verify the API fails as the widget is registered but was not added to the toolBar.
+        // Verify the API fails as the widget is registered but was not added to the ToolBar.
         auto outcome = m_toolBarManagerInterface->GetSortKeyOfWidgetInToolBar("o3de.toolbar.test", "o3de.widgetAction.test");
         auto outcome = m_toolBarManagerInterface->GetSortKeyOfWidgetInToolBar("o3de.toolbar.test", "o3de.widgetAction.test");
         EXPECT_FALSE(outcome.IsSuccess());
         EXPECT_FALSE(outcome.IsSuccess());
     }
     }
 
 
-    TEST_F(ActionManagerFixture, VerifyHideFromToolBarsWhenDisabledTrue)
+    TEST_F(ActionManagerFixture, VerifyToolBarVisibilityHideWhenDisabled)
     {
     {
         // Register toolbar, get it and verify it's empty.
         // Register toolbar, get it and verify it's empty.
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         EXPECT_EQ(toolBar->actions().size(), 0);
         EXPECT_EQ(toolBar->actions().size(), 0);
 
 
-        // Register a new action and add it to the menu. Have HideFromToolBarsWhenDisabled set to true.
+        // Register a new action and add it to the ToolBar. Have ToolBarVisibility set to HIDE_WHEN_DISABLED.
         AzToolsFramework::ActionProperties actionProperties;
         AzToolsFramework::ActionProperties actionProperties;
-        actionProperties.m_hideFromToolBarsWhenDisabled = true;
+        actionProperties.m_toolBarVisibility = AzToolsFramework::ActionVisibility::HIDE_WHEN_DISABLED;
 
 
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", actionProperties, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", actionProperties, []{});
@@ -480,7 +480,7 @@ namespace UnitTest
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBars();
         m_toolBarManagerInternalInterface->RefreshToolBars();
 
 
-        // Verify the action is now in the menu.
+        // Verify the action is now in the ToolBar.
         EXPECT_EQ(toolBar->actions().size(), 1);
         EXPECT_EQ(toolBar->actions().size(), 1);
 
 
         // Set the action as disabled.
         // Set the action as disabled.
@@ -490,18 +490,18 @@ namespace UnitTest
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBars();
         m_toolBarManagerInternalInterface->RefreshToolBars();
 
 
-        // Verify the action is no longer in the toolbar.
+        // Verify the action is no longer in the ToolBar.
         EXPECT_EQ(toolBar->actions().size(), 0);
         EXPECT_EQ(toolBar->actions().size(), 0);
     }
     }
 
 
-    TEST_F(ActionManagerFixture, VerifyHideFromToolBarsWhenDisabledFalse)
+    TEST_F(ActionManagerFixture, VerifyDefaultToolBarVisibility)
     {
     {
-        // Register toolbar, get it and verify it's empty.
+        // Register ToolBar, get it and verify it's empty.
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
         EXPECT_EQ(toolBar->actions().size(), 0);
         EXPECT_EQ(toolBar->actions().size(), 0);
 
 
-        // Register a new action and add it to the menu. HideFromToolBarsWhenDisabled is set to false by default.
+        // Register a new action and add it to the menu. ToolBarVisibility is set to ONLY_IN_ACTIVE_MODE by default.
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", {}, []{});
         m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", {}, []{});
         m_toolBarManagerInterface->AddActionToToolBar("o3de.toolbar.test", "o3de.action.test", 42);
         m_toolBarManagerInterface->AddActionToToolBar("o3de.toolbar.test", "o3de.action.test", 42);
@@ -519,7 +519,7 @@ namespace UnitTest
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBars();
         m_toolBarManagerInternalInterface->RefreshToolBars();
 
 
-        // Verify the action is now in the menu.
+        // Verify the action is now in the ToolBar.
         EXPECT_EQ(toolBar->actions().size(), 1);
         EXPECT_EQ(toolBar->actions().size(), 1);
 
 
         // Set the action as disabled.
         // Set the action as disabled.
@@ -529,7 +529,42 @@ namespace UnitTest
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         // Manually trigger ToolBar refresh - Editor will call this once per tick.
         m_toolBarManagerInternalInterface->RefreshToolBars();
         m_toolBarManagerInternalInterface->RefreshToolBars();
 
 
-        // Verify the action is still in the toolbar.
+        // Verify the action is still in the ToolBar.
+        EXPECT_EQ(toolBar->actions().size(), 1);
+    }
+
+    TEST_F(ActionManagerFixture, VerifyToolBarVisibilityAlwaysShowWhenChangingMode)
+    {
+        // Register ToolBar, get it and verify it's empty.
+        m_toolBarManagerInterface->RegisterToolBar("o3de.toolbar.test", {});
+        QToolBar* toolBar = m_toolBarManagerInterface->GetToolBar("o3de.toolbar.test");
+        EXPECT_EQ(toolBar->actions().size(), 0);
+
+        // Register a new action and add it to the default mode. Set ToolBarVisibility to ALWAYS_SHOW.
+        AzToolsFramework::ActionProperties actionProperties;
+        actionProperties.m_toolBarVisibility = AzToolsFramework::ActionVisibility::ALWAYS_SHOW;
+
+        m_actionManagerInterface->RegisterActionContext("", "o3de.context.test", {}, m_widget);
+        m_actionManagerInterface->RegisterAction("o3de.context.test", "o3de.action.test", actionProperties, []{});
+        m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, "o3de.action.test");
+
+        // Add the action to the ToolBar.
+        m_toolBarManagerInterface->AddActionToToolBar("o3de.toolbar.test", "o3de.action.test", 42);
+
+        // Manually trigger ToolBar refresh - Editor will call this once per tick.
+        m_toolBarManagerInternalInterface->RefreshToolBars();
+
+        // Verify the action is now in the ToolBar.
+        EXPECT_EQ(toolBar->actions().size(), 1);
+
+        // Register a new mode and switch to it.
+        m_actionManagerInterface->RegisterActionContextMode("o3de.context.test", "testMode");
+        m_actionManagerInterface->SetActiveActionContextMode("o3de.context.test", "testMode");
+
+        // Manually trigger ToolBar refresh - Editor will call this once per tick.
+        m_toolBarManagerInternalInterface->RefreshToolBars();
+
+        // Verify the action is still in the ToolBar.
         EXPECT_EQ(toolBar->actions().size(), 1);
         EXPECT_EQ(toolBar->actions().size(), 1);
     }
     }