-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4ac4a2
commit 8136301
Showing
12 changed files
with
353 additions
and
6 deletions.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
src/Controls/samples/Controls.Sample/Pages/Core/DropFileToMauiApp.xaml.cs
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,109 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Graphics; | ||
|
||
#if WINDOWS | ||
using Windows.ApplicationModel.DataTransfer; | ||
using Windows.Storage; | ||
#endif | ||
|
||
#if IOS || MACCATALYST | ||
using UIKit; | ||
using Foundation; | ||
#endif | ||
|
||
namespace Maui.Controls.Sample.Pages | ||
{ | ||
public partial class DropFileToMauiApp | ||
{ | ||
|
||
public DropFileToMauiApp() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
void DropGestureDragLeave(object? sender, DragEventArgs e) | ||
{ | ||
|
||
} | ||
|
||
async void DropGestureDrop(object? sender, DropEventArgs e) | ||
{ | ||
var filePaths = new List<string>(); | ||
|
||
#if WINDOWS | ||
if (e.PlatformArgs is not null && e.PlatformArgs.DragEventArgs.DataView.Contains(StandardDataFormats.StorageItems)) | ||
{ | ||
var items = await e.PlatformArgs.DragEventArgs.DataView.GetStorageItemsAsync(); | ||
if (items.Any()) | ||
{ | ||
foreach (var item in items) | ||
{ | ||
if (item is StorageFile file) | ||
{ | ||
filePaths.Add(item.Path); | ||
} | ||
} | ||
|
||
} | ||
} | ||
#elif MACCATALYST | ||
|
||
var session = e.PlatformArgs?.DropSession; | ||
if (session == null) | ||
{ | ||
return; | ||
} | ||
foreach (UIDragItem item in session.Items) | ||
{ | ||
var result = await LoadItemAsync(item.ItemProvider, item.ItemProvider.RegisteredTypeIdentifiers.ToList()); | ||
if (result is not null) | ||
{ | ||
filePaths.Add(result.FileUrl?.Path!); | ||
} | ||
} | ||
foreach (var item in filePaths) | ||
{ | ||
Debug.WriteLine($"Path: {item}"); | ||
} | ||
|
||
static async Task<LoadInPlaceResult?> LoadItemAsync(NSItemProvider itemProvider, List<string> typeIdentifiers) | ||
{ | ||
if (typeIdentifiers is null || typeIdentifiers.Count == 0) | ||
{ | ||
return null; | ||
} | ||
|
||
var typeIdent = typeIdentifiers.First(); | ||
|
||
if (itemProvider.HasItemConformingTo(typeIdent)) | ||
{ | ||
return await itemProvider.LoadInPlaceFileRepresentationAsync(typeIdent); | ||
} | ||
|
||
typeIdentifiers.Remove(typeIdent); | ||
|
||
return await LoadItemAsync(itemProvider, typeIdentifiers); | ||
} | ||
#else | ||
await Task.CompletedTask; | ||
#endif | ||
|
||
lblPath.Text = filePaths.FirstOrDefault(); | ||
} | ||
|
||
void DropGestureDragOver(object? sender, DragEventArgs e) | ||
{ | ||
Debug.WriteLine($"Dragging {e.Data?.Text}, {e.Data?.Image}"); | ||
} | ||
|
||
} | ||
} |
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,23 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues; | ||
|
||
public class Issue19926 : _IssuesUITest | ||
{ | ||
public override string Issue => "[Android] Opacity bug on BoxView.Background"; | ||
|
||
public Issue19926(TestDevice device) | ||
: base(device) | ||
{ } | ||
|
||
[Test] | ||
public void PropertiesShouldBeCorrectlyApplied() | ||
{ | ||
this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.iOS, TestDevice.Mac, TestDevice.Windows }); | ||
_ = App.WaitForElement("boxView"); | ||
|
||
VerifyScreenshot(); | ||
} | ||
} |
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,24 @@ | ||
using Maui.Controls.Sample; | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue21314 : _IssuesUITest { | ||
public override string Issue => "Image has wrong orientation on iOS"; | ||
|
||
public Issue21314(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
[Test] | ||
public void ImageShouldBePortrait() | ||
{ | ||
this.IgnoreIfPlatforms (new TestDevice[] { TestDevice.Android, TestDevice.Windows }); | ||
|
||
var image = App.WaitForElement ("theImage").GetRect(); | ||
Assert.Greater(image.Height, image.Width); | ||
} | ||
} | ||
} |
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,57 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue21711 : _IssuesUITest | ||
{ | ||
public Issue21711(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
public override string Issue => "NullReferenceException from FlexLayout.InitItemProperties"; | ||
|
||
[Test] | ||
public void AddDoesNotCrash() | ||
{ | ||
App.WaitForElement("Add"); | ||
|
||
App.Click("Add"); | ||
|
||
App.WaitForElement("Item2"); | ||
App.WaitForElement("Item3"); | ||
} | ||
|
||
[Test] | ||
public void InsertDoesNotCrash() | ||
{ | ||
App.WaitForElement("Insert"); | ||
|
||
App.Click("Insert"); | ||
|
||
App.WaitForElement("Item2"); | ||
App.WaitForElement("Item3"); | ||
} | ||
|
||
[Test] | ||
public void UpdateDoesNotCrash() | ||
{ | ||
App.WaitForElement("Update"); | ||
|
||
App.Click("Update"); | ||
|
||
App.WaitForElement("Item3"); | ||
} | ||
|
||
[Test] | ||
public void RemoveDoesNotCrash() | ||
{ | ||
App.WaitForElement("Remove"); | ||
|
||
App.Click("Remove"); | ||
|
||
App.WaitForElement("Item2"); | ||
} | ||
} | ||
} |
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,45 @@ | ||
using Microsoft.Maui.AppiumTests; | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
public partial class Issue5354 : _IssuesUITest | ||
{ | ||
public Issue5354(TestDevice device) : base(device) { } | ||
|
||
public override string Issue => "[CollectionView] Updating the ItemsLayout type should refresh the layout"; | ||
|
||
[Test] | ||
[Category(UITestCategories.CollectionView)] | ||
public void CollectionViewItemsLayoutUpdate() | ||
{ | ||
this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.iOS, TestDevice.Mac, TestDevice.Windows }, | ||
"This is a product bug."); | ||
|
||
App.WaitForElement("CollectionView5354"); | ||
App.WaitForElement("Button5354"); | ||
|
||
for(int i = 0; i < 3; i++) | ||
{ | ||
var linearRect0 = App.WaitForElement("Image0").GetRect(); | ||
var linearRect1 = App.WaitForElement("Image1").GetRect(); | ||
|
||
Assert.AreEqual(linearRect0.X, linearRect1.X); | ||
Assert.GreaterOrEqual(linearRect1.Y, linearRect0.Y + linearRect0.Height); | ||
|
||
App.Click("Button5354"); | ||
|
||
var gridRect0 = App.WaitForElement("Image0").GetRect(); | ||
var gridRect1 = App.WaitForElement("Image1").GetRect(); | ||
|
||
Assert.AreEqual(gridRect0.Y, gridRect1.Y); | ||
Assert.AreEqual(gridRect0.Height, gridRect1.Height); | ||
|
||
App.Click("Button5354"); | ||
} | ||
} | ||
} | ||
} |
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
Binary file added
BIN
+30.4 KB
...Controls/tests/UITests/snapshots/android/PropertiesShouldBeCorrectlyApplied.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+60.7 KB
...ots/ios-iphonex/EntryTextColorStopsWorkingAfterPropertyIsUpdatedFromBinding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.8 KB
...apshots/windows/EntryTextColorStopsWorkingAfterPropertyIsUpdatedFromBinding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.