Merge branch 'loaded-branch'
[moon.git] / test / 2.0 / moon-unit / System.Windows.Automation.Peers / ScrollViewerAutomationPeerTest.cs
blob14202f654744ae110a7cbb03a41f52994908d898
1 //
2 // Unit tests for ScrollViewerAutomationPeer
3 //
4 // Contact:
5 // Moonlight List (moonlight-list@lists.ximian.com)
6 //
7 // Copyright (C) 2009 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System;
30 using System.Text;
31 using System.Collections.Generic;
32 using System.Windows;
33 using System.Windows.Automation;
34 using System.Windows.Automation.Provider;
35 using System.Windows.Automation.Peers;
36 using System.Windows.Controls;
37 using System.Windows.Controls.Primitives;
39 using Mono.Moonlight.UnitTesting;
40 using Microsoft.VisualStudio.TestTools.UnitTesting;
41 using Microsoft.Silverlight.Testing;
43 namespace MoonTest.System.Windows.Automation.Peers {
45 [TestClass]
46 public class ScrollViewerAutomationPeerTest : FrameworkElementAutomationPeerTest {
48 public class ScrollViewerAutomationPeerConcrete : ScrollViewerAutomationPeer, FrameworkElementAutomationPeerContract {
50 public ScrollViewerAutomationPeerConcrete (ScrollViewer owner)
51 : base (owner)
55 #region Overridden methods
57 public bool IsControlElementCore_ ()
59 return base.IsControlElementCore ();
62 public string GetClassNameCore_ ()
64 return base.GetClassNameCore ();
67 public AutomationControlType GetAutomationControlTypeCore_ ()
69 return base.GetAutomationControlTypeCore ();
72 #endregion
74 #region Wrapper Methods
76 public string GetNameCore_ ()
78 return base.GetNameCore ();
81 public AutomationPeer GetLabeledByCore_ ()
83 return base.GetLabeledByCore ();
86 public bool IsContentElementCore_ ()
88 return base.IsContentElementCore ();
91 public string GetAcceleratorKeyCore_ ()
93 return base.GetAcceleratorKeyCore ();
96 public string GetAccessKeyCore_ ()
98 return base.GetAccessKeyCore ();
101 public string GetAutomationIdCore_ ()
103 return base.GetAutomationIdCore ();
106 public global::System.Windows.Rect GetBoundingRectangleCore_ ()
108 return base.GetBoundingRectangleCore ();
111 public global::System.Collections.Generic.List<AutomationPeer> GetChildrenCore_ ()
113 return base.GetChildrenCore ();
116 public global::System.Windows.Point GetClickablePointCore_ ()
118 return base.GetClickablePointCore ();
121 public string GetHelpTextCore_ ()
123 return base.GetHelpTextCore ();
126 public string GetItemStatusCore_ ()
128 return base.GetItemStatusCore ();
131 public string GetItemTypeCore_ ()
133 return base.GetItemTypeCore ();
136 public string GetLocalizedControlTypeCore_ ()
138 return base.GetLocalizedControlTypeCore ();
141 public AutomationOrientation GetOrientationCore_ ()
143 return base.GetOrientationCore ();
146 public bool HasKeyboardFocusCore_ ()
148 return base.HasKeyboardFocusCore ();
151 public bool IsEnabledCore_ ()
153 return base.IsEnabledCore ();
156 public bool IsKeyboardFocusableCore_ ()
158 return base.IsKeyboardFocusableCore ();
161 public bool IsOffscreenCore_ ()
163 return base.IsOffscreenCore ();
166 public bool IsPasswordCore_ ()
168 return base.IsPasswordCore ();
171 public bool IsRequiredForFormCore_ ()
173 return base.IsRequiredForFormCore ();
176 #endregion
179 [TestMethod]
180 public override void GetAutomationControlType ()
182 ScrollViewerAutomationPeerConcrete svapp = new ScrollViewerAutomationPeerConcrete (new ScrollViewer ());
183 Assert.AreEqual (AutomationControlType.Pane, svapp.GetAutomationControlType (), "GetAutomationControlType");
184 Assert.AreEqual (AutomationControlType.Pane, svapp.GetAutomationControlTypeCore_ (), "GetAutomationControlTypeCore");
187 [TestMethod]
188 public override void IsControlElement ()
190 ScrollViewerAutomationPeerConcrete svapp = new ScrollViewerAutomationPeerConcrete (new ScrollViewer ());
191 Assert.IsTrue (svapp.IsControlElement (), "IsControlElement");
192 Assert.IsTrue (svapp.IsControlElementCore_ (), "IsControlElementCore");
195 [TestMethod]
196 public override void GetClassName ()
198 ScrollViewerAutomationPeerConcrete svapp = new ScrollViewerAutomationPeerConcrete (new ScrollViewer ());
199 Assert.AreEqual ("ScrollViewer", svapp.GetClassName (), "GetClassNameCore");
200 Assert.AreEqual ("ScrollViewer", svapp.GetClassNameCore_ (), "GetClassNameCoreCore");
203 [TestMethod]
204 public override void GetPattern ()
206 ScrollViewerAutomationPeerConcrete svapp = new ScrollViewerAutomationPeerConcrete (new ScrollViewer ());
208 Assert.IsNull (svapp.GetPattern (PatternInterface.Dock), "Dock");
209 Assert.IsNull (svapp.GetPattern (PatternInterface.ExpandCollapse), "ExpandCollapse");
210 Assert.IsNull (svapp.GetPattern (PatternInterface.Grid), "Grid");
211 Assert.IsNull (svapp.GetPattern (PatternInterface.GridItem), "GridItem");
212 Assert.IsNull (svapp.GetPattern (PatternInterface.Invoke), "Invoke");
213 Assert.IsNull (svapp.GetPattern (PatternInterface.MultipleView), "MultipleView");
214 Assert.IsNull (svapp.GetPattern (PatternInterface.RangeValue), "RangeValue");
215 Assert.IsNull (svapp.GetPattern (PatternInterface.ScrollItem), "ScrollItem");
216 Assert.IsNull (svapp.GetPattern (PatternInterface.Selection), "Selection");
217 Assert.IsNull (svapp.GetPattern (PatternInterface.SelectionItem), "SelectionItem");
218 Assert.IsNull (svapp.GetPattern (PatternInterface.Table), "Table");
219 Assert.IsNull (svapp.GetPattern (PatternInterface.TableItem), "TableItem");
220 Assert.IsNull (svapp.GetPattern (PatternInterface.Toggle), "Toggle");
221 Assert.IsNull (svapp.GetPattern (PatternInterface.Transform), "Transform");
222 Assert.IsNull (svapp.GetPattern (PatternInterface.Value), "Value");
223 Assert.IsNull (svapp.GetPattern (PatternInterface.Window), "Window");
225 Assert.IsNotNull (svapp.GetPattern (PatternInterface.Scroll), "Scroll");
228 [TestMethod]
229 public override void HasKeyboardFocus ()
231 // The control by itself is not focusable, the content is
234 [TestMethod]
235 [Asynchronous]
236 public override void ContentTest ()
238 Assert.IsTrue (IsContentPropertyElement (), "ScrollViewer ContentElement.");
240 bool scrollViewerLoaded = false;
241 bool stackPanelLayoutChanged = false;
242 ScrollViewer scrollViewer = CreateConcreteFrameworkElement () as ScrollViewer;
243 scrollViewer.Loaded += (o, e) => scrollViewerLoaded = true;
244 scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
245 scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
246 TestPanel.Children.Add (scrollViewer);
248 // StackPanel and two TextBlocks
249 bool stackPanelLoaded = false;
250 StackPanel stackPanel = new StackPanel ();
251 stackPanel.LayoutUpdated += (o, e) => stackPanelLayoutChanged = true;
252 stackPanel.Children.Add (new TextBlock () { Text = "Text0" });
253 stackPanel.Children.Add (new TextBlock () { Text = "Text1" });
254 stackPanel.Loaded += (o, e) => stackPanelLoaded = true;
256 EnqueueConditional (() => scrollViewerLoaded, "ScrollViewerLoaded #0");
257 Enqueue (() => {
258 AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (scrollViewer);
259 Assert.IsNotNull (peer, "FrameworkElementAutomationPeer.CreatePeerForElement");
261 Assert.IsNull (peer.GetChildren (), "GetChildren #0");
262 scrollViewer.Content = stackPanel;
264 EnqueueConditional (() => scrollViewerLoaded && stackPanelLoaded, "ScrollViewerLoaded #1");
265 Enqueue (() => {
266 AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (scrollViewer);
267 Assert.IsNotNull (peer.GetChildren (), "GetChildren #1");
268 Assert.AreEqual (2, peer.GetChildren ().Count, "GetChildren.Count #1");
269 // We add one TextBlock
270 stackPanel.Children.Add (new TextBlock () { Text = "Text2" });
271 Assert.IsNotNull (peer.GetChildren (), "GetChildren #2");
272 Assert.AreEqual (3, peer.GetChildren ().Count, "GetChildren.Count #2");
273 stackPanelLayoutChanged = false;
275 // Let's add more items to show ScrollBars
276 for (int i = 0; i < 100; i++)
277 stackPanel.Children.Add (new TextBlock () { Text = string.Format ("Item {0}", i) });
279 EnqueueConditional (() => scrollViewerLoaded && stackPanelLayoutChanged, "ScrollViewerLoaded #2");
280 Enqueue (() => {
281 AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (scrollViewer);
282 Assert.IsNotNull (peer.GetChildren (), "GetChildren #3");
283 // 103 children and 1 scrollbar
284 Assert.AreEqual (104, peer.GetChildren ().Count, "GetChildren.Count #3");
285 // Let's add a long string in order to show horizontal scrollbar
286 string longString = "my long string";
287 StringBuilder builder = new StringBuilder ();
288 for (int i = 0; i < 50; i++)
289 builder.Append (longString);
291 stackPanel.Children.Add (new TextBlock () { Text = string.Format ("ItemX {0}", builder.ToString ()) });
293 Assert.IsNotNull (peer.GetChildren (), "GetChildren #4");
294 // 103 children and 2 scrollbar
295 Assert.AreEqual (105, peer.GetChildren ().Count, "GetChildren.Count #4");
297 EnqueueTestComplete ();
300 #region Pattern Tests
302 [TestMethod]
303 [Asynchronous]
304 public void IScrollProvider_Methods ()
306 bool scrollViewerLoaded = false;
308 ScrollViewer scrollViewer = CreateConcreteFrameworkElement () as ScrollViewer;
309 scrollViewer.Loaded += (o, e) => scrollViewerLoaded = true;
310 scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
311 scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
313 // We are going to use this canvas to define an explicit
314 // scrollviewer size and location
315 Canvas canvas = new Canvas ();
316 TestPanel.Children.Add (canvas);
318 scrollViewer.SetValue (Canvas.LeftProperty, 5d);
319 scrollViewer.SetValue (Canvas.TopProperty, 5d);
320 scrollViewer.Width = 100;
321 scrollViewer.Height = 150;
322 canvas.Children.Add (scrollViewer);
324 bool stackPanelLoaded = false;
325 bool stackPanelLayoutChanged = false;
326 StackPanel stackPanel = new StackPanel ();
327 stackPanel.LayoutUpdated += (o, e) => stackPanelLayoutChanged = true;
328 stackPanel.Loaded += (o, e) => stackPanelLoaded = true;
330 EnqueueConditional (() => scrollViewerLoaded, "ScrollViewerLoaded #0");
331 Enqueue (() => {
332 AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (scrollViewer);
333 Assert.IsNotNull (peer, "FrameworkElementAutomationPeer.CreatePeerForElement");
334 IScrollProvider scrollProvider = (IScrollProvider) peer.GetPattern (PatternInterface.Scroll);
336 Assert.IsNull (peer.GetChildren (), "GetChildren #0");
337 scrollViewer.Content = stackPanel;
339 Assert.IsFalse (scrollProvider.HorizontallyScrollable, "HorizontallyScrollable #0");
340 Assert.IsFalse (scrollProvider.VerticallyScrollable, "VerticallyScrollable #0");
342 Assert.AreEqual (100, scrollProvider.VerticalViewSize, "VerticalViewSize #0");
343 Assert.AreEqual (100, scrollProvider.HorizontalViewSize, "HorizontalViewSize #0");
345 Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, scrollProvider.VerticalScrollPercent, "VerticalScrollPercent #0");
346 Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, scrollProvider.HorizontalScrollPercent, "HorizontalScrollPercent #0");
348 EnqueueConditional (() => stackPanelLoaded, "StackPanelLayoutChanged #0");
349 Enqueue (() => {
350 stackPanelLayoutChanged = false;
351 stackPanel.Children.Add (new Button () { Content = "big button", Width = 110 });
353 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #0");
354 Enqueue (() => {
355 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
357 Assert.IsTrue (scrollProvider.HorizontallyScrollable, "HorizontallyScrollable #1");
358 Assert.IsFalse (scrollProvider.VerticallyScrollable, "VerticallyScrollable #1");
360 Assert.AreEqual (100, scrollProvider.VerticalViewSize, "VerticalViewSize #1");
361 double viewsize = (scrollViewer.ViewportWidth * 100) / scrollViewer.ExtentWidth;
362 Assert.AreEqual (viewsize, scrollProvider.HorizontalViewSize, "HorizontalViewSize #1");
364 Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, scrollProvider.VerticalScrollPercent, "VerticalScrollPercent #1");
365 Assert.AreEqual (scrollViewer.HorizontalOffset, scrollProvider.HorizontalScrollPercent, "HorizontalScrollPercent #1");
367 stackPanelLayoutChanged = false;
368 stackPanel.Children.RemoveAt (0);
370 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #1");
371 Enqueue (() => {
372 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
374 Assert.IsFalse (scrollProvider.HorizontallyScrollable, "HorizontallyScrollable #2");
375 Assert.IsFalse (scrollProvider.VerticallyScrollable, "VerticallyScrollable #2");
377 Assert.AreEqual (100, scrollProvider.VerticalViewSize, "VerticalViewSize #2");
378 Assert.AreEqual (100, scrollProvider.HorizontalViewSize, "HorizontalViewSize #2");
380 Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, scrollProvider.VerticalScrollPercent, "VerticalScrollPercent #2");
381 Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, scrollProvider.HorizontalScrollPercent, "HorizontalScrollPercent #2");
383 stackPanelLayoutChanged = false;
384 stackPanel.Children.Add (new Button () { Content = "big button", Width = 10, Height = 160 });
386 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #2");
387 Enqueue (() => {
388 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
390 Assert.IsFalse (scrollProvider.HorizontallyScrollable, "HorizontallyScrollable #3");
391 Assert.IsTrue (scrollProvider.VerticallyScrollable, "VerticallyScrollable #3");
393 double viewsize = (scrollViewer.ViewportHeight * 100) / scrollViewer.ExtentHeight;
394 Assert.AreEqual (viewsize, scrollProvider.VerticalViewSize, "VerticalViewSize #3");
395 Assert.AreEqual (100, scrollProvider.HorizontalViewSize, "HorizontalViewSize #3");
397 Assert.AreEqual (scrollViewer.VerticalOffset, scrollProvider.VerticalScrollPercent, "VerticalScrollPercent #3");
398 Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, scrollProvider.HorizontalScrollPercent, "HorizontalScrollPercent #3");
400 stackPanelLayoutChanged = false;
401 stackPanel.Children.RemoveAt (0);
403 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #3");
404 Enqueue (() => {
405 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
407 Assert.IsFalse (scrollProvider.HorizontallyScrollable, "HorizontallyScrollable #4");
408 Assert.IsFalse (scrollProvider.VerticallyScrollable, "VerticallyScrollable #4");
410 Assert.AreEqual (100, scrollProvider.VerticalViewSize, "VerticalViewSize #4");
411 Assert.AreEqual (100, scrollProvider.HorizontalViewSize, "HorizontalViewSize #4");
413 Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, scrollProvider.VerticalScrollPercent, "VerticalScrollPercent #4");
414 Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, scrollProvider.HorizontalScrollPercent, "HorizontalScrollPercent #4");
416 stackPanelLayoutChanged = false;
417 stackPanel.Children.Add (new Button () { Content = "big button", Width = 10, Height = 160 });
418 stackPanel.Children.Add (new Button () { Content = "big button", Width = 110 });
420 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #4");
421 double verticalOffset = 0;
422 double horizontalOffset = 0;
423 Enqueue (() => {
424 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
426 Assert.IsTrue (scrollProvider.HorizontallyScrollable, "HorizontallyScrollable #5");
427 Assert.IsTrue (scrollProvider.VerticallyScrollable, "VerticallyScrollable #5");
429 double viewsizeVertical = (scrollViewer.ViewportHeight * 100) / scrollViewer.ExtentHeight;
430 Assert.AreEqual (viewsizeVertical, scrollProvider.VerticalViewSize, "VerticalViewSize #5");
431 double viewsizeHorizontal = (scrollViewer.ViewportWidth * 100) / scrollViewer.ExtentWidth;
432 Assert.AreEqual (viewsizeHorizontal, scrollProvider.HorizontalViewSize, "HorizontalViewSize #5");
434 verticalOffset = scrollViewer.VerticalOffset;
435 Assert.AreEqual (verticalOffset, scrollProvider.VerticalScrollPercent, "VerticalScrollPercent #5");
436 horizontalOffset = scrollViewer.HorizontalOffset;
437 Assert.AreEqual (horizontalOffset, scrollProvider.HorizontalScrollPercent, "HorizontalScrollPercent #5");
439 stackPanel.Children.Add (new Button () { Content = "big button 2", Width = 10, Height = 160 });
440 stackPanel.Children.Add (new Button () { Content = "big button 3", Width = 110 });
441 stackPanel.Children.Add (new Button () { Content = "big button 4", Width = 10, Height = 160 });
442 stackPanel.Children.Add (new Button () { Content = "big button 5", Width = 110 });
444 stackPanelLayoutChanged = false;
445 scrollProvider.Scroll (ScrollAmount.SmallIncrement, ScrollAmount.SmallIncrement);
447 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #5");
448 Enqueue (() => {
449 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
451 double newVerticalOffset = scrollViewer.VerticalOffset;
452 double newHorizontalOffset = scrollViewer.HorizontalOffset;
454 Assert.AreNotEqual (newVerticalOffset, verticalOffset, "Old/New VerticalViewSize #0");
455 Assert.AreNotEqual (newHorizontalOffset, horizontalOffset, "Old/New HorizontalViewSize #0");
457 verticalOffset = newVerticalOffset;
458 horizontalOffset = newHorizontalOffset;
460 stackPanelLayoutChanged = false;
461 scrollProvider.Scroll (ScrollAmount.NoAmount, ScrollAmount.SmallIncrement);
463 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #6");
464 Enqueue (() => {
465 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
467 double newVerticalOffset = scrollViewer.VerticalOffset;
468 double newHorizontalOffset = scrollViewer.HorizontalOffset;
470 Assert.AreNotEqual (newVerticalOffset, verticalOffset, "Old/New VerticalViewSize #1");
471 Assert.AreEqual (newHorizontalOffset, horizontalOffset, "Old/New HorizontalViewSize #1");
473 verticalOffset = newVerticalOffset;
474 horizontalOffset = newHorizontalOffset;
476 stackPanelLayoutChanged = false;
477 scrollProvider.Scroll (ScrollAmount.SmallIncrement, ScrollAmount.NoAmount);
479 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #7");
480 Enqueue (() => {
481 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
483 double newVerticalOffset = scrollViewer.VerticalOffset;
484 double newHorizontalOffset = scrollViewer.HorizontalOffset;
486 Assert.AreEqual (newVerticalOffset, verticalOffset, "Old/New VerticalViewSize #2");
487 Assert.AreNotEqual (newHorizontalOffset, horizontalOffset, "Old/New HorizontalViewSize #2");
489 verticalOffset = newVerticalOffset;
490 horizontalOffset = newHorizontalOffset;
492 stackPanelLayoutChanged = false;
493 scrollProvider.Scroll (ScrollAmount.NoAmount, ScrollAmount.NoAmount);
495 EnqueueConditional (() => !stackPanelLayoutChanged, "StackPanelLayoutChanged #8");
496 Enqueue (() => {
497 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
499 double newVerticalOffset = scrollViewer.VerticalOffset;
500 double newHorizontalOffset = scrollViewer.HorizontalOffset;
502 Assert.AreEqual (newVerticalOffset, verticalOffset, "Old/New VerticalViewSize #3");
503 Assert.AreEqual (newHorizontalOffset, horizontalOffset, "Old/New HorizontalViewSize #3");
505 stackPanelLayoutChanged = false;
506 scrollProvider.SetScrollPercent (20, 30);
508 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #9");
509 Enqueue (() => {
510 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
512 Assert.AreEqual (30, scrollProvider.VerticalScrollPercent, "VerticalScrollPercent #6");
513 Assert.AreEqual (20, scrollProvider.HorizontalScrollPercent, "HorizontalScrollPercent #6");
515 stackPanelLayoutChanged = false;
516 scrollProvider.SetScrollPercent (ScrollPatternIdentifiers.NoScroll, 50);
518 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #10");
519 Enqueue (() => {
520 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
522 Assert.AreEqual (50, scrollProvider.VerticalScrollPercent, "VerticalScrollPercent #7");
523 Assert.AreEqual (20, scrollProvider.HorizontalScrollPercent, "HorizontalScrollPercent #7"); // same value
525 stackPanelLayoutChanged = false;
526 scrollProvider.SetScrollPercent (ScrollPatternIdentifiers.NoScroll, ScrollPatternIdentifiers.NoScroll);
528 EnqueueConditional (() => !stackPanelLayoutChanged, "StackPanelLayoutChanged #11");
529 Enqueue (() => {
530 IScrollProvider scrollProvider = ScrollProviderFromScrollViewer (scrollViewer);
532 Assert.AreEqual (50, scrollProvider.VerticalScrollPercent, "VerticalScrollPercent #8"); // same value
533 Assert.AreEqual (20, scrollProvider.HorizontalScrollPercent, "HorizontalScrollPercent #8"); // same value
535 EnqueueTestComplete ();
538 [TestMethod]
539 [Asynchronous]
540 public void IScrollProvider_HorizontalMethods ()
542 ScrollViewer viewer = new ScrollViewer () {
543 HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
544 VerticalScrollBarVisibility = ScrollBarVisibility.Auto
547 AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (viewer);
548 IScrollProvider p = (IScrollProvider) peer.GetPattern (PatternInterface.Scroll);
549 viewer.Content = new Button { Width = 1000, Height = 1000 };
551 CreateAsyncTest (viewer,
552 () => viewer.ApplyTemplate (),
553 // Visible and MaxWidth = 0
554 () => {
555 viewer.MaxWidth = 0;
556 viewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
558 () => Assert.IsTrue (p.HorizontallyScrollable, "#1"),
559 () => Assert.AreEqual ((viewer.ViewportWidth * 100) / viewer.ExtentWidth, p.HorizontalViewSize, "#2"),
560 () => Assert.AreEqual (viewer.VerticalOffset, p.HorizontalScrollPercent, "#3"),
561 // Visible and MaxWidth = 200
562 () => viewer.MaxWidth = 200,
563 () => Assert.IsTrue (p.HorizontallyScrollable, "#4"),
564 () => Assert.AreEqual ((viewer.ViewportWidth * 100) / viewer.ExtentWidth, p.HorizontalViewSize, "#5"),
565 () => Assert.AreEqual (viewer.VerticalOffset, p.HorizontalScrollPercent, "#6"),
566 // Hidden and MaxWidth = 0
567 () => {
568 viewer.MaxWidth = 0;
569 viewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
571 () => Assert.IsTrue (p.HorizontallyScrollable, "#7"),
572 () => Assert.AreEqual ((viewer.ViewportWidth * 100) / viewer.ExtentWidth, p.HorizontalViewSize, "#8"),
573 () => Assert.AreEqual (viewer.VerticalOffset, p.HorizontalScrollPercent, "#9"),
574 // Hidden and MaxWidth = 200
575 () => viewer.MaxWidth = 200,
576 () => Assert.IsTrue (p.HorizontallyScrollable, "#10"),
577 () => Assert.AreEqual ((viewer.ViewportWidth * 100) / viewer.ExtentWidth, p.HorizontalViewSize, "#11"),
578 () => Assert.AreEqual (viewer.VerticalOffset, p.HorizontalScrollPercent, "#12"),
579 // Disabled and MaxWidth = 0
580 () => {
581 viewer.MaxWidth = 0;
582 viewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
584 () => Assert.IsFalse (p.HorizontallyScrollable, "#13"),
585 () => Assert.AreEqual (100d, p.HorizontalViewSize, "#14"),
586 () => Assert.AreEqual (0d, viewer.ExtentWidth, "#15"),
587 () => Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, p.HorizontalScrollPercent, "#16"),
588 // Disabled and MaxWidth = 200
589 () => viewer.MaxWidth = 200,
590 () => Assert.IsFalse (p.HorizontallyScrollable, "#17"),
591 () => Assert.AreEqual (100d, p.HorizontalViewSize, "#18"),
592 () => Assert.AreNotEqual (0d, viewer.ExtentWidth, "#19"),
593 () => Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, p.HorizontalScrollPercent, "#20"),
594 // Auto and MaxWidth = 0
595 () => {
596 viewer.MaxWidth = 0;
597 viewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
599 () => Assert.IsTrue (p.HorizontallyScrollable, "#21"),
600 () => Assert.AreEqual ((viewer.ViewportWidth * 100) / viewer.ExtentWidth, p.HorizontalViewSize, "#22"),
601 () => Assert.AreEqual (viewer.VerticalOffset, p.HorizontalScrollPercent, "#23"),
602 // Auto and MaxWidth = 200
603 () => viewer.MaxWidth = 200,
604 () => Assert.IsTrue (p.HorizontallyScrollable, "#24"),
605 () => Assert.AreEqual ((viewer.ViewportWidth * 100) / viewer.ExtentWidth, p.HorizontalViewSize, "#25"),
606 () => Assert.AreEqual (viewer.VerticalOffset, p.HorizontalScrollPercent, "#26")
610 [TestMethod]
611 [Asynchronous]
612 public void IScrollProvider_VerticalMethods ()
614 ScrollViewer viewer = new ScrollViewer () {
615 HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
616 VerticalScrollBarVisibility = ScrollBarVisibility.Auto
619 AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (viewer);
620 IScrollProvider p = (IScrollProvider) peer.GetPattern (PatternInterface.Scroll);
621 viewer.Content = new Button { Width = 1000, Height = 1000 };
623 CreateAsyncTest (viewer,
624 () => viewer.ApplyTemplate (),
625 // Visible and MaxHeight = 0
626 () => {
627 viewer.MaxHeight = 0;
628 viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
630 () => Assert.IsTrue (p.VerticallyScrollable, "#1"),
631 () => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#2"),
632 () => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#3"),
633 // Visible and MaxHeight = 200
634 () => viewer.MaxHeight = 200,
635 () => Assert.IsTrue (p.VerticallyScrollable, "#4"),
636 () => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#5"),
637 () => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#6"),
638 // Hidden and MaxHeight = 0
639 () => {
640 viewer.MaxHeight = 0;
641 viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
643 () => Assert.IsTrue (p.VerticallyScrollable, "#7"),
644 () => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#8"),
645 () => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#9"),
646 // Hidden and MaxHeight = 200
647 () => viewer.MaxHeight = 200,
648 () => Assert.IsTrue (p.VerticallyScrollable, "#10"),
649 () => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#11"),
650 () => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#12"),
651 // Disabled and MaxHeight = 0
652 () => {
653 viewer.MaxHeight = 0;
654 viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
656 () => Assert.IsFalse (p.VerticallyScrollable, "#13"),
657 () => Assert.AreEqual (100d, p.VerticalViewSize, "#14"),
658 () => Assert.AreEqual (0d, viewer.ExtentHeight, "#15"),
659 () => Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, p.VerticalScrollPercent, "#16"),
660 // Disabled and MaxHeight = 200
661 () => viewer.MaxHeight = 200,
662 () => Assert.IsFalse (p.VerticallyScrollable, "#17"),
663 () => Assert.AreEqual (100d, p.VerticalViewSize, "#18"),
664 () => Assert.AreNotEqual (0d, viewer.ExtentHeight, "#19"),
665 () => Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, p.VerticalScrollPercent, "#20"),
666 // Auto and MaxHeight = 0
667 () => {
668 viewer.MaxHeight = 0;
669 viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
671 () => Assert.IsTrue (p.VerticallyScrollable, "#21"),
672 () => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#22"),
673 () => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#23"),
674 // Auto and MaxHeight = 200
675 () => viewer.MaxHeight = 200,
676 () => Assert.IsTrue (p.VerticallyScrollable, "#24"),
677 () => Assert.AreEqual ((viewer.ViewportHeight * 100) / viewer.ExtentHeight, p.VerticalViewSize, "#25"),
678 () => Assert.AreEqual (viewer.VerticalOffset, p.VerticalScrollPercent, "#26")
682 [TestMethod]
683 [Asynchronous]
684 public void IScrollProvider_Events ()
686 if (!EventsManager.Instance.AutomationSingletonExists) {
687 EnqueueTestComplete ();
688 return;
691 bool scrollViewerLoaded = false;
693 ScrollViewer scrollViewer = CreateConcreteFrameworkElement () as ScrollViewer;
694 scrollViewer.Loaded += (o, e) => scrollViewerLoaded = true;
695 scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
696 scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
698 // We are going to use this canvas to define an explicit
699 // scrollviewer size and location
700 Canvas canvas = new Canvas ();
701 TestPanel.Children.Add (canvas);
703 scrollViewer.SetValue (Canvas.LeftProperty, 5d);
704 scrollViewer.SetValue (Canvas.TopProperty, 5d);
705 scrollViewer.Width = 100;
706 scrollViewer.Height = 150;
707 canvas.Children.Add (scrollViewer);
709 bool stackPanelLoaded = false;
710 bool stackPanelLayoutChanged = false;
711 StackPanel stackPanel = new StackPanel ();
712 stackPanel.LayoutUpdated += (o, e) => stackPanelLayoutChanged = true;
713 stackPanel.Loaded += (o, e) => stackPanelLoaded = true;
715 AutomationPeer peer = null;
716 IScrollProvider scrollProvider = null;
717 AutomationPropertyEventTuple propertyTuple = null;
718 double viewsizeVertical = 0;
719 double viewsizeHorizontal = 0;
720 double verticalOffset = 0;
721 double horizontalOffset = 0;
723 EnqueueConditional (() => scrollViewerLoaded, "ScrollViewerLoaded #0");
724 Enqueue (() => {
725 peer = FrameworkElementAutomationPeer.CreatePeerForElement (scrollViewer);
726 Assert.IsNotNull (peer, "FrameworkElementAutomationPeer.CreatePeerForElement");
727 scrollProvider = (IScrollProvider) peer.GetPattern (PatternInterface.Scroll);
729 scrollViewer.Content = stackPanel;
731 EnqueueConditional (() => stackPanelLoaded, "StackPanelLayoutChanged #0");
732 Enqueue (() => {
733 EventsManager.Instance.Reset ();
734 stackPanelLayoutChanged = false;
735 stackPanel.Children.Add (new Button () { Content = "big button", Width = 110 });
737 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #0");
738 Enqueue (() => {
739 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
740 ScrollPatternIdentifiers.VerticallyScrollableProperty);
741 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #0");
743 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
744 ScrollPatternIdentifiers.HorizontallyScrollableProperty);
745 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #1");
746 Assert.IsFalse ((bool) propertyTuple.OldValue, "GetAutomationEventFrom.OldValue #1");
747 Assert.IsTrue ((bool) propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #1");
749 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
750 ScrollPatternIdentifiers.VerticalViewSizeProperty);
751 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #2");
753 viewsizeHorizontal = (scrollViewer.ViewportWidth * 100) / scrollViewer.ExtentWidth;
754 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
755 ScrollPatternIdentifiers.HorizontalViewSizeProperty);
756 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #3");
757 Assert.AreEqual (100, (double) propertyTuple.OldValue, "GetAutomationEventFrom.OldValue #3");
758 Assert.AreEqual (viewsizeHorizontal, (double) propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #3");
760 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
761 ScrollPatternIdentifiers.VerticalScrollPercentProperty);
762 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #4");
764 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
765 ScrollPatternIdentifiers.HorizontalScrollPercentProperty);
766 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #5");
767 Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, (double) propertyTuple.OldValue, "GetAutomationEventFrom.OldValue #5");
768 Assert.AreEqual (scrollViewer.HorizontalOffset, (double) propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #5");
769 horizontalOffset = scrollViewer.HorizontalOffset;
771 Enqueue (() => {
772 EventsManager.Instance.Reset ();
773 stackPanelLayoutChanged = false;
774 stackPanel.Children.RemoveAt (0);
776 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #1");
777 Enqueue (() => {
778 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
779 ScrollPatternIdentifiers.VerticallyScrollableProperty);
780 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #6");
782 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
783 ScrollPatternIdentifiers.HorizontallyScrollableProperty);
784 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #7");
785 Assert.IsTrue ((bool) propertyTuple.OldValue, "GetAutomationEventFrom.OldValue #6");
786 Assert.IsFalse ((bool) propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #6");
788 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
789 ScrollPatternIdentifiers.VerticalViewSizeProperty);
790 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #8");
792 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
793 ScrollPatternIdentifiers.HorizontalViewSizeProperty);
794 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #9");
795 Assert.AreEqual (viewsizeHorizontal, (double) propertyTuple.OldValue, "GetAutomationEventFrom.OldValue #7");
796 Assert.AreEqual (100d, (double) propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #7");
798 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
799 ScrollPatternIdentifiers.VerticalScrollPercentProperty);
800 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #10");
802 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
803 ScrollPatternIdentifiers.HorizontalScrollPercentProperty);
804 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #11");
805 Assert.AreEqual (horizontalOffset, (double) propertyTuple.OldValue, "GetAutomationEventFrom.OldValue #8");
806 Assert.AreEqual (ScrollPatternIdentifiers.NoScroll, (double) propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #8");
808 Enqueue (() => {
809 EventsManager.Instance.Reset ();
810 stackPanelLayoutChanged = false;
811 stackPanel.Children.Add (new Button () { Content = "big button", Width = 10, Height = 160 });
812 stackPanel.Children.Add (new Button () { Content = "big button", Width = 110 });
814 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #2");
815 Enqueue (() => {
816 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
817 ScrollPatternIdentifiers.VerticallyScrollableProperty);
818 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #12");
819 Assert.IsFalse ((bool) propertyTuple.OldValue, "GetAutomationEventFrom.OldValue #12");
820 Assert.IsTrue ((bool) propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #12");
822 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
823 ScrollPatternIdentifiers.HorizontallyScrollableProperty);
824 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #13");
825 Assert.IsFalse ((bool) propertyTuple.OldValue, "GetAutomationEventFrom.OldValue #13");
826 Assert.IsTrue ((bool) propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #13");
828 viewsizeVertical = (scrollViewer.ViewportHeight * 100) / scrollViewer.ExtentHeight;
829 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
830 ScrollPatternIdentifiers.VerticalViewSizeProperty);
831 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #14");
832 Assert.AreEqual (viewsizeVertical, scrollProvider.VerticalViewSize, "VerticalViewSize #1");
834 viewsizeHorizontal = (scrollViewer.ViewportWidth * 100) / scrollViewer.ExtentWidth;
835 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
836 ScrollPatternIdentifiers.HorizontalViewSizeProperty);
837 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #15");
838 Assert.AreEqual (viewsizeHorizontal, scrollProvider.HorizontalViewSize, "HorizontalViewSize #1");
840 Enqueue (() => {
841 EventsManager.Instance.Reset ();
842 stackPanel.Children.Add (new Button () { Content = "big button 2", Width = 10, Height = 160 });
843 stackPanel.Children.Add (new Button () { Content = "big button 3", Width = 110 });
844 stackPanel.Children.Add (new Button () { Content = "big button 4", Width = 10, Height = 160 });
845 stackPanel.Children.Add (new Button () { Content = "big button 5", Width = 110 });
847 stackPanelLayoutChanged = false;
848 scrollProvider.Scroll (ScrollAmount.SmallIncrement, ScrollAmount.SmallIncrement);
850 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #3");
851 Enqueue (() => {
852 double newVerticalOffset = scrollViewer.VerticalOffset;
853 double newHorizontalOffset = scrollViewer.HorizontalOffset;
855 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
856 ScrollPatternIdentifiers.VerticalViewSizeProperty);
857 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #16");
859 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
860 ScrollPatternIdentifiers.HorizontalViewSizeProperty);
861 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #17");
863 Assert.AreNotEqual (newVerticalOffset, verticalOffset, "Old/New VerticalViewSize #0");
864 Assert.AreNotEqual (newHorizontalOffset, horizontalOffset, "Old/New HorizontalViewSize #0");
866 verticalOffset = newVerticalOffset;
867 horizontalOffset = newHorizontalOffset;
869 Enqueue (() => {
870 EventsManager.Instance.Reset ();
871 stackPanelLayoutChanged = false;
872 scrollProvider.Scroll (ScrollAmount.NoAmount, ScrollAmount.SmallIncrement);
874 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #4");
875 Enqueue (() => {
876 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
877 ScrollPatternIdentifiers.VerticalScrollPercentProperty);
878 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #18");
880 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
881 ScrollPatternIdentifiers.HorizontalScrollPercentProperty);
882 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #19");
884 Enqueue (() => {
885 EventsManager.Instance.Reset ();
886 stackPanelLayoutChanged = false;
887 scrollProvider.Scroll (ScrollAmount.SmallIncrement, ScrollAmount.NoAmount);
889 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #5");
890 Enqueue (() => {
891 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
892 ScrollPatternIdentifiers.VerticalScrollPercentProperty);
893 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #20");
895 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
896 ScrollPatternIdentifiers.HorizontalScrollPercentProperty);
897 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #21");
899 Enqueue (() => {
900 EventsManager.Instance.Reset ();
901 stackPanelLayoutChanged = false;
902 scrollProvider.Scroll (ScrollAmount.NoAmount, ScrollAmount.NoAmount);
904 Enqueue (() => {
905 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
906 ScrollPatternIdentifiers.VerticalScrollPercentProperty);
907 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #22");
909 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
910 ScrollPatternIdentifiers.HorizontalScrollPercentProperty);
911 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #23");
913 Enqueue (() => {
914 EventsManager.Instance.Reset ();
915 stackPanelLayoutChanged = false;
916 scrollProvider.SetScrollPercent (20, 30);
918 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #7");
919 Enqueue (() => {
920 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
921 ScrollPatternIdentifiers.VerticalScrollPercentProperty);
922 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #22");
923 Assert.AreEqual (30d, propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #22");
925 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
926 ScrollPatternIdentifiers.HorizontalScrollPercentProperty);
927 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #23");
928 Assert.AreEqual (20d, propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #23");
930 Enqueue (() => {
931 EventsManager.Instance.Reset ();
932 stackPanelLayoutChanged = false;
933 scrollProvider.SetScrollPercent (ScrollPatternIdentifiers.NoScroll, 50);
935 EnqueueConditional (() => stackPanelLayoutChanged, "StackPanelLayoutChanged #8");
936 Enqueue (() => {
937 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
938 ScrollPatternIdentifiers.VerticalScrollPercentProperty);
939 Assert.IsNotNull (propertyTuple, "GetAutomationEventFrom #24");
940 Assert.AreEqual (50d, propertyTuple.NewValue, "GetAutomationEventFrom.NewValue #24");
941 Assert.AreEqual (30d, propertyTuple.OldValue, "GetAutomationEventFrom.NewValue #24");
943 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
944 ScrollPatternIdentifiers.HorizontalScrollPercentProperty);
945 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #25");
947 Enqueue (() => {
948 EventsManager.Instance.Reset ();
949 stackPanelLayoutChanged = false;
950 scrollProvider.SetScrollPercent (ScrollPatternIdentifiers.NoScroll, ScrollPatternIdentifiers.NoScroll);
952 Enqueue (() => {
953 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
954 ScrollPatternIdentifiers.VerticalScrollPercentProperty);
955 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #26");
957 propertyTuple = EventsManager.Instance.GetAutomationEventFrom (peer,
958 ScrollPatternIdentifiers.HorizontalScrollPercentProperty);
959 Assert.IsNull (propertyTuple, "GetAutomationEventFrom #27");
961 EnqueueTestComplete ();
964 private IScrollProvider ScrollProviderFromScrollViewer (ScrollViewer viewer)
966 AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (viewer);
967 Assert.IsNotNull (peer, "FrameworkElementAutomationPeer.CreatePeerForElement");
968 return (IScrollProvider) peer.GetPattern (PatternInterface.Scroll);
971 #endregion
973 protected override FrameworkElement CreateConcreteFrameworkElement ()
975 return new ScrollViewer ();
978 protected override FrameworkElementAutomationPeerContract CreateConcreteFrameworkElementAutomationPeer (FrameworkElement element)
980 return new ScrollViewerAutomationPeerConcrete (element as ScrollViewer);