public void ChildPropertyChangesWithRevert() { using (var verify = new Verify()) { var customer = CreateCustomer(verify); var eventAssertCustomer = new PropertyChangedEventTest(verify, customer); //changes to a child in a collection var eventAssertOrder0 = new PropertyChangedEventTest(verify, customer.Orders[0]); var newOrderDate = new DateTime(2010, 5, 5); customer.Orders[0].OrderDate = newOrderDate; eventAssertOrder0.ExpectEvent("OrderDate"); eventAssertOrder0.ExpectEvent("IsChangedLocal"); eventAssertOrder0.ExpectEvent("IsChanged"); eventAssertOrder0.ExpectNothing(); //eventAssertCustomer.ExpectEvent("IsChanged"); //eventAssertCustomer.ExpectNothing(); //rollback customer.RejectChanges(); verify.AreEqual(OrderDate1, customer.Orders[0].OrderDate, "Order date didn't roll back"); verify.IsFalse(customer.IsChanged, ""); eventAssertCustomer.ExpectEvent("IsChanged"); } }
public void CalculatedFieldAttribute_Test3() { using (var verify = new Verify()) { verify.ArgumentException("sources", () => new CalculatedFieldAttribute(null), "empty lists are not allowed"); } }
public void ChangeTrackingModelBase_BasicFunctionalityTest() { using (var verify = new Verify()) { var person = new ChangeTrackingPerson(); var eventAssert = new PropertyChangedEventTest(verify, person); Assert.IsNull(person.FirstName); Assert.AreEqual("", person.LastName); eventAssert.ExpectNothing(); person.FirstName = "John"; eventAssert.ExpectEvent("FirstName"); eventAssert.ExpectEvent("FullName"); eventAssert.ExpectEvent("IsChangedLocal"); eventAssert.ExpectEvent("IsChanged"); person.LastName = "Doe"; eventAssert.ExpectEvent("LastName"); eventAssert.ExpectEvent("FullName"); person.InvokeGoodPropertyMessage(); eventAssert.ExpectEvent("FullName"); person.InvokeAllPropertyMessage(); eventAssert.ExpectEvent(""); } }
public void ExtendedObservableCollection_AddRemoveOverrideTest() { using (var verify = new Verify()) { var result = new FooCollection(new[] { new Foo(), new Foo(), new Foo() }); verify.AreEqual(3, result.AddCount, "count was incorrect"); } }
public void ItemEventArgs_ItemTest() { using (var verify = new Verify()) { var x = new ItemEventArgs<string>("xxx"); verify.AreEqual("xxx", x.Item, "Item property was not set correctly"); } }
public void WeakReferenceCollection_Add() { using (var verify = new Verify()) { var result = new WeakReferenceCollection<string>(); verify.ArgumentNullException("item", () => result.Add(null)); } }
public void CalculatedFieldAttribute_Test2() { using (var verify = new Verify()) { verify.ArgumentException("sources", () => new CalculatedFieldAttribute(null)); } }
public void WeakReferenceCollection_AddRange_Test1() { using (var verify = new Verify()) { IList<string> list = null; var result = new WeakReferenceCollection<string>(); verify.ArgumentNullException("list", () => result.AddRange(list)); } }
public void CollectionUtilities_AddRange_Test2() { using (var verify = new Verify()) { List<string> target = null; List<string> list = null; verify.ArgumentNullException("target", () => CollectionUtilities.AddRange(target, list)); } }
public void CollectionUtilities_AddRange_Test11() { using (var verify = new Verify()) { var list = (new List<int> { 1, 2, 3 }).Where(x => true); ICollection<int> target = new ReadOnlyCollection<int>(new List<int>()); verify.ArgumentException("target", () => CollectionUtilities.AddRange(target, list), "read-only list"); verify.ArgumentException("target", () => CollectionUtilities.AddRange(target, 1, 2, 3), "read-only list"); } }
public void CollectionUtilities_AddRange_Test10() { using (var verify = new Verify()) { IEnumerable<int> list = new List<int> { 1, 2, 3 }; ICollection<int> target = new ReadOnlyCollection<int>(new List<int>()); verify.ArgumentException("target", () => CollectionUtilities.AddRange(target, list), "read-only list"); verify.ArgumentException("target", () => CollectionUtilities.AddRange(target, 1, 2, 3), "read-only list"); } }
public void ExtendedObservableCollection_RemoveNullHandlerTest() { using (var verify = new Verify()) { var list = new ObservableCollectionExtended<int>(); var result = new ReadOnlyObservableCollectionExtended<int>(list); verify.ArgumentNullException("eventHandler", () => result.RemoveHandler((IListener<NotifyCollectionChangedEventArgs>)null)); verify.ArgumentNullException("eventHandler", () => result.RemoveHandler((IListener<PropertyChangedEventArgs>)null)); } }
public void PropertyMetadataCollection_CopyTo_Test3() { using (var verify = new Verify()) { var result = MetadataCache.GetMetadata(typeof(Tests.Metadata.Mock)).Properties; var array = new PropertyMetadata[result.Count]; result.CopyTo(array, 0); foreach (var p in result) CollectionAssert.Contains(array, p); } }
public void ExtendedObservableCollection_AddNullHandlerTest() { using (var verify = new Verify()) { var result = new FooCollection(); verify.ArgumentNullException("eventHandler", () => result.AddHandler((IListener<NotifyCollectionChangedEventArgs>)null)); verify.ArgumentNullException("eventHandler", () => result.AddHandler((IListener<PropertyChangedEventArgs>)null)); verify.ArgumentNullException("eventHandler", () => result.AddHandler((IListener<RelayedEventArgs<PropertyChangedEventArgs>>)null)); } }
public void CalculatedFieldAttribute_Test1() { using (var verify = new Verify()) { string fields = "AAA, BBB,CCC"; var result = new CalculatedFieldAttribute(fields); verify.AreEqual(fields, result.Sources, "the field list shouldn't be altered in any way"); verify.ItemsAreEqual(new[] { "AAA", "BBB", "CCC" }, result.SourceProperties, ""); } }
public void ValidationResultCollection_Test1() { using (var verify = new Verify()) { var collection = new ValidationResultCollection(); var result = collection.Add("Test", "FirstName", "LastName"); verify.AreEqual("Test", result.ErrorMessage, "Error message"); verify.AreEqual("FirstName", result.MemberNames.ToList()[0], "member 0"); verify.AreEqual("LastName", result.MemberNames.ToList()[1], "member 1"); } }
public static Page Fetch(Service service) { if (!Platform.HasInternetConnection()) { return new ContentPage { Content = new Label { Text = Localize.GetString("TelegramPleaseConnectToInternet"), VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, XAlign = TextAlignment.Center, Font = Font.SystemFontOfSize(18), }, Title = Localize.GetString("TelegramSetupWizardTitle"), Padding = 30, }; } LoadSettingsIfNeeded(); if (_cachedPage != null) { return _cachedPage; } var tabs = new TabbedPage(); var code = new Code(service, tabs); var verify = new Verify(service, tabs, code); var info = new Info(service, tabs, verify); tabs.Children.Add(info); tabs.PropertyChanged += (sender, e) => { if (e.PropertyName == "CurrentPage") { var selected = tabs.CurrentPage; if (selected is Info) { tabs.Children.Remove(verify); tabs.Children.Remove(code); } if (selected is Verify) { tabs.Children.Remove(code); } } }; tabs.Title = Localize.GetString("TelegramSetupWizardTitle"); _cachedPage = tabs; return tabs; }
public void ExtendedObservableCollection_AddRange_Test1() { using (var verify = new Verify()) { var weakNotifier = new WeakNotifier(); var notifier = new Notifier(); var temp = new[] { notifier, weakNotifier }; var result = new ObservableCollectionExtended<object>(); result.AddRange(temp); ConstructorAssertions(verify, result, weakNotifier, notifier); } }
public void CollectionUtilities_AddRange_Test3() { using (var verify = new Verify()) { List<string> target = new List<string>(); List<string> list = new List<string>(); target.Add("AAA"); list.Add("BBB"); list.Add("CCC"); CollectionUtilities.AddRange(target, list); verify.ItemsAreEqual(new[] { "AAA", "BBB", "CCC" }, target, "AddRange should have added 3 items"); } }
public void ChildPropertyChangesWithCommit() { using (var verify = new Verify()) { var customer = CreateCustomer(verify); //more setup customer.FirstName = "Tom"; customer.LastName = "Doe"; customer.AcceptChanges(); if (customer.IsChanged) verify.Inconclusive("setup failed"); var eventAssertCustomer = new PropertyChangedEventTest(verify, customer); customer.PropertyChanged += (s, e) => Debug.WriteLine(e.PropertyName); //local changes customer.FirstName = "Bob"; eventAssertCustomer.ExpectEvent("FirstName"); eventAssertCustomer.ExpectEvent("FullName"); eventAssertCustomer.ExpectEvent("IsChangedLocal"); eventAssertCustomer.ExpectEvent("IsChanged"); eventAssertCustomer.ExpectNothing(); verify.IsTrue(customer.IsChanged, ""); verify.IsTrue(customer.IsChangedLocal, ""); verify.AreEqual(1, customer.ChangedProperties().Count, "There should be one changed property"); verify.AreEqual("FirstName", customer.ChangedProperties()[0], "The property should be FirstName"); //this time IsChanged shouldn't be raised again customer.LastName = "Jones"; eventAssertCustomer.ExpectEvent("LastName"); eventAssertCustomer.ExpectEvent("FullName"); eventAssertCustomer.ExpectNothing(); verify.IsTrue(customer.IsChanged, ""); verify.IsTrue(customer.IsChangedLocal, ""); //accept changes customer.AcceptChanges(); verify.IsFalse(customer.IsChanged, ""); verify.IsFalse(customer.IsChangedLocal, ""); eventAssertCustomer.ExpectEvent("IsChangedLocal"); eventAssertCustomer.ExpectEvent("IsChanged"); eventAssertCustomer.ExpectNothing(); verify.AreEqual("Bob", customer.FirstName, ""); verify.AreEqual("Jones", customer.LastName, ""); verify.AreEqual(0, customer.ChangedProperties().Count, "There shouldn't be any changed properties"); } }
public void WeakReferenceCollection_AddRange_Test3() { using (var verify = new Verify()) { string item1 = "AAA"; string item2 = "BBB"; var list = new List<string>(); list.Add(item1); list.Add(null); list.Add(item2); var result = new WeakReferenceCollection<string>(); verify.ArgumentException("list", () => result.AddRange(list), "The list contains a null item"); } }
public void ColumnMappingTest() { using (var verify = new Verify()) { var properties = MetadataCache.GetMetadata(typeof(DataMapMock)).Properties; Assert.AreEqual("Column1", properties["Column1"].MappedColumnName); Assert.AreEqual("ColumnB", properties["Column2"].MappedColumnName); Assert.IsNull(properties["Column3"].MappedColumnName); Assert.IsFalse(properties["Column1"].IsKey); Assert.IsFalse(properties["Column2"].IsKey); Assert.IsFalse(properties["Column3"].IsKey); Assert.IsTrue(properties["Column4"].IsKey); } }
public void RelayedEventArgs_Test1() { using (var verify = new Verify()) { try { var e = RelayedEventArgs.Create(new object(), (EventArgs)null); verify.Fail("Expected an ArgumentNullException"); } catch (ArgumentNullException ex) { verify.AreEqual("eventArgs", ex.ParamName, "Parameter name is wrong"); } } }
public void ExtendedObservableCollection_AddRange_Test2() { using (var verify = new Verify()) { try { var result = new ObservableCollectionExtended<object>(); result.AddRange(null); verify.Fail("Expected an ArgumentNullException exception"); } catch (ArgumentNullException ex) { verify.AreEqual("list", ex.ParamName, "Parameter name is incorrect"); } } }
public void ExtendedReadOnlyObservableCollection_Constructor_Test1() { using (var verify = new Verify()) { try { ObservableCollectionExtended<int> list = null; var result = new ReadOnlyObservableCollectionExtended<int>(list); verify.Fail("Expected an ArgumentNullException"); } catch (ArgumentNullException ex) { verify.AreEqual("list", ex.ParamName, "Parameter name is wrong"); } } }
public void WeakReferenceCollection_AddRange_Test2() { using (var verify = new Verify()) { string item1 = "AAA"; string item2 = "BBB"; var list = new List<string>(); list.Add(item1); list.Add(item2); var result = new WeakReferenceCollection<string>(); result.AddRange(list); verify.ItemsAreSame(new[] { "AAA", "BBB" }, result, "Two items should have been in the collection."); } }
public void PropertyMetadataCollection_CopyTo_Test1() { using (var verify = new Verify()) { try { var result = MetadataCache.GetMetadata(typeof(Tests.Metadata.Mock)).Properties; result.CopyTo(null, 0); verify.Fail("Expected an ArgumentNullException"); } catch (ArgumentNullException ex) { verify.AreEqual("array", ex.ParamName, "Incorrect parameter name"); } } }
public void ExtendedObservableDictionary_RemoveHandlerTest2() { using (var verify = new Verify()) { var list = new ObservableCollectionExtended<int>(); var result = new ReadOnlyObservableCollectionExtended<int>(list); var collectionChangedEventQueue = new Queue<Tuple<object, NotifyCollectionChangedEventArgs>>(); var collectionChangedListener = new Listener<NotifyCollectionChangedEventArgs>((s, e) => collectionChangedEventQueue.Enqueue(Tuple.Create(s, e))); result.AddHandler(collectionChangedListener); result.RemoveHandler(collectionChangedListener); result.RemoveHandler(collectionChangedListener); var propertyChangedEventQueue = new Queue<Tuple<object, PropertyChangedEventArgs>>(); var propertyChangedListener = new Listener<PropertyChangedEventArgs>((s, e) => propertyChangedEventQueue.Enqueue(Tuple.Create(s, e))); result.AddHandler(propertyChangedListener); result.RemoveHandler(propertyChangedListener); result.RemoveHandler(propertyChangedListener); } }
public void EditableObjectModelBase_BasicFunctionalityTest() { using (var verify = new Verify()) { var person = new EditablePerson(); var eventAssert = new PropertyChangedEventTest(verify, person); Assert.IsNull(person.FirstName); Assert.AreEqual("", person.LastName); person.FirstName = "John"; eventAssert.ExpectUnordered("FirstName", "IsChangedLocal", "IsChanged", "FullName"); person.LastName = "Doe"; eventAssert.ExpectUnordered("LastName", "FullName"); person.InvokeGoodPropertyMessage(); eventAssert.ExpectEvent("FullName"); } }
public void VerifyCurrentAnchor() { ItemsRepeater rootRepeater = null; ScrollViewer scrollViewer = null; ItemsRepeaterScrollHost scrollhost = null; ManualResetEvent viewChanged = new ManualResetEvent(false); RunOnUIThread.Execute(() => { scrollhost = (ItemsRepeaterScrollHost)XamlReader.Load( @"<controls:ItemsRepeaterScrollHost Width='400' Height='600' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:controls='using:Microsoft.UI.Xaml.Controls'> <controls:ItemsRepeaterScrollHost.Resources> <DataTemplate x:Key='ItemTemplate' > <TextBlock Text='{Binding}' Height='50'/> </DataTemplate> </controls:ItemsRepeaterScrollHost.Resources> <ScrollViewer x:Name='scrollviewer'> <controls:ItemsRepeater x:Name='rootRepeater' ItemTemplate='{StaticResource ItemTemplate}' VerticalCacheLength='0' /> </ScrollViewer> </controls:ItemsRepeaterScrollHost>"); rootRepeater = (ItemsRepeater)scrollhost.FindName("rootRepeater"); scrollViewer = (ScrollViewer)scrollhost.FindName("scrollviewer"); scrollViewer.ViewChanged += (sender, args) => { if (!args.IsIntermediate) { viewChanged.Set(); } }; rootRepeater.ItemsSource = Enumerable.Range(0, 500); Content = scrollhost; }); // scroll down several times and validate current anchor for (int i = 1; i < 10; i++) { IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { scrollViewer.ChangeView(null, i * 200, null); }); Verify.IsTrue(viewChanged.WaitOne(DefaultWaitTimeInMS)); viewChanged.Reset(); RunOnUIThread.Execute(() => { Verify.AreEqual(i * 200, scrollViewer.VerticalOffset); var anchor = PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5) ? scrollhost.CurrentAnchor : scrollViewer.CurrentAnchor; var anchorIndex = rootRepeater.GetElementIndex(anchor); Log.Comment("CurrentAnchor: " + anchorIndex); Verify.AreEqual(i * 4, anchorIndex); }); } }
public void Setup() { Verify verify = new Verify(); _v = verify; }
private static Map GetMap(PublicationScope publicationScope, CultureInfo localizationScope, UrlSpace urlSpace) { Verify.ArgumentNotNull(localizationScope, "localizationScope"); Verify.ArgumentNotNull(urlSpace, "urlSpace"); if (System.Transactions.Transaction.Current != null) { var exceptionToLog = new Exception("It is not safe to use PageStructureInfo/SiteMap functionality in transactional context. Method Composite.Data.PageManager can be used instead."); Log.LogWarning(typeof(PageStructureInfo).Name, exceptionToLog); } var scopeKey = GetScopeKey(publicationScope, localizationScope, urlSpace); Map map = _generatedMaps[scopeKey]; if (map != null) { return(map); } // Using different sync roots for different datascopes //object buildingLock = _buildingLock[scopeKey.First == DataScopeIdentifier.Public.Name ? 0 : 1]; // NOTE: Do not using a lock because it could because GetAssociatedPageIds is used inside transactions on some sites and it causes deadlocks // lock (buildingLock) { map = _generatedMaps[scopeKey]; if (map != null) { return(map); } Version version = _versions[scopeKey]; if (version == null) { lock (_updatingLock) { version = _versions[scopeKey]; if (version == null) { _versions.Add(scopeKey, version = new Version()); } } } Thread.MemoryBarrier(); int currentVersion = version.VersionNumber; Thread.MemoryBarrier(); using (new DataScope(publicationScope, localizationScope)) { map = BuildMap(urlSpace); } lock (_updatingLock) { if (_versions[scopeKey].VersionNumber == currentVersion) { _generatedMaps.Remove(scopeKey); _generatedMaps.Add(scopeKey, map); } } return(map); } }
public void ValidateOneScrollViewerScenario() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) { Log.Warning("Skipping since version is less than RS5 and effective viewport is not available below RS5"); return; } var realizationRects = new List <Rect>(); ScrollViewer scrollViewer = null; var viewChangeCompletedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { var repeater = new ItemsRepeater() { Layout = GetMonitoringLayout(new Size(500, 600), realizationRects), HorizontalCacheLength = 0.0, VerticalCacheLength = 0.0 }; scrollViewer = new ScrollViewer { Content = repeater, Width = 200, Height = 300 }; Content = scrollViewer; Content.UpdateLayout(); Verify.AreEqual(2, realizationRects.Count); Verify.AreEqual(new Rect(0, 0, 0, 0), realizationRects[0]); Verify.AreEqual(new Rect(0, 0, 200, 300), realizationRects[1]); realizationRects.Clear(); scrollViewer.ViewChanged += (Object sender, ScrollViewerViewChangedEventArgs args) => { if (!args.IsIntermediate) { viewChangeCompletedEvent.Set(); } }; }); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { scrollViewer.ChangeView(0.0, 100.0, null, true); }); Verify.IsTrue(viewChangeCompletedEvent.WaitOne(DefaultWaitTimeInMS)); RunOnUIThread.Execute(() => { Verify.AreEqual(new Rect(0, 100, 200, 300), realizationRects.Last()); realizationRects.Clear(); viewChangeCompletedEvent.Reset(); scrollViewer.ChangeView(null, null, 2.0f, true); }); Verify.IsTrue(viewChangeCompletedEvent.WaitOne(DefaultWaitTimeInMS)); RunOnUIThread.Execute(() => { Verify.AreEqual( new Rect(0, 50, 100, 150), realizationRects.Last()); realizationRects.Clear(); }); }
public void CanBringIntoViewElements() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) { Log.Warning("Skipping since version is less than RS5 and effective viewport is not available below RS5"); return; } if (!PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone3)) { Log.Warning("Skipping CanBringIntoViewElements because UIElement.BringIntoViewRequested was added in RS4."); return; } ScrollViewer scroller = null; ItemsRepeater repeater = null; var rootLoadedEvent = new AutoResetEvent(initialState: false); var effectiveViewChangeCompletedEvent = new AutoResetEvent(initialState: false); var viewChangeCompletedEvent = new AutoResetEvent(initialState: false); var viewChangedOffsets = new List <double>(); RunOnUIThread.Execute(() => { var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam laoreet erat vel massa rutrum, eget mollis massa vulputate. Vivamus semper augue leo, eget faucibus nulla mattis nec. Donec scelerisque lacus at dui ultricies, eget auctor ipsum placerat. Integer aliquet libero sed nisi eleifend, nec rutrum arcu lacinia. Sed a sem et ante gravida congue sit amet ut augue. Donec quis pellentesque urna, non finibus metus. Proin sed ornare tellus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam laoreet erat vel massa rutrum, eget mollis massa vulputate. Vivamus semper augue leo, eget faucibus nulla mattis nec. Donec scelerisque lacus at dui ultricies, eget auctor ipsum placerat. Integer aliquet libero sed nisi eleifend, nec rutrum arcu lacinia. Sed a sem et ante gravida congue sit amet ut augue. Donec quis pellentesque urna, non finibus metus. Proin sed ornare tellus."; var root = (Grid)XamlReader.Load(TestUtilities.ProcessTestXamlForRepo( @"<Grid xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:controls='using:Microsoft.UI.Xaml.Controls'> <Grid.Resources> <controls:StackLayout x:Name='VerticalStackLayout' /> <controls:RecyclingElementFactory x:Key='ElementFactory'> <controls:RecyclingElementFactory.RecyclePool> <controls:RecyclePool /> </controls:RecyclingElementFactory.RecyclePool> <DataTemplate x:Key='ItemTemplate'> <Border Background='LightGray' Margin ='5'> <TextBlock Text='{Binding}' TextWrapping='WrapWholeWords' /> </Border> </DataTemplate> </controls:RecyclingElementFactory> </Grid.Resources> <ScrollViewer x:Name='Scroller' Width='400' Height='600' Background='Gray'> <controls:ItemsRepeater x:Name='ItemsRepeater' ItemTemplate='{StaticResource ElementFactory}' Layout='{StaticResource VerticalStackLayout}' HorizontalCacheLength='0' VerticalCacheLength='0' /> </ScrollViewer> </Grid>")); var elementFactory = (RecyclingElementFactory)root.Resources["ElementFactory"]; scroller = (ScrollViewer)root.FindName("Scroller"); repeater = (ItemsRepeater)root.FindName("ItemsRepeater"); var items = Enumerable.Range(0, 400).Select(i => string.Format("{0}: {1}", i, lorem.Substring(0, 250))); repeater.ItemsSource = items; scroller.ViewChanged += (o, e) => { Log.Comment("ViewChanged: " + scroller.VerticalOffset); viewChangedOffsets.Add(scroller.VerticalOffset); if (!e.IsIntermediate) { viewChangeCompletedEvent.Set(); } }; scroller.EffectiveViewportChanged += (o, args) => { effectiveViewChangeCompletedEvent.Set(); }; Content = root; root.Loaded += delegate { rootLoadedEvent.Set(); }; }); Verify.IsTrue(rootLoadedEvent.WaitOne(DefaultWaitTimeInMS)); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { repeater.GetOrCreateElement(100).StartBringIntoView(); repeater.UpdateLayout(); }); Verify.IsTrue(viewChangeCompletedEvent.WaitOne(DefaultWaitTimeInMS)); IdleSynchronizer.Wait(); Verify.AreEqual(1, viewChangedOffsets.Count); viewChangedOffsets.Clear(); ValidateRealizedRange(repeater, 99, 106); RunOnUIThread.Execute(() => { Log.Comment("Scroll into view item 105 (already realized) w/ animation."); repeater.TryGetElement(105).StartBringIntoView(new BringIntoViewOptions { VerticalAlignmentRatio = 0.5, AnimationDesired = true }); repeater.UpdateLayout(); }); Verify.IsTrue(viewChangeCompletedEvent.WaitOne(DefaultWaitTimeInMS)); IdleSynchronizer.Wait(); Verify.IsLessThanOrEqual(1, viewChangedOffsets.Count); viewChangedOffsets.Clear(); ValidateRealizedRange(repeater, 101, 109); RunOnUIThread.Execute(() => { Log.Comment("Scroll item 0 to the top w/ animation and 0.5 vertical alignment."); repeater.GetOrCreateElement(0).StartBringIntoView(new BringIntoViewOptions { VerticalAlignmentRatio = 0.5, AnimationDesired = true }); repeater.UpdateLayout(); }); Verify.IsTrue(viewChangeCompletedEvent.WaitOne(DefaultWaitTimeInMS)); IdleSynchronizer.Wait(); viewChangedOffsets.Clear(); ValidateRealizedRange(repeater, 0, 6); RunOnUIThread.Execute(() => { // You can't align the first group in the middle obviously. Verify.AreEqual(0, scroller.VerticalOffset); Log.Comment("Scroll to item 20."); repeater.GetOrCreateElement(20).StartBringIntoView(new BringIntoViewOptions { VerticalAlignmentRatio = 0.0 }); repeater.UpdateLayout(); }); Verify.IsTrue(viewChangeCompletedEvent.WaitOne(DefaultWaitTimeInMS)); IdleSynchronizer.Wait(); ValidateRealizedRange(repeater, 19, 26); }
public void CanGrowCacheBufferWithScrollViewer() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) { Log.Warning("Skipping since version is less than RS5 and effective viewport is not available below RS5"); return; } ScrollViewer scroller = null; ItemsRepeater repeater = null; var measureRealizationRects = new List <Rect>(); var arrangeRealizationRects = new List <Rect>(); var fullCacheEvent = new ManualResetEvent(initialState: false); RunOnUIThread.Execute(() => { Log.Comment("Preparing the visual tree..."); scroller = new ScrollViewer { Width = 400, Height = 400 }; var layout = new MockVirtualizingLayout { MeasureLayoutFunc = (availableSize, context) => { var ctx = (VirtualizingLayoutContext)context; Log.Comment("MeasureLayout - Rect:" + ctx.RealizationRect); if (measureRealizationRects.Count == 0 || measureRealizationRects.Last() != ctx.RealizationRect) { measureRealizationRects.Add(ctx.RealizationRect); } return(new Size(1000, 2000)); }, ArrangeLayoutFunc = (finalSize, context) => { var ctx = (VirtualizingLayoutContext)context; Log.Comment("ArrangeLayout - Rect:" + ctx.RealizationRect); if (arrangeRealizationRects.Count == 0 || arrangeRealizationRects.Last() != ctx.RealizationRect) { arrangeRealizationRects.Add(ctx.RealizationRect); } if (ctx.RealizationRect.Height == scroller.Height * (repeater.VerticalCacheLength + 1)) { fullCacheEvent.Set(); } return(finalSize); } }; repeater = new ItemsRepeater() { Layout = layout }; scroller.Content = repeater; Content = scroller; }); if (!fullCacheEvent.WaitOne(DefaultWaitTimeInMS)) { Verify.Fail("Cache full size never reached."); } IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { var cacheLength = repeater.VerticalCacheLength; var expectedRealizationWindow = new Rect( -cacheLength / 2 * scroller.Width, -cacheLength / 2 * scroller.Height, (1 + cacheLength) * scroller.Width, (1 + cacheLength) * scroller.Height); Log.Comment("Validate that the realization window reached full size."); Verify.AreEqual(expectedRealizationWindow, measureRealizationRects.Last()); Verify.AreEqual(expectedRealizationWindow, arrangeRealizationRects.Last()); Log.Comment("Validate that the realization window grew by 40 pixels each time during the process."); for (int i = 2; i < measureRealizationRects.Count; ++i) { Verify.AreEqual(-40, measureRealizationRects[i].X - measureRealizationRects[i - 1].X); Verify.AreEqual(-40, measureRealizationRects[i].Y - measureRealizationRects[i - 1].Y); Verify.AreEqual(80, measureRealizationRects[i].Width - measureRealizationRects[i - 1].Width); Verify.AreEqual(80, measureRealizationRects[i].Height - measureRealizationRects[i - 1].Height); Verify.AreEqual(-40, arrangeRealizationRects[i].X - arrangeRealizationRects[i - 1].X); Verify.AreEqual(-40, arrangeRealizationRects[i].Y - arrangeRealizationRects[i - 1].Y); Verify.AreEqual(80, arrangeRealizationRects[i].Width - arrangeRealizationRects[i - 1].Width); Verify.AreEqual(80, arrangeRealizationRects[i].Height - arrangeRealizationRects[i - 1].Height); } }); }
public static void MinimizeWindow(Window window) { Verify.IsNotNull(window, "window"); _PostSystemCommand(window, SC.MINIMIZE); }
void VerifyFocusedIndex(int index) { Verify.AreEqual(index, Int32.Parse(elements.GetFocusedIndexTextBlock().DocumentText)); }
public VerifyWithUrl(Verify verify) : base("verify", verify) { }
public Log4NetParser(IRetrieveProcesses processRetriever, IHaveExtendedProperties extendedProperties) : base(processRetriever, "log4net", "http://logging.apache.org/log4j/") { Verify.NotNull(extendedProperties, "extendedProperties"); }
private void SetupDefaultUI( ScrollViewer scrollViewer, Rectangle rectangleScrollViewerContent = null, AutoResetEvent scrollViewerLoadedEvent = null, AutoResetEvent scrollViewerUnloadedEvent = null, bool setAsContentRoot = true, bool useParentGrid = false) { Log.Comment("Setting up default UI with ScrollViewer" + (rectangleScrollViewerContent == null ? "" : " and Rectangle")); LinearGradientBrush twoColorLGB = new LinearGradientBrush() { StartPoint = new Point(0, 0), EndPoint = new Point(1, 1) }; GradientStop brownGS = new GradientStop() { Color = Colors.Brown, Offset = 0.0 }; twoColorLGB.GradientStops.Add(brownGS); GradientStop orangeGS = new GradientStop() { Color = Colors.Orange, Offset = 1.0 }; twoColorLGB.GradientStops.Add(orangeGS); if (rectangleScrollViewerContent != null) { rectangleScrollViewerContent.Width = c_defaultUIScrollViewerContentWidth; rectangleScrollViewerContent.Height = c_defaultUIScrollViewerContentHeight; rectangleScrollViewerContent.Fill = twoColorLGB; } Verify.IsNotNull(scrollViewer); scrollViewer.Name = "scrollViewer"; scrollViewer.Width = c_defaultUIScrollViewerWidth; scrollViewer.Height = c_defaultUIScrollViewerHeight; if (rectangleScrollViewerContent != null) { scrollViewer.Content = rectangleScrollViewerContent; } if (scrollViewerLoadedEvent != null) { scrollViewer.Loaded += (object sender, RoutedEventArgs e) => { Log.Comment("ScrollViewer.Loaded event handler"); scrollViewerLoadedEvent.Set(); }; } if (scrollViewerUnloadedEvent != null) { scrollViewer.Unloaded += (object sender, RoutedEventArgs e) => { Log.Comment("ScrollViewer.Unloaded event handler"); scrollViewerUnloadedEvent.Set(); }; } Grid parentGrid = null; if (useParentGrid) { parentGrid = new Grid(); parentGrid.Width = c_defaultUIScrollViewerWidth * 3; parentGrid.Height = c_defaultUIScrollViewerHeight * 3; scrollViewer.HorizontalAlignment = HorizontalAlignment.Left; scrollViewer.VerticalAlignment = VerticalAlignment.Top; parentGrid.Children.Add(scrollViewer); } if (setAsContentRoot) { Log.Comment("Setting window content"); if (useParentGrid) { MUXControlsTestApp.App.TestContentRoot = parentGrid; } else { MUXControlsTestApp.App.TestContentRoot = scrollViewer; } } }
public void VerifyAnchorCandidateRegistration() { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2)) { Log.Warning("Test is disabled on pre-RS2 because ScrollViewer not supported pre-RS2"); return; } using (PrivateLoggingHelper privateSVLoggingHelper = new PrivateLoggingHelper("ScrollViewer", "Scroller")) { int expectedAnchorCandidatesCount = 0; Scroller scroller = null; ScrollViewer scrollViewer = null; Rectangle rectangleScrollViewerContent = null; AutoResetEvent scrollViewerLoadedEvent = new AutoResetEvent(false); AutoResetEvent scrollViewerAnchorRequestedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { rectangleScrollViewerContent = new Rectangle(); scrollViewer = new ScrollViewer(); scrollViewer.HorizontalAnchorRatio = 0.1; SetupDefaultUI(scrollViewer, rectangleScrollViewerContent, scrollViewerLoadedEvent); scrollViewer.AnchorRequested += (ScrollViewer sender, ScrollerAnchorRequestedEventArgs args) => { Log.Comment("ScrollViewer.AnchorRequested event handler. args.AnchorCandidates.Count: " + args.AnchorCandidates.Count); Verify.IsNull(args.AnchorElement); Verify.AreEqual(expectedAnchorCandidatesCount, args.AnchorCandidates.Count); scrollViewerAnchorRequestedEvent.Set(); }; }); WaitForEvent("Waiting for Loaded event", scrollViewerLoadedEvent); RunOnUIThread.Execute(() => { Log.Comment("Accessing inner Scroller control"); scroller = ScrollViewerTestHooks.GetScrollerPart(scrollViewer); Log.Comment("Registering Rectangle as anchor candidate"); scrollViewer.RegisterAnchorCandidate(rectangleScrollViewerContent); expectedAnchorCandidatesCount = 1; Log.Comment("Forcing Scroller layout"); scroller.InvalidateArrange(); }); WaitForEvent("Waiting for AnchorRequested event", scrollViewerAnchorRequestedEvent); RunOnUIThread.Execute(() => { Log.Comment("Unregistering Rectangle as anchor candidate"); scrollViewer.UnregisterAnchorCandidate(rectangleScrollViewerContent); expectedAnchorCandidatesCount = 0; Log.Comment("Forcing Scroller layout"); scroller.InvalidateArrange(); }); WaitForEvent("Waiting for AnchorRequested event", scrollViewerAnchorRequestedEvent); } }
void VerifyRadioButtonsHasFocus(bool hasFocus) { Verify.AreEqual(hasFocus, elements.GetRadioButtonsHasFocusCheckBox().ToggleState == ToggleState.On); }
/// <summary>Transforms input image into one or several destinations.</summary> /// <param name="jpegBuf">Pointer to a buffer containing the JPEG image to decompress. This buffer is not modified.</param> /// <param name="transforms">Array of transform descriptions to be applied to the source image. </param> /// <param name="flags">The bitwise OR of one or more of the <see cref="TJFlags"/> "flags".</param> /// <returns>Array of transformed jpeg images.</returns> /// <exception cref="ArgumentNullException"><paramref name="transforms"/> is <see langword="null" />.</exception> /// <exception cref="ArgumentException">Transforms can not be empty.</exception> /// <exception cref="TJException"> Throws if low level turbo jpeg function fails. </exception> public byte[][] Transform(Span <byte> jpegBuf, TJTransformDescription[] transforms, TJFlags flags) { Verify.NotDisposed(this); if (transforms == null) { throw new ArgumentNullException(nameof(transforms)); } if (transforms.Length == 0) { throw new ArgumentException("Transforms can not be empty", nameof(transforms)); } fixed(byte *jpegBufPtr = jpegBuf) { var count = transforms.Length; var destBufs = new IntPtr[count]; var destSizes = new uint[count]; int subsampl; int colorspace; int width; int height; var funcResult = TurboJpegImport.TjDecompressHeader( this.transformHandle, jpegBufPtr, (nuint)jpegBuf.Length, out width, out height, out subsampl, out colorspace); TJUtils.ThrowOnError(funcResult); Size mcuSize; if (!TurboJpegImport.MCUSizes.TryGetValue((TJSubsamplingOption)subsampl, out mcuSize)) { throw new TJException("Unable to read Subsampling Options from jpeg header"); } var tjTransforms = new TJTransform[count]; for (var i = 0; i < count; i++) { var x = CorrectRegionCoordinate(transforms[i].Region.X, mcuSize.Width); var y = CorrectRegionCoordinate(transforms[i].Region.Y, mcuSize.Height); var w = CorrectRegionSize(transforms[i].Region.X, x, transforms[i].Region.W, width); var h = CorrectRegionSize(transforms[i].Region.Y, y, transforms[i].Region.H, height); tjTransforms[i] = new TJTransform { Op = (int)transforms[i].Operation, Options = (int)transforms[i].Options, R = new TJRegion { X = x, Y = y, W = w, H = h, }, Data = transforms[i].CallbackData, CustomFilter = transforms[i].CustomFilter, }; } var transformsPtr = TJUtils.StructArrayToIntPtr(tjTransforms); try { funcResult = TurboJpegImport.TjTransform( this.transformHandle, jpegBufPtr, (nuint)jpegBuf.Length, count, destBufs, destSizes, transformsPtr, (int)flags); TJUtils.ThrowOnError(funcResult); var result = new List <byte[]>(); for (var i = 0; i < destBufs.Length; i++) { var ptr = destBufs[i]; var size = destSizes[i]; var item = new byte[size]; Marshal.Copy(ptr, item, 0, (int)size); result.Add(item); TurboJpegImport.TjFree(ptr); } return(result.ToArray()); } finally { TJUtils.FreePtr(transformsPtr); } } }
private void SetupUIWithBiDirectionalScrollController( ScrollPresenter scrollPresenter, Rectangle rectangleScrollPresenterContent, BiDirectionalScrollController biDirectionalScrollController, AutoResetEvent loadedEvent) { Log.Comment("Setting up UI with ScrollPresenter and bi-directional scroll controller" + (rectangleScrollPresenterContent == null ? "" : " and Rectangle")); LinearGradientBrush twoColorLGB = new LinearGradientBrush() { StartPoint = new Point(0, 0), EndPoint = new Point(1, 1) }; GradientStop brownGS = new GradientStop() { Color = Colors.Brown, Offset = 0.0 }; twoColorLGB.GradientStops.Add(brownGS); GradientStop orangeGS = new GradientStop() { Color = Colors.Orange, Offset = 1.0 }; twoColorLGB.GradientStops.Add(orangeGS); if (rectangleScrollPresenterContent != null) { rectangleScrollPresenterContent.Width = c_defaultUIScrollPresenterContentWidth; rectangleScrollPresenterContent.Height = c_defaultUIScrollPresenterContentHeight; rectangleScrollPresenterContent.Fill = twoColorLGB; } Verify.IsNotNull(scrollPresenter); scrollPresenter.Width = c_defaultUIScrollPresenterWidth; scrollPresenter.Height = c_defaultUIScrollPresenterHeight; if (rectangleScrollPresenterContent != null) { scrollPresenter.Content = rectangleScrollPresenterContent; } biDirectionalScrollController.Width = c_defaultUIScrollPresenterHeight; biDirectionalScrollController.Height = c_defaultUIScrollPresenterHeight; StackPanel horizontalStackPanel = new StackPanel(); horizontalStackPanel.Orientation = Orientation.Horizontal; horizontalStackPanel.Children.Add(scrollPresenter); horizontalStackPanel.Children.Add(biDirectionalScrollController); if (loadedEvent != null) { horizontalStackPanel.Loaded += (object sender, RoutedEventArgs e) => { Log.Comment("Loaded event handler"); loadedEvent.Set(); }; } Log.Comment("Setting window content"); Content = horizontalStackPanel; }
public void ValidateBasicScrollViewerScenario() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) { Log.Warning("Skipping since version is less than RS5 and effective viewport is not available below RS5"); return; } var realizationRects = new List <Rect>(); var viewChangeCompletedEvent = new AutoResetEvent(false); ScrollViewer scrollViewer = null; ManualResetEvent viewChanged = new ManualResetEvent(false); ManualResetEvent layoutMeasured = new ManualResetEvent(false); RunOnUIThread.Execute(() => { var repeater = new ItemsRepeater() { Layout = GetMonitoringLayout(new Size(500, 600), realizationRects, layoutMeasured), HorizontalCacheLength = 0.0, VerticalCacheLength = 0.0 }; scrollViewer = new ScrollViewer { Content = repeater, Width = 200, Height = 300, HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden, VerticalScrollBarVisibility = ScrollBarVisibility.Hidden, }; scrollViewer.ViewChanged += (sender, args) => { if (!args.IsIntermediate) { Log.Comment("ViewChanged " + scrollViewer.HorizontalOffset + ":" + scrollViewer.VerticalOffset); viewChanged.Set(); } }; Content = scrollViewer; }); Verify.IsTrue(layoutMeasured.WaitOne(), "Did not receive measure on layout"); RunOnUIThread.Execute(() => { // First layout pass will invalidate measure during the first arrange // so that we can get a viewport during the second measure/arrange pass. Verify.AreEqual(new Rect(0, 0, 0, 0), realizationRects[0]); Verify.AreEqual(new Rect(0, 0, 200, 300), realizationRects[1]); realizationRects.Clear(); viewChanged.Reset(); layoutMeasured.Reset(); scrollViewer.ChangeView(null, 100.0, 1.0f, disableAnimation: true); }); IdleSynchronizer.Wait(); Verify.IsTrue(viewChanged.WaitOne(), "Did not receive view changed event"); Verify.IsTrue(layoutMeasured.WaitOne(), "Did not receive measure on layout"); viewChanged.Reset(); layoutMeasured.Reset(); RunOnUIThread.Execute(() => { Verify.AreEqual(new Rect(0, 100, 200, 300), realizationRects.Last()); realizationRects.Clear(); viewChangeCompletedEvent.Reset(); // Max viewport offset is (300, 400). Horizontal viewport offset // is expected to get coerced from 400 to 300. scrollViewer.ChangeView(400, 100.0, 1.0f, disableAnimation: true); }); IdleSynchronizer.Wait(); Verify.IsTrue(viewChanged.WaitOne(), "Did not receive view changed event"); Verify.IsTrue(layoutMeasured.WaitOne(), "Did not receive measure on layout"); viewChanged.Reset(); layoutMeasured.Reset(); RunOnUIThread.Execute(() => { Verify.AreEqual(new Rect(300, 100, 200, 300), realizationRects.Last()); realizationRects.Clear(); viewChangeCompletedEvent.Reset(); scrollViewer.ChangeView(null, null, 2.0f, disableAnimation: true); }); IdleSynchronizer.Wait(); Verify.IsTrue(viewChanged.WaitOne(), "Did not receive view changed event"); Verify.IsTrue(layoutMeasured.WaitOne(), "Did not receive measure on layout"); viewChanged.Reset(); layoutMeasured.Reset(); RunOnUIThread.Execute(() => { Verify.AreEqual(new Rect(150, 50, 100, 150), realizationRects.Last()); realizationRects.Clear(); }); }
private void NestedRepeaterWithDataTemplateScenario(bool disableAnimation) { if (!disableAnimation && PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) { Log.Warning("This test is showing consistent issues with not scrolling enough on RS5 and 19H1 when animations are enabled, tracked by microsoft-ui-xaml#779"); return; } // Example of how to include debug tracing in an ApiTests.ItemsRepeater test's output. // using (PrivateLoggingHelper privateLoggingHelper = new PrivateLoggingHelper("Repeater")) // { ItemsRepeater rootRepeater = null; ScrollViewer scrollViewer = null; ManualResetEvent viewChanged = new ManualResetEvent(false); RunOnUIThread.Execute(() => { var anchorProvider = (ItemsRepeaterScrollHost)XamlReader.Load( @"<controls:ItemsRepeaterScrollHost Width='400' Height='600' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:controls='using:Microsoft.UI.Xaml.Controls'> <controls:ItemsRepeaterScrollHost.Resources> <DataTemplate x:Key='ItemTemplate' > <TextBlock Text='{Binding}' /> </DataTemplate> <DataTemplate x:Key='GroupTemplate'> <StackPanel> <TextBlock Text='{Binding}' /> <controls:ItemsRepeater ItemTemplate='{StaticResource ItemTemplate}' ItemsSource='{Binding}' VerticalCacheLength='0'/> </StackPanel> </DataTemplate> </controls:ItemsRepeaterScrollHost.Resources> <ScrollViewer x:Name='scrollviewer'> <controls:ItemsRepeater x:Name='rootRepeater' ItemTemplate='{StaticResource GroupTemplate}' VerticalCacheLength='0' /> </ScrollViewer> </controls:ItemsRepeaterScrollHost>"); rootRepeater = (ItemsRepeater)anchorProvider.FindName("rootRepeater"); rootRepeater.SizeChanged += (sender, args) => { Log.Comment($"SizeChanged: Size=({rootRepeater.ActualWidth} x {rootRepeater.ActualHeight})"); }; scrollViewer = (ScrollViewer)anchorProvider.FindName("scrollviewer"); scrollViewer.ViewChanging += (sender, args) => { Log.Comment($"ViewChanging: Next VerticalOffset={args.NextView.VerticalOffset}, Final VerticalOffset={args.FinalView.VerticalOffset}"); }; scrollViewer.ViewChanged += (sender, args) => { Log.Comment($"ViewChanged: VerticalOffset={scrollViewer.VerticalOffset}, IsIntermediate={args.IsIntermediate}"); if (!args.IsIntermediate) { viewChanged.Set(); } }; var itemsSource = new ObservableCollection <ObservableCollection <int> >(); for (int i = 0; i < 100; i++) { itemsSource.Add(new ObservableCollection <int>(Enumerable.Range(0, 5))); } ; rootRepeater.ItemsSource = itemsSource; Content = anchorProvider; }); // scroll down several times to cause recycling of elements for (int i = 1; i < 10; i++) { IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { Log.Comment($"Size=({rootRepeater.ActualWidth} x {rootRepeater.ActualHeight})"); Log.Comment($"ChangeView(VerticalOffset={i * 200})"); scrollViewer.ChangeView(null, i * 200, null, disableAnimation); }); Log.Comment("Waiting for view change completion..."); Verify.IsTrue(viewChanged.WaitOne(DefaultWaitTimeInMS)); viewChanged.Reset(); Log.Comment("View change completed"); RunOnUIThread.Execute(() => { Verify.AreEqual(i * 200, scrollViewer.VerticalOffset); }); } // } }
public void ValidateTabNavigation() { if (!PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone2)) { Log.Warning("Test is disabled on anything lower than RS3 because the GetChildrenInTabFocusOrder API is not available on previous versions."); return; } ItemsRepeater repeater = null; ScrollViewer scrollViewer = null; var data = new ObservableCollection <string>(Enumerable.Range(0, 50).Select(i => "Item #" + i)); var viewChangedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { var itemTemplate = (DataTemplate)XamlReader.Load( @"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> <Button Content='{Binding}' Height='100' /> </DataTemplate>"); var elementFactory = new RecyclingElementFactory() { RecyclePool = new RecyclePool(), Templates = { { "itemTemplate", itemTemplate }, } }; Content = CreateAndInitializeRepeater ( data, new StackLayout(), elementFactory, ref repeater, ref scrollViewer ); scrollViewer.ViewChanged += (s, e) => { if (!e.IsIntermediate) { viewChangedEvent.Set(); } }; repeater.TabFocusNavigation = KeyboardNavigationMode.Local; Content.UpdateLayout(); ValidateTabNavigationOrder(repeater); }); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { // Move window - disconnected scrollViewer.ChangeView(null, 2000, null, true); }); Verify.IsTrue(viewChangedEvent.WaitOne(DefaultWaitTimeInMS), "Waiting for final ViewChanged event."); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { ValidateTabNavigationOrder(repeater); // Delete a couple of elements and validate we // ignore unrealized elements. // First visible element is expected to be index 20. while (data.Count > 21) { data.RemoveAt(21); } repeater.UpdateLayout(); ValidateTabNavigationOrder(repeater); }); }
public static void CloseWindow(Window window) { Verify.IsNotNull(window, "window"); _PostSystemCommand(window, SC.CLOSE); }
public void ValidateTwoScrollViewerScenario() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) { Log.Warning("Skipping since version is less than RS5 and effective viewport is not available below RS5"); return; } var realizationRects = new List <Rect>(); ScrollViewer horizontalScroller = null; ScrollViewer verticalScroller = null; var horizontalViewChangeCompletedEvent = new AutoResetEvent(false); var verticalViewChangeCompletedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { var repeater = new ItemsRepeater() { Layout = GetMonitoringLayout(new Size(500, 500), realizationRects), HorizontalCacheLength = 0.0, VerticalCacheLength = 0.0 }; horizontalScroller = new ScrollViewer { Content = repeater, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto, VerticalScrollBarVisibility = ScrollBarVisibility.Disabled, HorizontalScrollMode = ScrollMode.Enabled, VerticalScrollMode = ScrollMode.Disabled }; verticalScroller = new ScrollViewer { Content = horizontalScroller, Width = 200, Height = 200 }; Content = verticalScroller; Content.UpdateLayout(); Verify.AreEqual(2, realizationRects.Count); Verify.AreEqual(new Rect(0, 0, 0, 0), realizationRects[0]); Verify.AreEqual(new Rect(0, 0, 200, 200), realizationRects[1]); realizationRects.Clear(); horizontalScroller.ViewChanged += (Object sender, ScrollViewerViewChangedEventArgs args) => { if (!args.IsIntermediate) { horizontalViewChangeCompletedEvent.Set(); } }; verticalScroller.ViewChanged += (Object sender, ScrollViewerViewChangedEventArgs args) => { if (!args.IsIntermediate) { verticalViewChangeCompletedEvent.Set(); } }; }); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { verticalScroller.ChangeView(0.0, 100.0, null, true); }); Verify.IsTrue(verticalViewChangeCompletedEvent.WaitOne(DefaultWaitTimeInMS)); RunOnUIThread.Execute(() => { Verify.AreEqual(new Rect(0, 100, 200, 200), realizationRects.Last()); realizationRects.Clear(); // Max viewport offset is (300, 300). Horizontal viewport offset // is expected to get coerced from 400 to 300. horizontalScroller.ChangeView(400.0, 100.0, null, true); }); Verify.IsTrue(horizontalViewChangeCompletedEvent.WaitOne(DefaultWaitTimeInMS)); RunOnUIThread.Execute(() => { Verify.AreEqual(new Rect(300, 100, 200, 200), realizationRects.Last()); realizationRects.Clear(); }); }
private static IEnumerable <XElement> GetSitemapByScopeUnannotated(SitemapScope associationScope, Guid pageId) { if (associationScope == SitemapScope.All) { foreach (XElement homepage in GetSiteMap()) { yield return(new XElement(homepage)); } yield break; } Verify.ArgumentCondition(pageId != Guid.Empty, "pageId", "The parameter is Guid.Empty"); XElement currentPageElement = PageStructureInfo.GetSiteMap().DescendantsAndSelf().FirstOrDefault(f => f.Attribute("Id").Value == pageId.ToString()); // finde dybden - hvis scope dybden == nuværende dybde + 1, så skift nuværende til first child if (currentPageElement == null) { throw new ArgumentException("No page with the given ID could be located in the current data scope ('{0}').".FormatWith(pageId), "pageId"); } XElement pageCopy = null; switch (associationScope) { case SitemapScope.Current: yield return(new XElement(currentPageElement.Name, currentPageElement.Attributes())); break; case SitemapScope.Parent: if (currentPageElement.Parent != null && currentPageElement.Parent.Name == PageElementName) { yield return(new XElement(currentPageElement.Parent.Name, currentPageElement.Parent.Attributes())); } break; case SitemapScope.Descendants: foreach (XElement child in currentPageElement.Elements(PageElementName)) { yield return(new XElement(child)); } break; case SitemapScope.DescendantsAndCurrent: yield return(new XElement(currentPageElement)); break; case SitemapScope.Children: foreach (XElement page in currentPageElement.Elements(PageElementName)) { yield return(new XElement(page.Name, page.Attributes())); } break; case SitemapScope.Siblings: foreach (XElement page in currentPageElement.Parent.Elements(PageElementName)) { yield return(new XElement(page.Name, page.Attributes())); } break; case SitemapScope.Ancestors: foreach (XElement page in currentPageElement.Ancestors(PageElementName)) { pageCopy = new XElement(page.Name, page.Attributes(), pageCopy); } yield return(pageCopy); break; case SitemapScope.AncestorsAndCurrent: foreach (XElement page in currentPageElement.AncestorsAndSelf(PageElementName)) { pageCopy = new XElement(page.Name, page.Attributes(), pageCopy); } yield return(pageCopy); break; case SitemapScope.Level1: pageCopy = GetPageCopyBySiteDepth(currentPageElement, 1, true); if (pageCopy != null) { yield return(pageCopy); } break; case SitemapScope.Level2: pageCopy = GetPageCopyBySiteDepth(currentPageElement, 2, true); if (pageCopy != null) { yield return(pageCopy); } break; case SitemapScope.Level3: pageCopy = GetPageCopyBySiteDepth(currentPageElement, 3, true); if (pageCopy != null) { yield return(pageCopy); } break; case SitemapScope.Level4: pageCopy = GetPageCopyBySiteDepth(currentPageElement, 4, true); if (pageCopy != null) { yield return(pageCopy); } break; case SitemapScope.Level1AndSiblings: foreach (XElement page in PageStructureInfo.GetSiteMap()) { yield return(new XElement(page.Name, page.Attributes())); } break; case SitemapScope.Level2AndSiblings: foreach (XElement page in GetSiblingsCopyBySiteDepth(currentPageElement, 2)) { yield return(page); } break; case SitemapScope.Level3AndSiblings: foreach (XElement page in GetSiblingsCopyBySiteDepth(currentPageElement, 3)) { yield return(page); } break; case SitemapScope.Level4AndSiblings: foreach (XElement page in GetSiblingsCopyBySiteDepth(currentPageElement, 4)) { yield return(page); } break; case SitemapScope.Level1AndDescendants: pageCopy = GetPageCopyBySiteDepth(currentPageElement, 1, false); if (pageCopy != null) { yield return(pageCopy); } break; case SitemapScope.Level2AndDescendants: pageCopy = GetPageCopyBySiteDepth(currentPageElement, 2, false); if (pageCopy != null) { yield return(pageCopy); } break; case SitemapScope.Level3AndDescendants: pageCopy = GetPageCopyBySiteDepth(currentPageElement, 3, false); if (pageCopy != null) { yield return(pageCopy); } break; case SitemapScope.Level4AndDescendants: pageCopy = GetPageCopyBySiteDepth(currentPageElement, 4, false); if (pageCopy != null) { yield return(pageCopy); } break; default: throw new NotImplementedException("Unhandled SitemapScope type: " + associationScope); } }
public void Update(IEnumerable <IData> dataset) { Verify.ArgumentNotNull(dataset, "dataset"); CheckTransactionNotInAbortedState(); using (XmlDataProviderDocumentCache.CreateEditingContext()) { var validatedFileRecords = new Dictionary <DataSourceId, FileRecord>(); var validatedElements = new Dictionary <DataSourceId, XElement>(); // verify phase foreach (IData wrappedData in dataset) { var data = DataWrappingFacade.UnWrap(wrappedData); Verify.ArgumentCondition(data != null, "dataset", "Collection contains a null element."); Verify.ArgumentCondition(data.DataSourceId != null, "dataset", "Collection contains a data item with DataSourceId null property."); ValidationHelper.Validate(data); XmlDataTypeStore dataTypeStore = _xmlDataTypeStoresContainer.GetDataTypeStore(data.DataSourceId.InterfaceType); var dataScope = data.DataSourceId.DataScopeIdentifier; var culture = data.DataSourceId.LocaleScope; var type = data.DataSourceId.InterfaceType; var dataTypeStoreScope = dataTypeStore.GetDataScope(dataScope, culture, type); dataTypeStore.Helper.ValidateDataType(data); if (null == data.DataSourceId) { throw new ArgumentException("The DataSourceId property of the data argument must not be null", "data"); } if (data.DataSourceId.ProviderName != _dataProviderContext.ProviderName) { throw new ArgumentException("The data element does not belong to this provider", "data"); } var fileRecord = GetFileRecord(dataTypeStore, dataTypeStoreScope); var index = fileRecord.RecordSet.Index; IDataId dataId = data.DataSourceId.DataId; XElement element = index[dataId]; if (element == null) { throw new ArgumentException($"Cannot update a data item, no data element corresponds to the given data id: '{dataId.Serialize(null)}'; Type: '{type}'; DataScope: '{dataScope}'; Culture: '{culture}'", nameof(dataset)); } IXElementWrapper wrapper = data as IXElementWrapper; Verify.ArgumentCondition(wrapper != null, nameof(dataset), $"The type of data was expected to be of type {typeof(IXElementWrapper)}"); XElement updatedElement = CreateUpdatedXElement(wrapper, element); validatedFileRecords.Add(data.DataSourceId, fileRecord); validatedElements.Add(data.DataSourceId, updatedElement); } foreach (var key in validatedElements.Keys) { FileRecord fileRecord = validatedFileRecords[key]; fileRecord.Dirty = true; fileRecord.RecordSet.Index[key.DataId] = validatedElements[key]; } XmlDataProviderDocumentCache.SaveChanges(); SubscribeToTransactionRollbackEvent(); } }
public void ChangeOffsetsWithAttachedBiDirectionalScrollController() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2)) { Log.Comment("Skipping failing test on RS1."); return; } ScrollPresenter scrollPresenter = null; Rectangle rectangleScrollPresenterContent = null; BiDirectionalScrollController biDirectionalScrollController = null; AutoResetEvent loadedEvent = new AutoResetEvent(false); AutoResetEvent scrollCompletedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { // We need the styles of the CompositionScrollController, so let's load them App.AppendResourceDictionaryToMergedDictionaries(App.AdditionStylesXaml); rectangleScrollPresenterContent = new Rectangle(); scrollPresenter = new ScrollPresenter(); biDirectionalScrollController = new BiDirectionalScrollController(); biDirectionalScrollController.LogMessage += (BiDirectionalScrollController sender, string args) => { Log.Comment(args); }; scrollPresenter.HorizontalScrollController = biDirectionalScrollController.HorizontalScrollController; scrollPresenter.VerticalScrollController = biDirectionalScrollController.VerticalScrollController; SetupUIWithBiDirectionalScrollController( scrollPresenter, rectangleScrollPresenterContent, biDirectionalScrollController, loadedEvent); biDirectionalScrollController.ScrollCompleted += (BiDirectionalScrollController sender, BiDirectionalScrollControllerScrollingScrollCompletedEventArgs args) => { Log.Comment("ChangeOffset completed. OffsetsChangeCorrelationId=" + args); Log.Comment("Setting completion event"); scrollCompletedEvent.Set(); }; }); WaitForEvent("Waiting for Loaded event", loadedEvent); RunOnUIThread.Execute(() => { Log.Comment("BiDirectionalScrollController size={0}, {1}", biDirectionalScrollController.ActualWidth, biDirectionalScrollController.ActualHeight); }); Log.Comment("Jump to zoomFactor 0.75"); ZoomTo( scrollPresenter, 0.75f, 0.0f, 0.0f, ScrollingAnimationMode.Disabled, ScrollingSnapPointsMode.Ignore); RunOnUIThread.Execute(() => { Log.Comment("Jumping to offsets"); biDirectionalScrollController.ScrollTo( (c_defaultUIScrollPresenterContentWidth * 0.75 - c_defaultUIScrollPresenterWidth) / 4.0, (c_defaultUIScrollPresenterContentHeight * 0.75 - c_defaultUIScrollPresenterHeight) / 4.0, ScrollingAnimationMode.Disabled); }); WaitForEvent("Waiting for operation completion", scrollCompletedEvent); RunOnUIThread.Execute(() => { Verify.AreEqual((c_defaultUIScrollPresenterContentWidth * 0.75 - c_defaultUIScrollPresenterWidth) / 4.0, scrollPresenter.HorizontalOffset); Verify.AreEqual((c_defaultUIScrollPresenterContentHeight * 0.75 - c_defaultUIScrollPresenterHeight) / 4.0, scrollPresenter.VerticalOffset); Log.Comment("Animating to offsets"); biDirectionalScrollController.ScrollTo( (c_defaultUIScrollPresenterContentWidth * 0.75 - c_defaultUIScrollPresenterWidth) / 2.0, (c_defaultUIScrollPresenterContentHeight * 0.75 - c_defaultUIScrollPresenterHeight) / 2.0, ScrollingAnimationMode.Enabled); scrollCompletedEvent.Reset(); }); WaitForEvent("Waiting for operation completion", scrollCompletedEvent); RunOnUIThread.Execute(() => { Verify.AreEqual((c_defaultUIScrollPresenterContentWidth * 0.75 - c_defaultUIScrollPresenterWidth) / 2.0, scrollPresenter.HorizontalOffset); Verify.AreEqual((c_defaultUIScrollPresenterContentHeight * 0.75 - c_defaultUIScrollPresenterHeight) / 2.0, scrollPresenter.VerticalOffset); }); }
public void VerifyStoreScenarioCache() { ItemsRepeater rootRepeater = null; RunOnUIThread.Execute(() => { var scrollhost = (ItemsRepeaterScrollHost)XamlReader.Load( @" <controls:ItemsRepeaterScrollHost Width='400' Height='200' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:controls='using:Microsoft.UI.Xaml.Controls'> <controls:ItemsRepeaterScrollHost.Resources> <DataTemplate x:Key='ItemTemplate' > <TextBlock Text='{Binding}' Height='100' Width='100'/> </DataTemplate> <DataTemplate x:Key='GroupTemplate'> <StackPanel> <TextBlock Text='{Binding}' /> <controls:ItemsRepeaterScrollHost> <ScrollViewer HorizontalScrollMode='Enabled' VerticalScrollMode='Disabled' HorizontalScrollBarVisibility='Auto' VerticalScrollBarVisibility='Hidden'> <controls:ItemsRepeater ItemTemplate='{StaticResource ItemTemplate}' ItemsSource='{Binding}'> <controls:ItemsRepeater.Layout> <controls:StackLayout Orientation='Horizontal' /> </controls:ItemsRepeater.Layout> </controls:ItemsRepeater> </ScrollViewer> </controls:ItemsRepeaterScrollHost> </StackPanel> </DataTemplate> </controls:ItemsRepeaterScrollHost.Resources> <ScrollViewer x:Name='scrollviewer'> <controls:ItemsRepeater x:Name='rootRepeater' ItemTemplate='{StaticResource GroupTemplate}'/> </ScrollViewer> </controls:ItemsRepeaterScrollHost>"); rootRepeater = (ItemsRepeater)scrollhost.FindName("rootRepeater"); List <List <int> > items = new List <List <int> >(); for (int i = 0; i < 100; i++) { items.Add(Enumerable.Range(0, 4).ToList()); } rootRepeater.ItemsSource = items; Content = scrollhost; }); IdleSynchronizer.Wait(); // Verify that first items outside the visible range but in the realized range // for the inner of the nested repeaters are realized. RunOnUIThread.Execute(() => { // Group2 will be outside the visible range but within the realized range. var group2 = rootRepeater.TryGetElement(2) as StackPanel; Verify.IsNotNull(group2); var group2Repeater = ((ItemsRepeaterScrollHost)group2.Children[1]).ScrollViewer.Content as ItemsRepeater; Verify.IsNotNull(group2Repeater); Verify.IsNotNull(group2Repeater.TryGetElement(0)); }); }
public void VerifyCorrectionsInNonScrollableDirection() { ItemsRepeater rootRepeater = null; ScrollViewer scrollViewer = null; ItemsRepeaterScrollHost scrollhost = null; ManualResetEvent viewChanged = new ManualResetEvent(false); RunOnUIThread.Execute(() => { scrollhost = (ItemsRepeaterScrollHost)XamlReader.Load( @"<controls:ItemsRepeaterScrollHost Width='400' Height='600' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:controls='using:Microsoft.UI.Xaml.Controls'> <ScrollViewer Width='400' Height='400' x:Name='scrollviewer'> <controls:ItemsRepeater x:Name='repeater'> <DataTemplate> <StackPanel> <controls:ItemsRepeater ItemsSource='{Binding}'> <controls:ItemsRepeater.Layout> <controls:StackLayout Orientation='Horizontal' /> </controls:ItemsRepeater.Layout> </controls:ItemsRepeater> </StackPanel> </DataTemplate> </controls:ItemsRepeater> </ScrollViewer> </controls:ItemsRepeaterScrollHost>"); rootRepeater = (ItemsRepeater)scrollhost.FindName("repeater"); scrollViewer = (ScrollViewer)scrollhost.FindName("scrollviewer"); scrollViewer.ViewChanged += (sender, args) => { if (!args.IsIntermediate) { viewChanged.Set(); } }; List <List <int> > items = new List <List <int> >(); for (int i = 0; i < 100; i++) { items.Add(Enumerable.Range(0, 4).ToList()); } rootRepeater.ItemsSource = items; Content = scrollhost; }); // scroll down several times and validate no crash for (int i = 1; i < 5; i++) { IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { scrollViewer.ChangeView(null, i * 200, null); }); Verify.IsTrue(viewChanged.WaitOne(DefaultWaitTimeInMS)); viewChanged.Reset(); } }
public static void RestoreWindow(Window window) { Verify.IsNotNull(window, "window"); _PostSystemCommand(window, SC.RESTORE); }
public void ChangeOffsetsWithAdditionalVelocityAndAttachedBiDirectionalScrollController() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2)) { Log.Comment("Skipping failing test on RS1."); return; } ScrollPresenter scrollPresenter = null; Rectangle rectangleScrollPresenterContent = null; BiDirectionalScrollController biDirectionalScrollController = null; AutoResetEvent loadedEvent = new AutoResetEvent(false); AutoResetEvent scrollCompletedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { // We need the styles of the CompositionScrollController, so let's load them App.AppendResourceDictionaryToMergedDictionaries(App.AdditionStylesXaml); rectangleScrollPresenterContent = new Rectangle(); scrollPresenter = new ScrollPresenter(); biDirectionalScrollController = new BiDirectionalScrollController(); biDirectionalScrollController.LogMessage += (BiDirectionalScrollController sender, string args) => { Log.Comment(args); }; scrollPresenter.HorizontalScrollController = biDirectionalScrollController.HorizontalScrollController; scrollPresenter.VerticalScrollController = biDirectionalScrollController.VerticalScrollController; SetupUIWithBiDirectionalScrollController( scrollPresenter, rectangleScrollPresenterContent, biDirectionalScrollController, loadedEvent); biDirectionalScrollController.ScrollCompleted += (BiDirectionalScrollController sender, BiDirectionalScrollControllerScrollingScrollCompletedEventArgs args) => { Log.Comment("AddScrollVelocity completed. OffsetsChangeCorrelationId=" + args); Log.Comment("Setting completion event"); scrollCompletedEvent.Set(); }; }); WaitForEvent("Waiting for Loaded event", loadedEvent); RunOnUIThread.Execute(() => { Log.Comment("BiDirectionalScrollController size={0}, {1}", biDirectionalScrollController.ActualWidth, biDirectionalScrollController.ActualHeight); }); Log.Comment("Jump to zoomFactor 0.75"); ZoomTo( scrollPresenter, 0.75f, 0.0f, 0.0f, ScrollingAnimationMode.Disabled, ScrollingSnapPointsMode.Ignore); RunOnUIThread.Execute(() => { Log.Comment("Adding velocity to offsets, with default inertia decay rates"); biDirectionalScrollController.AddScrollVelocity( new Vector2(100.0f) /*offsetsVelocity*/, null /*inertiaDecayRate*/); }); WaitForEvent("Waiting for operation completion", scrollCompletedEvent); RunOnUIThread.Execute(() => { Log.Comment("scrollPresenter.HorizontalOffset={0}", scrollPresenter.HorizontalOffset); Log.Comment("scrollPresenter.VerticalOffset={0}", scrollPresenter.VerticalOffset); Verify.IsTrue(scrollPresenter.HorizontalOffset > 20.0); Verify.IsTrue(scrollPresenter.VerticalOffset > 20.0); Log.Comment("Adding negative velocity to offsets, with custom inertia decay rates"); biDirectionalScrollController.AddScrollVelocity( new Vector2(-50.0f) /*offsetsVelocity*/, new Vector2(0.9f) /*inertiaDecayRate*/); scrollCompletedEvent.Reset(); }); WaitForEvent("Waiting for operation completion", scrollCompletedEvent); RunOnUIThread.Execute(() => { Log.Comment("scrollPresenter.HorizontalOffset={0}", scrollPresenter.HorizontalOffset); Log.Comment("scrollPresenter.VerticalOffset={0}", scrollPresenter.VerticalOffset); Verify.IsTrue(scrollPresenter.HorizontalOffset < 20.0); Verify.IsTrue(scrollPresenter.VerticalOffset < 20.0); Log.Comment("Adding velocity to offsets, with no inertia decay rates"); biDirectionalScrollController.AddScrollVelocity( new Vector2(200.0f) /*offsetsVelocity*/, new Vector2(0.0f) /*inertiaDecayRate*/); scrollCompletedEvent.Reset(); }); WaitForEvent("Waiting for operation completion", scrollCompletedEvent); RunOnUIThread.Execute(() => { Log.Comment("scrollPresenter.HorizontalOffset={0}", scrollPresenter.HorizontalOffset); Log.Comment("scrollPresenter.VerticalOffset={0}", scrollPresenter.VerticalOffset); Verify.AreEqual(600.0, scrollPresenter.HorizontalOffset); Verify.AreEqual(250.0, scrollPresenter.VerticalOffset); }); }
/// <summary>Display the system menu at a specified location.</summary> /// <param name="screenLocation">The location to display the system menu, in logical screen coordinates.</param> public static void ShowSystemMenu(Window window, Point screenLocation) { Verify.IsNotNull(window, "window"); ShowSystemMenuPhysicalCoordinates(window, DpiHelper.LogicalPixelsToDevice(screenLocation)); }
public void VerifyScrollerAttachedProperties() { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2)) { Log.Warning("Test is disabled on pre-RS2 because ScrollViewer not supported pre-RS2"); return; } using (PrivateLoggingHelper privateSVLoggingHelper = new PrivateLoggingHelper("ScrollViewer", "Scroller")) { ScrollViewer scrollViewer = null; Rectangle rectangleScrollViewerContent = null; AutoResetEvent scrollViewerLoadedEvent = new AutoResetEvent(false); AutoResetEvent scrollViewerUnloadedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { rectangleScrollViewerContent = new Rectangle(); scrollViewer = new ScrollViewer(); SetupDefaultUI(scrollViewer, rectangleScrollViewerContent, scrollViewerLoadedEvent, scrollViewerUnloadedEvent); }); WaitForEvent("Waiting for Loaded event", scrollViewerLoadedEvent); RunOnUIThread.Execute(() => { Log.Comment("Setting Scroller-cloned properties to non-default values"); scrollViewer.IgnoredInputKind = InputKind.MouseWheel | InputKind.Pen; scrollViewer.ContentOrientation = ContentOrientation.Horizontal; scrollViewer.HorizontalScrollChainingMode = ChainingMode.Always; scrollViewer.VerticalScrollChainingMode = ChainingMode.Never; scrollViewer.HorizontalScrollRailingMode = RailingMode.Disabled; scrollViewer.VerticalScrollRailingMode = RailingMode.Disabled; scrollViewer.HorizontalScrollMode = ScrollMode.Enabled; scrollViewer.VerticalScrollMode = ScrollMode.Disabled; scrollViewer.ZoomMode = ZoomMode.Enabled; scrollViewer.ZoomChainingMode = ChainingMode.Never; scrollViewer.MinZoomFactor = 2.0; scrollViewer.MaxZoomFactor = 8.0; Log.Comment("Verifying Scroller-cloned non-default properties"); Verify.AreEqual(scrollViewer.IgnoredInputKind, InputKind.MouseWheel | InputKind.Pen); Verify.AreEqual(scrollViewer.ContentOrientation, ContentOrientation.Horizontal); Verify.AreEqual(scrollViewer.HorizontalScrollChainingMode, ChainingMode.Always); Verify.AreEqual(scrollViewer.VerticalScrollChainingMode, ChainingMode.Never); Verify.AreEqual(scrollViewer.HorizontalScrollRailingMode, RailingMode.Disabled); Verify.AreEqual(scrollViewer.VerticalScrollRailingMode, RailingMode.Disabled); Verify.AreEqual(scrollViewer.HorizontalScrollMode, ScrollMode.Enabled); Verify.AreEqual(scrollViewer.VerticalScrollMode, ScrollMode.Disabled); #if USE_SCROLLMODE_AUTO Verify.AreEqual(scrollViewer.ComputedHorizontalScrollMode, ScrollMode.Enabled); Verify.AreEqual(scrollViewer.ComputedVerticalScrollMode, ScrollMode.Disabled); #endif Verify.AreEqual(scrollViewer.ZoomMode, ZoomMode.Enabled); Verify.AreEqual(scrollViewer.ZoomChainingMode, ChainingMode.Never); Verify.IsGreaterThan(scrollViewer.MinZoomFactor, 2.0 - c_epsilon); Verify.IsLessThan(scrollViewer.MinZoomFactor, 2.0 + c_epsilon); Verify.IsGreaterThan(scrollViewer.MaxZoomFactor, 8.0 - c_epsilon); Verify.IsLessThan(scrollViewer.MaxZoomFactor, 8.0 + c_epsilon); Log.Comment("Resetting window content and ScrollViewer"); MUXControlsTestApp.App.TestContentRoot = null; scrollViewer = null; }); WaitForEvent("Waiting for Unloaded event", scrollViewerUnloadedEvent); IdleSynchronizer.Wait(); Log.Comment("Garbage collecting..."); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Log.Comment("Done"); } }
public void ModelBase_ValidationTest2() { using (var verify = new Verify()) { var person = new SimplePerson(); var eventAssert = new PropertyChangedEventTest(verify, person); person.Validate(); Assert.IsTrue(person.HasErrors); eventAssert.ExpectEvent("HasErrors"); var errors = person.GetErrors("FirstName"); Assert.AreEqual(1, errors.Count); person.ClearErrors(); Assert.IsFalse(person.HasErrors); var errors2 = person.GetErrors("FirstName"); Assert.AreEqual(0, errors2.Count); } }
void VerifySelectedSizeOfSet(int index) { Verify.AreEqual(index, Int32.Parse(elements.GetSelectedSizeOfSetTextBlock().DocumentText)); }