committed by
GitHub
48 changed files with 1178 additions and 169 deletions
@ -0,0 +1,76 @@ |
|||||
|
# Contributor Covenant Code of Conduct |
||||
|
|
||||
|
## Our Pledge |
||||
|
|
||||
|
In the interest of fostering an open and welcoming environment, we as |
||||
|
contributors and maintainers pledge to making participation in our project and |
||||
|
our community a harassment-free experience for everyone, regardless of age, body |
||||
|
size, disability, ethnicity, sex characteristics, gender identity and expression, |
||||
|
level of experience, education, socio-economic status, nationality, personal |
||||
|
appearance, race, religion, or sexual identity and orientation. |
||||
|
|
||||
|
## Our Standards |
||||
|
|
||||
|
Examples of behavior that contributes to creating a positive environment |
||||
|
include: |
||||
|
|
||||
|
* Using welcoming and inclusive language |
||||
|
* Being respectful of differing viewpoints and experiences |
||||
|
* Gracefully accepting constructive criticism |
||||
|
* Focusing on what is best for the community |
||||
|
* Showing empathy towards other community members |
||||
|
|
||||
|
Examples of unacceptable behavior by participants include: |
||||
|
|
||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or |
||||
|
advances |
||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks |
||||
|
* Public or private harassment |
||||
|
* Publishing others' private information, such as a physical or electronic |
||||
|
address, without explicit permission |
||||
|
* Other conduct which could reasonably be considered inappropriate in a |
||||
|
professional setting |
||||
|
|
||||
|
## Our Responsibilities |
||||
|
|
||||
|
Project maintainers are responsible for clarifying the standards of acceptable |
||||
|
behavior and are expected to take appropriate and fair corrective action in |
||||
|
response to any instances of unacceptable behavior. |
||||
|
|
||||
|
Project maintainers have the right and responsibility to remove, edit, or |
||||
|
reject comments, commits, code, wiki edits, issues, and other contributions |
||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or |
||||
|
permanently any contributor for other behaviors that they deem inappropriate, |
||||
|
threatening, offensive, or harmful. |
||||
|
|
||||
|
## Scope |
||||
|
|
||||
|
This Code of Conduct applies both within project spaces and in public spaces |
||||
|
when an individual is representing the project or its community. Examples of |
||||
|
representing a project or community include using an official project e-mail |
||||
|
address, posting via an official social media account, or acting as an appointed |
||||
|
representative at an online or offline event. Representation of a project may be |
||||
|
further defined and clarified by project maintainers. |
||||
|
|
||||
|
## Enforcement |
||||
|
|
||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be |
||||
|
reported by contacting the project team at steven@avaloniaui.net. All |
||||
|
complaints will be reviewed and investigated and will result in a response that |
||||
|
is deemed necessary and appropriate to the circumstances. The project team is |
||||
|
obligated to maintain confidentiality with regard to the reporter of an incident. |
||||
|
Further details of specific enforcement policies may be posted separately. |
||||
|
|
||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good |
||||
|
faith may face temporary or permanent repercussions as determined by other |
||||
|
members of the project's leadership. |
||||
|
|
||||
|
## Attribution |
||||
|
|
||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, |
||||
|
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html |
||||
|
|
||||
|
[homepage]: https://www.contributor-covenant.org |
||||
|
|
||||
|
For answers to common questions about this code of conduct, see |
||||
|
https://www.contributor-covenant.org/faq |
||||
@ -1,12 +1,19 @@ |
|||||
// Copyright (c) The Avalonia Project. All rights reserved.
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using System.Collections; |
||||
|
using System.Collections.Specialized; |
||||
|
|
||||
namespace Avalonia.Controls.Presenters |
namespace Avalonia.Controls.Presenters |
||||
{ |
{ |
||||
public interface IItemsPresenter : IPresenter |
public interface IItemsPresenter : IPresenter |
||||
{ |
{ |
||||
|
IEnumerable Items { get; set; } |
||||
|
|
||||
IPanel Panel { get; } |
IPanel Panel { get; } |
||||
|
|
||||
|
void ItemsChanged(NotifyCollectionChangedEventArgs e); |
||||
|
|
||||
void ScrollIntoView(object item); |
void ScrollIntoView(object item); |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,109 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Reactive.Disposables; |
||||
|
using Avalonia.Platform; |
||||
|
using Avalonia.Threading; |
||||
|
using Avalonia.UnitTests; |
||||
|
using Avalonia.VisualTree; |
||||
|
using Moq; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Avalonia.Controls.UnitTests |
||||
|
{ |
||||
|
public class TolTipTests |
||||
|
{ |
||||
|
private MouseTestHelper _mouseHelper = new MouseTestHelper(); |
||||
|
|
||||
|
[Fact] |
||||
|
public void Should_Not_Open_On_Detached_Control() |
||||
|
{ |
||||
|
//issue #3188
|
||||
|
var control = new Decorator() |
||||
|
{ |
||||
|
[ToolTip.TipProperty] = "Tip", |
||||
|
[ToolTip.ShowDelayProperty] = 0 |
||||
|
}; |
||||
|
|
||||
|
Assert.False((control as IVisual).IsAttachedToVisualTree); |
||||
|
|
||||
|
//here in issue #3188 exception is raised
|
||||
|
_mouseHelper.Enter(control); |
||||
|
|
||||
|
Assert.False(ToolTip.GetIsOpen(control)); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Should_Open_On_Pointer_Enter() |
||||
|
{ |
||||
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
||||
|
{ |
||||
|
var window = new Window(); |
||||
|
|
||||
|
var target = new Decorator() |
||||
|
{ |
||||
|
[ToolTip.TipProperty] = "Tip", |
||||
|
[ToolTip.ShowDelayProperty] = 0 |
||||
|
}; |
||||
|
|
||||
|
window.Content = target; |
||||
|
|
||||
|
window.ApplyTemplate(); |
||||
|
window.Presenter.ApplyTemplate(); |
||||
|
|
||||
|
Assert.True((target as IVisual).IsAttachedToVisualTree); |
||||
|
|
||||
|
_mouseHelper.Enter(target); |
||||
|
|
||||
|
Assert.True(ToolTip.GetIsOpen(target)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Should_Open_On_Pointer_Enter_With_Delay() |
||||
|
{ |
||||
|
Action timercallback = null; |
||||
|
var delay = TimeSpan.Zero; |
||||
|
|
||||
|
var pti = Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true); |
||||
|
|
||||
|
Mock.Get(pti) |
||||
|
.Setup(v => v.StartTimer(It.IsAny<DispatcherPriority>(), It.IsAny<TimeSpan>(), It.IsAny<Action>())) |
||||
|
.Callback<DispatcherPriority, TimeSpan, Action>((priority, interval, tick) => |
||||
|
{ |
||||
|
delay = interval; |
||||
|
timercallback = tick; |
||||
|
}) |
||||
|
.Returns(Disposable.Empty); |
||||
|
|
||||
|
using (UnitTestApplication.Start(TestServices.StyledWindow.With(threadingInterface: pti))) |
||||
|
{ |
||||
|
var window = new Window(); |
||||
|
|
||||
|
var target = new Decorator() |
||||
|
{ |
||||
|
[ToolTip.TipProperty] = "Tip", |
||||
|
[ToolTip.ShowDelayProperty] = 1 |
||||
|
}; |
||||
|
|
||||
|
window.Content = target; |
||||
|
|
||||
|
window.ApplyTemplate(); |
||||
|
window.Presenter.ApplyTemplate(); |
||||
|
|
||||
|
Assert.True((target as IVisual).IsAttachedToVisualTree); |
||||
|
|
||||
|
_mouseHelper.Enter(target); |
||||
|
|
||||
|
Assert.Equal(TimeSpan.FromMilliseconds(1), delay); |
||||
|
Assert.NotNull(timercallback); |
||||
|
Assert.False(ToolTip.GetIsOpen(target)); |
||||
|
|
||||
|
timercallback(); |
||||
|
|
||||
|
Assert.True(ToolTip.GetIsOpen(target)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.UnitTests; |
||||
|
using Avalonia.VisualTree; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Avalonia.Input.UnitTests |
||||
|
{ |
||||
|
public class PointerTests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void On_Capture_Transfer_PointerCaptureLost_Should_Propagate_Up_To_The_Common_Parent() |
||||
|
{ |
||||
|
Border initialParent, initialCapture, newParent, newCapture; |
||||
|
var el = new StackPanel |
||||
|
{ |
||||
|
Children = |
||||
|
{ |
||||
|
(initialParent = new Border { Child = initialCapture = new Border() }), |
||||
|
(newParent = new Border { Child = newCapture = new Border() }) |
||||
|
} |
||||
|
}; |
||||
|
var receivers = new List<object>(); |
||||
|
var root = new TestRoot(el); |
||||
|
foreach (InputElement d in root.GetSelfAndVisualDescendants()) |
||||
|
d.PointerCaptureLost += (s, e) => receivers.Add(s); |
||||
|
var pointer = new Pointer(Pointer.GetNextFreeId(), PointerType.Mouse, true); |
||||
|
|
||||
|
pointer.Capture(initialCapture); |
||||
|
pointer.Capture(newCapture); |
||||
|
Assert.True(receivers.SequenceEqual(new[] { initialCapture, initialParent })); |
||||
|
|
||||
|
receivers.Clear(); |
||||
|
pointer.Capture(null); |
||||
|
Assert.True(receivers.SequenceEqual(new object[] { newCapture, newParent, el, root })); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue