diff --git a/Gu.Wpf.Adorners.Demo/Windows/WatermarkWindow.xaml b/Gu.Wpf.Adorners.Demo/Windows/WatermarkWindow.xaml
index 47e6a6f..4e6bd4c 100644
--- a/Gu.Wpf.Adorners.Demo/Windows/WatermarkWindow.xaml
+++ b/Gu.Wpf.Adorners.Demo/Windows/WatermarkWindow.xaml
@@ -35,7 +35,9 @@
-
+
@@ -79,7 +81,9 @@
-
+
@@ -124,8 +128,9 @@
+ adorners:Watermark.Text="Write something here"
+ BorderBrush="#FF707070"
+ Visibility="{Binding ElementName=VisibilityCbx, Path=SelectedItem}">
abc
cde
fgh
@@ -214,6 +219,11 @@
+
+ Visible
+ Hidden
+ Collapsed
+
diff --git a/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.ComboBox.cs b/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.ComboBox.cs
index 380791f..945c2c8 100644
--- a/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.ComboBox.cs
+++ b/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.ComboBox.cs
@@ -20,8 +20,8 @@ public void WithDefaultWatermarkWhenNotFocused()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithDefaultWatermark");
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithDefaultWatermark_not_focused.png", passwordBox);
+ var comboBox = window.FindComboBox("ComboBoxWithDefaultWatermark");
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithDefaultWatermark_not_focused.png", comboBox);
}
}
@@ -31,9 +31,9 @@ public void WithDefaultWatermarkWhenFocused()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithDefaultWatermark");
- passwordBox.Focus();
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithDefaultWatermark_focused.png", passwordBox);
+ var comboBox = window.FindComboBox("ComboBoxWithDefaultWatermark");
+ comboBox.Focus();
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithDefaultWatermark_focused.png", comboBox);
}
}
@@ -43,10 +43,10 @@ public void WithDefaultWatermarkWhenNotEmpty()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithDefaultWatermark");
- passwordBox.Select("abc");
+ var comboBox = window.FindComboBox("ComboBoxWithDefaultWatermark");
+ comboBox.Select("abc");
window.FindButton("Lose focus").Click();
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithDefaultWatermark_not_empty.png", passwordBox);
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithDefaultWatermark_not_empty.png", comboBox);
}
}
@@ -56,12 +56,12 @@ public void WithWatermarkWithBoundText()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithWatermarkWithBoundText");
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkWithBoundText_AAA.png", passwordBox);
+ var comboBox = window.FindComboBox("ComboBoxWithWatermarkWithBoundText");
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkWithBoundText_AAA.png", comboBox);
window.FindTextBox("AdornerText").Text = "abc";
window.FindButton("Lose focus").Invoke();
Wait.For(TimeSpan.FromMilliseconds(50));
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkWithBoundText_abc.png", passwordBox);
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkWithBoundText_abc.png", comboBox);
}
}
@@ -71,8 +71,8 @@ public void WithWatermarkWithInheritedFontSize()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithWatermarkWithInheritedFontSize");
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkWithInheritedFontSize.png", passwordBox);
+ var comboBox = window.FindComboBox("ComboBoxWithWatermarkWithInheritedFontSize");
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkWithInheritedFontSize.png", comboBox);
}
}
@@ -82,8 +82,8 @@ public void WithWatermarkWithExplicitTextStyle()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithWatermarkWithExplicitTextStyle");
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkWithExplicitTextStyle.png", passwordBox);
+ var comboBox = window.FindComboBox("ComboBoxWithWatermarkWithExplicitTextStyle");
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkWithExplicitTextStyle.png", comboBox);
}
}
@@ -104,8 +104,8 @@ public void WithWatermarkVisibleWhenEmpty()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmpty");
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmpty_not_focused.png", passwordBox);
+ var comboBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmpty");
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmpty_not_focused.png", comboBox);
}
}
@@ -115,9 +115,9 @@ public void WithWatermarkVisibleWhenEmptyWhenFocused()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmpty");
- passwordBox.Focus();
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmpty_focused.png", passwordBox);
+ var comboBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmpty");
+ comboBox.Focus();
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmpty_focused.png", comboBox);
}
}
@@ -127,10 +127,10 @@ public void WithWatermarkVisibleWhenEmptyWhenNotEmpty()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmpty");
- passwordBox.Select("abc");
+ var comboBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmpty");
+ comboBox.Select("abc");
window.FindButton("Lose focus").Click();
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmpty_not_empty.png", passwordBox);
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmpty_not_empty.png", comboBox);
}
}
@@ -140,8 +140,8 @@ public void WithWatermarkVisibleWhenEmptyAndNotFocused()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused");
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused_not_focused.png", passwordBox);
+ var comboBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused");
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused_not_focused.png", comboBox);
}
}
@@ -151,9 +151,9 @@ public void WithWatermarkVisibleWhenEmptyAndNotFocusedWhenFocused()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused");
- passwordBox.Focus();
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused_focused.png", passwordBox);
+ var comboBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused");
+ comboBox.Focus();
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused_focused.png", comboBox);
}
}
@@ -163,10 +163,32 @@ public void WithWatermarkVisibleWhenEmptyAndNotFocusedWhenNotEmpty()
using (var app = Application.Launch(ExeFileName, WindowName))
{
var window = app.MainWindow;
- var passwordBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused");
- passwordBox.Select("abc");
+ var comboBox = window.FindComboBox("ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused");
+ comboBox.Select("abc");
window.FindButton("Lose focus").Click();
- ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused_not_empty.png", passwordBox);
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithWatermarkVisibleWhenEmptyAndNotFocused_not_empty.png", comboBox);
+ }
+ }
+
+ [TestCase("Collapsed")]
+ [TestCase("Hidden")]
+ public void WhenAdornedElementIs(string visibility)
+ {
+ using (var app = Application.Launch(ExeFileName, WindowName))
+ {
+ var window = app.MainWindow;
+ Wait.For(TimeSpan.FromMilliseconds(200));
+ var button = window.FindComboBox("ComboBoxWithDefaultWatermark");
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithDefaultWatermark_not_focused.png", button);
+
+ var comboBox = window.FindComboBox("VisibilityCbx");
+ comboBox.Select(visibility);
+ Wait.For(TimeSpan.FromMilliseconds(200));
+
+ // Checking that we don't crash here. See issue #24
+ comboBox.Select("Visible");
+ Wait.For(TimeSpan.FromMilliseconds(200));
+ ImageAssert.AreEqual(".\\Images\\ComboBoxWithDefaultWatermark_not_focused.png", button);
}
}
}
diff --git a/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.PasswordBox.cs b/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.PasswordBox.cs
index 9c55113..4c4200c 100644
--- a/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.PasswordBox.cs
+++ b/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.PasswordBox.cs
@@ -169,6 +169,28 @@ public void WithWatermarkVisibleWhenEmptyAndNotFocusedWhenNotEmpty()
ImageAssert.AreEqual(".\\Images\\PasswordBoxWithWatermarkVisibleWhenEmptyAndNotFocused_not_empty.png", passwordBox);
}
}
+
+ [TestCase("Collapsed")]
+ [TestCase("Hidden")]
+ public void WhenAdornedElementIs(string visibility)
+ {
+ using (var app = Application.Launch(ExeFileName, WindowName))
+ {
+ var window = app.MainWindow;
+ Wait.For(TimeSpan.FromMilliseconds(200));
+ var button = window.FindPasswordBox("PasswordBoxWithDefaultWatermark");
+ ImageAssert.AreEqual(".\\Images\\PasswordBoxWithDefaultWatermark_not_focused.png", button);
+
+ var comboBox = window.FindComboBox("VisibilityCbx");
+ comboBox.Select(visibility);
+ Wait.For(TimeSpan.FromMilliseconds(200));
+
+ // Checking that we don't crash here. See issue #24
+ comboBox.Select("Visible");
+ Wait.For(TimeSpan.FromMilliseconds(200));
+ ImageAssert.AreEqual(".\\Images\\PasswordBoxWithDefaultWatermark_not_focused.png", button);
+ }
+ }
}
}
}
diff --git a/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.TextBox.cs b/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.TextBox.cs
index 48770e7..22cbd66 100644
--- a/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.TextBox.cs
+++ b/Gu.Wpf.Adorners.UiTests/WatermarkWindowTests.TextBox.cs
@@ -169,6 +169,28 @@ public void WithWatermarkVisibleWhenEmptyAndNotFocusedWhenNotEmpty()
ImageAssert.AreEqual(".\\Images\\TextBoxWithWatermarkVisibleWhenEmptyAndNotFocused_not_empty.png", textBox);
}
}
+
+ [TestCase("Collapsed")]
+ [TestCase("Hidden")]
+ public void WhenAdornedElementIs(string visibility)
+ {
+ using (var app = Application.Launch(ExeFileName, WindowName))
+ {
+ var window = app.MainWindow;
+ Wait.For(TimeSpan.FromMilliseconds(200));
+ var button = window.FindTextBox("TextBoxWithDefaultWatermark");
+ ImageAssert.AreEqual(".\\Images\\TextBoxWithDefaultWatermark_not_focused.png", button);
+
+ var comboBox = window.FindComboBox("VisibilityCbx");
+ comboBox.Select(visibility);
+ Wait.For(TimeSpan.FromMilliseconds(200));
+
+ // Checking that we don't crash here. See issue #24
+ comboBox.Select("Visible");
+ Wait.For(TimeSpan.FromMilliseconds(200));
+ ImageAssert.AreEqual(".\\Images\\TextBoxWithDefaultWatermark_not_focused.png", button);
+ }
+ }
}
}
}