This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Showing
78 changed files
with
5,056 additions
and
780 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
112 changes: 112 additions & 0 deletions
112
Xamarin.Forms.Controls/CoreGalleryPages/ImageButtonCoreGalleryPage.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,112 @@ | ||
using System; | ||
|
||
using Xamarin.Forms.CustomAttributes; | ||
|
||
namespace Xamarin.Forms.Controls | ||
{ | ||
internal class ImageButtonCoreGalleryPage : CoreGalleryPage<ImageButton> | ||
{ | ||
protected override bool SupportsFocus => false; | ||
|
||
protected override bool SupportsTapGestureRecognizer => false; | ||
|
||
protected override void InitializeElement(ImageButton element) | ||
{ | ||
element.Source = "oasissmall.jpg"; | ||
} | ||
|
||
protected override void Build(StackLayout stackLayout) | ||
{ | ||
base.Build(stackLayout); | ||
|
||
|
||
IsEnabledStateViewContainer.View.Clicked += (sender, args) => | ||
{ | ||
IsEnabledStateViewContainer.TitleLabel.Text += " (Tapped)"; | ||
}; | ||
|
||
var aspectFillContainer = new ViewContainer<ImageButton>(Test.ImageButton.AspectFill, new ImageButton { Aspect = Aspect.AspectFill }); | ||
var aspectFitContainer = new ViewContainer<ImageButton>(Test.ImageButton.AspectFit, new ImageButton { Aspect = Aspect.AspectFit }); | ||
var fillContainer = new ViewContainer<ImageButton>(Test.ImageButton.Fill, new ImageButton { Aspect = Aspect.Fill }); | ||
var isLoadingContainer = new StateViewContainer<ImageButton>(Test.ImageButton.IsLoading, new ImageButton()); | ||
var isOpaqueContainer = new StateViewContainer<ImageButton>(Test.ImageButton.IsOpaque, new ImageButton()); | ||
|
||
|
||
var borderButtonContainer = new ViewContainer<ImageButton>(Test.ImageButton.BorderColor, | ||
new ImageButton | ||
{ | ||
BackgroundColor = Color.Transparent, | ||
BorderColor = Color.Red, | ||
BorderWidth = 1, | ||
Source = "oasissmall.jpg" | ||
} | ||
); | ||
|
||
var borderRadiusContainer = new ViewContainer<ImageButton>(Test.ImageButton.BorderRadius, | ||
new ImageButton | ||
{ | ||
Source = "oasissmall.jpg", | ||
BackgroundColor = Color.Transparent, | ||
BorderColor = Color.Red, | ||
CornerRadius = 20, | ||
BorderWidth = 1, | ||
} | ||
); | ||
|
||
var borderWidthContainer = new ViewContainer<ImageButton>(Test.ImageButton.BorderWidth, | ||
new ImageButton | ||
{ | ||
Source = "oasissmall.jpg", | ||
BackgroundColor = Color.Transparent, | ||
BorderColor = Color.Red, | ||
BorderWidth = 15, | ||
} | ||
); | ||
|
||
var clickedContainer = new EventViewContainer<ImageButton>(Test.ImageButton.Clicked, | ||
new ImageButton | ||
{ | ||
Source = "oasissmall.jpg" | ||
} | ||
); | ||
clickedContainer.View.Clicked += (sender, args) => clickedContainer.EventFired(); | ||
|
||
var commandContainer = new ViewContainer<ImageButton>(Test.ImageButton.Command, | ||
new ImageButton | ||
{ | ||
Command = new Command(() => DisplayActionSheet("Hello Command", "Cancel", "Destroy")), | ||
Source = "oasissmall.jpg" | ||
} | ||
); | ||
|
||
var imageContainer = new ViewContainer<ImageButton>(Test.Button.Image, | ||
new ImageButton | ||
{ | ||
Source = new FileImageSource { File = "bank.png" } | ||
} | ||
); | ||
|
||
|
||
InitializeElement(aspectFillContainer.View); | ||
InitializeElement(aspectFitContainer.View); | ||
InitializeElement(fillContainer.View); | ||
InitializeElement(isLoadingContainer.View); | ||
InitializeElement(isOpaqueContainer.View); | ||
|
||
var sourceContainer = new ViewContainer<ImageButton>(Test.ImageButton.Source, new ImageButton { Source = "https://raw.githubusercontent.com/xamarin/Xamarin.Forms/master/Xamarin.Forms.Controls/coffee.png" }); | ||
|
||
Add(aspectFillContainer); | ||
Add(aspectFitContainer); | ||
Add(fillContainer); | ||
Add(isLoadingContainer); | ||
Add(isOpaqueContainer); | ||
Add(sourceContainer); | ||
Add(borderButtonContainer); | ||
Add(borderRadiusContainer); | ||
Add(borderWidthContainer); | ||
Add(clickedContainer); | ||
Add(commandContainer); | ||
Add(imageContainer); | ||
} | ||
} | ||
} |
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
144 changes: 144 additions & 0 deletions
144
Xamarin.Forms.Core.UITests.Shared/Tests/ImageButtonUITests.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,144 @@ | ||
using System.Threading; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.CustomAttributes; | ||
|
||
namespace Xamarin.Forms.Core.UITests | ||
{ | ||
[TestFixture] | ||
[Category(UITestCategories.Image)] | ||
internal class ImageButtonUITests : _ViewUITests | ||
{ | ||
public ImageButtonUITests() | ||
{ | ||
PlatformViewType = Views.ImageButton; | ||
} | ||
|
||
protected override void NavigateToGallery() | ||
{ | ||
App.NavigateToGallery(GalleryQueries.ImageButtonGallery); | ||
|
||
// let remote images load | ||
Thread.Sleep(2000); | ||
} | ||
|
||
[UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")] | ||
public override void _Focus() | ||
{ | ||
} | ||
|
||
// TODO | ||
public override void _GestureRecognizers() | ||
{ | ||
} | ||
|
||
[UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")] | ||
public override void _IsEnabled() | ||
{ | ||
} | ||
|
||
[UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")] | ||
public override void _IsFocused() | ||
{ | ||
} | ||
|
||
[UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")] | ||
public override void _UnFocus() | ||
{ | ||
} | ||
|
||
// TODO | ||
// Implement control specific ui tests | ||
|
||
// TODO | ||
// Tests for remote images | ||
|
||
protected override void FixtureTeardown() | ||
{ | ||
App.NavigateBack(); | ||
base.FixtureTeardown(); | ||
} | ||
|
||
|
||
|
||
|
||
// ImageButton Tests | ||
[Test] | ||
[UiTest(typeof(ImageButton), "BorderColor")] | ||
[UiTestBroken(BrokenReason.CalabashAndroidUnsupported, "Figure out how to get Android Drawables")] | ||
[UiTestBroken(BrokenReason.CalabashiOSUnsupported, "iOS nil result")] | ||
public void BorderColor() | ||
{ | ||
//TODO iOS | ||
var remote = new ViewContainerRemote(App, Test.ImageButton.BorderColor, PlatformViewType); | ||
remote.GoTo(); | ||
} | ||
|
||
[Test] | ||
[UiTest(typeof(ImageButton), "BorderRadius")] | ||
[UiTestBroken(BrokenReason.CalabashAndroidUnsupported, "Figure out how to get Android Drawables")] | ||
public void BorderRadius() | ||
{ | ||
var remote = new ViewContainerRemote(App, Test.ImageButton.BorderRadius, PlatformViewType); | ||
remote.GoTo(); | ||
|
||
#if __IOS__ | ||
var borderRadius = remote.GetProperty<float>(ImageButton.CornerRadiusProperty); | ||
Assert.AreEqual(20.0f, borderRadius); | ||
#endif | ||
} | ||
|
||
[Test] | ||
[UiTest(typeof(ImageButton), "BorderWidth")] | ||
[UiTestBroken(BrokenReason.CalabashAndroidUnsupported, "Figure out how to get Android Drawables")] | ||
public void BorderWidth() | ||
{ | ||
var remote = new ViewContainerRemote(App, Test.ImageButton.BorderWidth, PlatformViewType); | ||
remote.GoTo(); | ||
|
||
#if __IOS__ | ||
var borderWidth = remote.GetProperty<float>(ImageButton.BorderWidthProperty); | ||
Assert.AreEqual(15.0f, borderWidth); | ||
#endif | ||
} | ||
|
||
[Test] | ||
[UiTest(typeof(ImageButton), "Clicked")] | ||
public void Clicked() | ||
{ | ||
var remote = new EventViewContainerRemote(App, Test.ImageButton.Clicked, PlatformViewType); | ||
remote.GoTo(); | ||
|
||
var textBeforeClick = remote.GetEventLabel().Text; | ||
Assert.AreEqual("Event: Clicked (none)", textBeforeClick); | ||
|
||
// Click ImageButton | ||
remote.TapView(); | ||
|
||
var textAfterClick = remote.GetEventLabel().Text; | ||
Assert.AreEqual("Event: Clicked (fired 1)", textAfterClick); | ||
} | ||
|
||
[Test] | ||
[UiTest(typeof(ImageButton), "Command")] | ||
public void Command() | ||
{ | ||
var remote = new ViewContainerRemote(App, Test.ImageButton.Command, PlatformViewType); | ||
remote.GoTo(); | ||
|
||
remote.TapView(); | ||
|
||
App.WaitForElement(q => q.Marked("Hello Command")); | ||
App.Tap(q => q.Marked("Destroy")); | ||
} | ||
|
||
[Test] | ||
[UiTest(typeof(ImageButton), "Image")] | ||
[UiTestExempt(ExemptReason.TimeConsuming, "Need way to check Android resources")] | ||
public void Image() | ||
{ | ||
//TODO iOS | ||
var remote = new ViewContainerRemote(App, Test.ImageButton.Image, PlatformViewType); | ||
remote.GoTo(); | ||
} | ||
} | ||
} |
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.