-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TabView Compact TabViewWidthMode and new CloseButtonOverlayMode prope…
…rty (#2016) * Add/update enums * Add properties * Update test page to handle new values * Add initial logic for handling switching to and from compact width mode * Add API test for compact width mode * Initial feature set for CloseButtonOverlayMode * Add initial CloseButtonOverlayMode tests * Update CloseButtonOverlayMode Auto behavior * Revert inner loop sln * CR feedback * Switch to visual states for close button * CR feedback * Set correct package availability level for TabView close button hover mode * Add necessary WUXC_VERSION_PREVIEW tags * CR feedback * CR feedback the second * Revert failing A PI test * Switch to lambdas to use const * Update names in CloseButtonOverlaymode API
- Loading branch information
Showing
16 changed files
with
432 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using MUXControlsTestApp.Utilities; | ||
using System; | ||
using System.Threading; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Markup; | ||
using Windows.UI.Xaml.Media; | ||
using Common; | ||
using Microsoft.UI.Xaml.Controls; | ||
using System.Collections.Generic; | ||
|
||
#if USING_TAEF | ||
using WEX.TestExecution; | ||
using WEX.TestExecution.Markup; | ||
using WEX.Logging.Interop; | ||
#else | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging; | ||
#endif | ||
|
||
using Symbol = Windows.UI.Xaml.Controls.Symbol; | ||
|
||
namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests | ||
{ | ||
|
||
[TestClass] | ||
public class TabViewTests : ApiTestBase | ||
{ | ||
|
||
[TestMethod] | ||
public void VerifyCompactTabWidthVisualStates() | ||
{ | ||
TabView tabView = null; | ||
RunOnUIThread.Execute(() => | ||
{ | ||
tabView = new TabView(); | ||
Content = tabView; | ||
|
||
tabView.TabItems.Add(CreateTabViewItem("Item 0", Symbol.Add)); | ||
tabView.TabItems.Add(CreateTabViewItem("Item 1", Symbol.AddFriend)); | ||
tabView.TabItems.Add(CreateTabViewItem("Item 2")); | ||
|
||
tabView.SelectedIndex = 0; | ||
tabView.SelectedItem = tabView.TabItems[0]; | ||
(tabView.SelectedItem as TabViewItem).IsSelected = true; | ||
Verify.AreEqual("Item 0", (tabView.SelectedItem as TabViewItem).Header); | ||
tabView.TabWidthMode = TabViewWidthMode.Compact; | ||
Content.UpdateLayout(); | ||
}); | ||
|
||
IdleSynchronizer.Wait(); | ||
|
||
// Check if switching to compact updates all items correctly | ||
RunOnUIThread.Execute(() => | ||
{ | ||
VerifyTabWidthVisualStates(tabView.TabItems, true); | ||
tabView.TabItems.Add(CreateTabViewItem("Item 3")); | ||
}); | ||
|
||
IdleSynchronizer.Wait(); | ||
|
||
// Check if a newly added item has correct visual states | ||
RunOnUIThread.Execute(() => | ||
{ | ||
VerifyTabWidthVisualStates(tabView.TabItems, true); | ||
tabView.TabWidthMode = TabViewWidthMode.Equal; | ||
}); | ||
|
||
IdleSynchronizer.Wait(); | ||
|
||
// Switch back to non compact and check if every item has the correct visual state | ||
RunOnUIThread.Execute(() => | ||
{ | ||
VerifyTabWidthVisualStates(tabView.TabItems, false); | ||
}); | ||
} | ||
|
||
private static void VerifyTabWidthVisualStates(IList<object> items, bool isCompact) | ||
{ | ||
foreach (var item in items) | ||
{ | ||
var tabItem = item as TabViewItem; | ||
if (tabItem.IsSelected || !isCompact) | ||
{ | ||
VisualStateHelper.ContainsVisualState(tabItem, "StandardWidth"); | ||
} | ||
else | ||
{ | ||
VisualStateHelper.ContainsVisualState(tabItem, "Compact"); | ||
} | ||
} | ||
} | ||
|
||
private static TabViewItem CreateTabViewItem(string name, Symbol icon, bool closable = true, bool enabled = true) | ||
{ | ||
var tabViewItem = new TabViewItem(); | ||
|
||
tabViewItem.Header = name; | ||
tabViewItem.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = icon }; | ||
tabViewItem.IsClosable = closable; | ||
tabViewItem.IsEnabled = enabled; | ||
|
||
return tabViewItem; | ||
} | ||
|
||
private static TabViewItem CreateTabViewItem(string name, bool closable = true, bool enabled = true) | ||
{ | ||
var tabViewItem = new TabViewItem(); | ||
|
||
tabViewItem.Header = name; | ||
tabViewItem.IsClosable = closable; | ||
tabViewItem.IsEnabled = enabled; | ||
|
||
return tabViewItem; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. --> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
<HasSharedItems>true</HasSharedItems> | ||
<SharedGUID>2f4e95e9-f729-481c-b9aa-c9bec91ae395</SharedGUID> | ||
</PropertyGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<Import_RootNamespace>TabView_APITests</Import_RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildThisFileDirectory)TabViewTests.cs" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>2f4e95e9-f729-481c-b9aa-c9bec91ae395</ProjectGuid> | ||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" /> | ||
<PropertyGroup /> | ||
<Import Project="TabView_APITests.projitems" Label="Shared" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.