Esempio n. 1
0
		public void ItemParentTest5 ()
		{
			bool loaded = false;
			bool opened = false;
			Rectangle content = new Rectangle {
				Fill = new SolidColorBrush (Colors.Brown),
				Width = 100,
				Height = 50
			};
			ComboBoxPoker box = new ComboBoxPoker { Width = 50, Height = 50 };
			ComboBoxItem item = new ComboBoxItem { Content = content };
			StringBuilder sb = new StringBuilder ();
			box.DropDownOpened += delegate { opened = true; };
			box.DropDownClosed += delegate { opened = false; };
			box.Items.Add (item);
			box.SelectedIndex = 0;
			box.Loaded += delegate { loaded = true; };
			TestPanel.Children.Add (box);


			EnqueueConditional (() => loaded);
			Enqueue (() => box.ApplyTemplate ());
			Enqueue (() => box.IsDropDownOpen = true);
			EnqueueConditional (() => opened);
			Enqueue (() => Assert.IsNotNull (VisualTreeHelper.GetParent (item), "#0"));
			Enqueue (() => Assert.IsInstanceOfType<StackPanel> (VisualTreeHelper.GetParent (item), "#1"));
			Enqueue (() => Assert.AreSame (box, item.Parent, "#2"));
			Enqueue (() => Assert.AreEqual (content, item.Content, "#2b"));
			Enqueue (() => Assert.AreEqual (item, content.Parent, "2c"));
			Enqueue (() => Assert.IsInstanceOfType<ContentPresenter> (VisualTreeHelper.GetParent ((Rectangle) item.Content), "#3"));
			Enqueue (() => Assert.AreSame (item, ((Rectangle) item.Content).Parent, "#4"));

			Enqueue (() => box.IsDropDownOpen = false);
			EnqueueConditional (() => !opened, "#5");

			Enqueue (() => Assert.IsNotNull (VisualTreeHelper.GetParent (item), "#6"));
			Enqueue (() => Assert.IsInstanceOfType<StackPanel> (VisualTreeHelper.GetParent (item), "#6b"));
			Enqueue (() => Assert.AreSame (box, item.Parent, "#7"));
			Enqueue (() => Assert.IsNull (item.Content, "#8"));
			EnqueueTestComplete ();
		}
Esempio n. 2
0
		public void ContainerItemTest5 ()
		{
			ComboBoxPoker box = new ComboBoxPoker ();
			box.ApplyTemplate ();
			box.ContainerItem = new ComboBoxItem ();
			CreateAsyncTest (box,
				() => box.IsDropDownOpen = true,
				() => {
					box.Items.Add (new object ());
				},
				() => {
					box.Items.Add (new object ());
				}
			);
		}
Esempio n. 3
0
		public void ContainerItemTest4 ()
		{
			ComboBoxPoker box = new ComboBoxPoker ();
			box.ApplyTemplate ();
			box.ContainerItem = new Rectangle ();
			CreateAsyncTest (box,
				() => box.IsDropDownOpen = true,
				() => Assert.Throws<InvalidCastException> (() => box.Items.Add (new object ()))
			);
		}
Esempio n. 4
0
		public void SelectThenClear2 ()
		{
			ComboBoxPoker box = new ComboBoxPoker ();
			CreateAsyncTest (box,
				() => box.ApplyTemplate (),
				() => {
					box.Items.Add (new object ());
					box.Items.Add (new object ());
					box.Items.Add (new object ());
				},
				// Check to see if the items are cleared in the reverse order they were added in
				() => { box.IsDropDownOpen = true; },
				() => { box.SelectedItem = box.Items.Last (); },
				() => {
					box.methods.Clear ();
					box.Items.Clear ();
					Assert.AreEqual (5, box.methods.Count, "#0");
					Assert.AreEqual ("ClearContainerForItemOverride", box.methods [0].MethodName, "#1");
					Assert.AreEqual ("ClearContainerForItemOverride", box.methods [1].MethodName, "#2");
					Assert.AreEqual ("ClearContainerForItemOverride", box.methods [2].MethodName, "#3");
					Assert.AreEqual ("OnItemsChanged", box.methods [3].MethodName, "#4");
					Assert.AreEqual ("SelectionChangedEvent", box.methods [4].MethodName, "#5"); // Fails in Silverlight 3
				}
			);
		}
Esempio n. 5
0
		public void SelectThenClear ()
		{
			ComboBoxPoker box = new ComboBoxPoker ();
			CreateAsyncTest (box,
				() => box.ApplyTemplate (),
				() => {
					box.Items.Add (new object ());
					box.Items.Add (new object ());
					box.Items.Add (new object ());

				},
				() => { box.IsDropDownOpen = true; },
				() => { box.SelectedItem = box.Items [0]; },
				() => {
					box.methods.Clear ();
					box.Items.Clear ();
					Assert.AreEqual (5, box.methods.Count, "#0");
					Assert.AreEqual ("ClearContainerForItemOverride", box.methods [0].MethodName, "#1");
					Assert.AreEqual ("ClearContainerForItemOverride", box.methods [1].MethodName, "#2");
					Assert.AreEqual ("ClearContainerForItemOverride", box.methods [2].MethodName, "#3");
					Assert.AreEqual ("OnItemsChanged", box.methods [3].MethodName, "#5");
					Assert.AreEqual ("SelectionChangedEvent", box.methods [4].MethodName, "#6");
					Assert.IsNull (box.SelectedItem, "#7");
				}
			);
		}
Esempio n. 6
0
		public void OnDropDownMethodsTest ()
		{
			bool opened = false;
			ComboBoxPoker box = new ComboBoxPoker { CallBaseOnDropDown = false };
			TestPanel.Children.Add (box);

			box.DropDownOpened += delegate { opened = true; };
			box.ApplyTemplate ();
			Enqueue (() => {
				box.IsDropDownOpen = true;
			});
			Enqueue (() => {
				try {
					Assert.IsFalse (opened, "#1");
					Assert.IsTrue (box.TemplatePopup.IsOpen, "#2");
				} finally {
					box.IsDropDownOpen = false;
				}
			});
			EnqueueTestComplete ();
		}