コード例 #1
0
ファイル: StackPanelFactory.cs プロジェクト: dotnet/wpf-test
        public override StackPanel Create(DeterministicRandom random)
        {
            StackPanel stackPanel = new StackPanel();

            ApplyCommonProperties(stackPanel, random);
            return(stackPanel);
        }
コード例 #2
0
        public override LinearColorKeyFrame Create(DeterministicRandom random)
        {
            LinearColorKeyFrame linearColorKeyFrame = new LinearColorKeyFrame();

            ApplyColorKeyFrameProperties(linearColorKeyFrame, random);
            return(linearColorKeyFrame);
        }
コード例 #3
0
 private unsafe void DrawToBitmap(byte *buffer, uint size, DeterministicRandom random)
 {
     for (uint i = 0; i < size; i++)
     {
         buffer[i] = unchecked ((byte)random.Next());
     }
 }
コード例 #4
0
        /// <summary>
        /// Create a InkCanvas.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override InkCanvas Create(DeterministicRandom random)
        {
            InkCanvas inkCanvas = new InkCanvas();

            inkCanvas.Background = Background;
            HomelessTestHelpers.Merge(inkCanvas.Children, UIElementCollection);
            inkCanvas.DefaultDrawingAttributes      = DefaultDrawingAttributes;
            inkCanvas.DefaultStylusPointDescription = DefaultStylusPointDescription;
            inkCanvas.EditingMode           = random.NextEnum <InkCanvasEditingMode>();
            inkCanvas.EditingModeInverted   = random.NextEnum <InkCanvasEditingMode>();
            inkCanvas.EraserShape           = EraserShape;
            inkCanvas.MoveEnabled           = random.NextBool();
            inkCanvas.PreferredPasteFormats = PreferredPasteFormats;
            inkCanvas.ResizeEnabled         = random.NextBool();
            inkCanvas.Strokes         = Strokes;
            inkCanvas.UseCustomCursor = random.NextBool();

            inkCanvas.ActiveEditingModeChanged         += new RoutedEventHandler(ActiveEditingModeChanged);
            inkCanvas.DefaultDrawingAttributesReplaced += new DrawingAttributesReplacedEventHandler(DefaultDrawingAttributesReplaced);
            inkCanvas.EditingModeChanged         += new RoutedEventHandler(EditingModeChanged);
            inkCanvas.EditingModeInvertedChanged += new RoutedEventHandler(EditingModeInvertedChanged);
            inkCanvas.Gesture           += new InkCanvasGestureEventHandler(Gesture);
            inkCanvas.SelectionChanged  += new EventHandler(SelectionChanged);
            inkCanvas.SelectionChanging += new InkCanvasSelectionChangingEventHandler(SelectionChanging);
            inkCanvas.SelectionMoved    += new EventHandler(SelectionMoved);
            inkCanvas.SelectionMoving   += new InkCanvasSelectionEditingEventHandler(SelectionMoving);
            inkCanvas.SelectionResized  += new EventHandler(SelectionResized);
            inkCanvas.SelectionResizing += new InkCanvasSelectionEditingEventHandler(SelectionResizing);
            inkCanvas.StrokeCollected   += new InkCanvasStrokeCollectedEventHandler(StrokeCollected);
            inkCanvas.StrokeErased      += new RoutedEventHandler(StrokeErased);
            inkCanvas.StrokeErasing     += new InkCanvasStrokeErasingEventHandler(StrokeErasing);
            inkCanvas.StrokesReplaced   += new InkCanvasStrokesReplacedEventHandler(StrokesReplaced);

            return(inkCanvas);
        }
コード例 #5
0
        public override VectorAnimation Create(DeterministicRandom random)
        {
            VectorAnimation vectorAnimation = new VectorAnimation();

            if (random.NextBool())
            {
                vectorAnimation.From = FromValue;
            }

            if (random.NextBool())
            {
                vectorAnimation.To = ToValue;
            }

            if (random.NextBool())
            {
                vectorAnimation.By = ByValue;
            }

            vectorAnimation.IsAdditive     = IsAdditive;
            vectorAnimation.IsCumulative   = IsCumulative;
            vectorAnimation.EasingFunction = EasingFunction;
            ApplyTimelineProperties(vectorAnimation, random);

            return(vectorAnimation);
        }
コード例 #6
0
        /// <summary>
        /// Create a simple DataTemplate which contains a Button and a Label in a StackPanel.
        /// Label content is the string Length.
        /// Button content is the string.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override DataTemplate Create(DeterministicRandom random)
        {
            DataTemplate dataTemplate = new DataTemplate(typeof(string));

            FrameworkElementFactory panel = new FrameworkElementFactory(typeof(StackPanel));

            FrameworkElementFactory label = new FrameworkElementFactory(typeof(Label));
            //Bind string Length to Label content.
            Binding lengthBinding = new Binding("Length");

            lengthBinding.Mode = BindingMode.OneWay;
            label.SetBinding(Label.ContentProperty, lengthBinding);

            FrameworkElementFactory button = new FrameworkElementFactory(typeof(Button));
            //Bind string to Button content.
            Binding contentBinding = new Binding();

            contentBinding.Mode = BindingMode.OneWay;
            button.SetBinding(Button.ContentProperty, contentBinding);

            panel.AppendChild(label);
            panel.AppendChild(button);

            dataTemplate.VisualTree = panel;

            return(dataTemplate);
        }
コード例 #7
0
        public override DiscreteInt32KeyFrame Create(DeterministicRandom random)
        {
            DiscreteInt32KeyFrame discreteInt32KeyFrame = new DiscreteInt32KeyFrame();

            ApplyInt32KeyFrameProperties(discreteInt32KeyFrame, random);
            return(discreteInt32KeyFrame);
        }
コード例 #8
0
ファイル: TransformFactory.cs プロジェクト: dotnet/wpf-test
        public override TransformGroup Create(DeterministicRandom random)
        {
            TransformGroup transformGroup = new TransformGroup();

            transformGroup.Children = TransformCollection;
            return(transformGroup);
        }
コード例 #9
0
        public override SizeAnimation Create(DeterministicRandom random)
        {
            SizeAnimation sizeAnimation = new SizeAnimation();

            if (random.NextBool())
            {
                sizeAnimation.From = FromValue;
            }

            if (random.NextBool())
            {
                sizeAnimation.To = ToValue;
            }

            if (random.NextBool())
            {
                sizeAnimation.By = ByValue;
            }

            sizeAnimation.IsAdditive     = IsAdditive;
            sizeAnimation.EasingFunction = EasingFunction;
            if (FromValue.Height > ToValue.Height || FromValue.Width > ToValue.Width)
            {
                sizeAnimation.IsCumulative = false;
            }
            else
            {
                sizeAnimation.IsCumulative = IsCumulative;
            }

            ApplyTimelineProperties(sizeAnimation, random);
            return(sizeAnimation);
        }
コード例 #10
0
ファイル: FileHostUriFactory.cs プロジェクト: dotnet/wpf-test
        /// <summary>
        /// Create a Uri using one of the files specified in ListOfFilesOnFileHost.xml.
        /// For Uris created with different files, modify ListOfFilesOnFileHost.xml.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override Uri Create(DeterministicRandom random)
        {
            XmlDocument document = new XmlDocument();

            document.Load(filesOnFileHost);
            XmlNodeList files     = document.GetElementsByTagName("File");
            int         fileCount = files.Count;

            if (fileCount == 0)
            {
                throw new InvalidOperationException(String.Format("File: {0} doesn't contain any File node.", filesOnFileHost));
            }

            int fileIndex = random.Next(fileCount);

            XmlElement fileNode = files[fileIndex] as XmlElement;
            string     filename = fileNode.GetAttribute("Name");

            if (String.IsNullOrEmpty(filename))
            {
                throw new InvalidOperationException(String.Format("File node : \n {0} doesn't have Name attribute.", fileNode.OuterXml));
            }

            FileHost fileHost = new FileHost();

            Uri uri = fileHost.GetUri(filename, Scheme);

            return(uri);
        }
コード例 #11
0
        public override DecimalAnimation Create(DeterministicRandom random)
        {
            DecimalAnimation decimalAnimation = new DecimalAnimation();

            if (random.NextBool())
            {
                decimalAnimation.From = FromValue;
            }

            if (random.NextBool())
            {
                decimalAnimation.To = ToValue;
            }

            if (random.NextBool())
            {
                decimalAnimation.By = ByValue;
            }

            decimalAnimation.IsAdditive     = IsAdditive;
            decimalAnimation.IsCumulative   = IsCumulative;
            decimalAnimation.EasingFunction = EasingFunction;
            ApplyTimelineProperties(decimalAnimation, random);

            return(decimalAnimation);
        }
コード例 #12
0
ファイル: LineBreakFactory.cs プロジェクト: dotnet/wpf-test
        public override LineBreak Create(DeterministicRandom random)
        {
            LineBreak lineBreak = new LineBreak();

            ApplyInlineProperties(lineBreak, random);
            return(lineBreak);
        }
コード例 #13
0
        public override BitmapPalette Create(DeterministicRandom random)
        {
            if (Colors == null)
            {
                Colors = new List <Color>();
            }

            if (random.NextBool())
            {
                for (int i = 1; i <= random.Next(256) + 1; i++)
                {
                    Colors.Add(Color.FromScRgb(
                                   (float)random.NextDouble(),
                                   (float)random.NextDouble(),
                                   (float)random.NextDouble(),
                                   (float)random.NextDouble()));
                }
            }
            else
            {
                for (int i = 1; i <= random.Next(256) + 1; i++)
                {
                    Colors.Add(random.NextStaticProperty <Colors, Color>());
                }
            }

            return(new BitmapPalette(Colors));
        }
コード例 #14
0
        public override MediaElement Create(DeterministicRandom random)
        {
            MediaElement mediaElement = new MediaElement();

            mediaElement.Source = Uri;

            mediaElement.Volume           = random.NextDouble();
            mediaElement.ScrubbingEnabled = random.NextBool();

            if (IsControledWithClock && Timeline != null)
            {
                mediaElement.Clock = Timeline.CreateClock();
            }
            else
            {
                mediaElement.Source = Uri;
            }

            //Events

            mediaElement.BufferingEnded   += new System.Windows.RoutedEventHandler(BufferingEnded);
            mediaElement.BufferingStarted += new System.Windows.RoutedEventHandler(BufferingStarted);
            mediaElement.MediaOpened      += new System.Windows.RoutedEventHandler(MediaOpened);
            mediaElement.MediaFailed      += new EventHandler <System.Windows.ExceptionRoutedEventArgs>(MediaFailed);
            mediaElement.MediaEnded       += new System.Windows.RoutedEventHandler(MediaEnded);
            return(mediaElement);
        }
コード例 #15
0
 private Color RandomColor(DeterministicRandom random)
 {
     return(Color.FromArgb(unchecked ((byte)random.Next()),
                           unchecked ((byte)random.Next()),
                           unchecked ((byte)random.Next()),
                           unchecked ((byte)random.Next())));
 }
コード例 #16
0
        /// <summary>
        /// A heavy non-cached Visual tree value extraction from state
        /// </summary>
        /// <param name="desiredType"></param>
        /// <param name="random"></param>
        /// <returns></returns>
        public DependencyObject GetFromVisualTree(Type desiredType, DeterministicRandom random)
        {
            List <DependencyObject> matches = new List <DependencyObject>();

            foreach (Window window in windowList)
            {
                List <DependencyObject> elements = HomelessTestHelpers.VisualTreeWalk(window);
                elements.Add(window);

                foreach (DependencyObject obj in elements)
                {
                    if (desiredType.IsInstanceOfType(obj))
                    {
                        matches.Add(obj);
                    }
                }
            }

            if (matches.Count == 0)
            {
                return(null);
            }

            return(random.NextItem <DependencyObject>(matches));
        }
コード例 #17
0
        public override ListItem Create(DeterministicRandom random)
        {
            ListItem listItem = null;

            if (Paragraph != null)
            {
                listItem = new ListItem(Paragraph);
            }
            else
            {
                listItem = new ListItem();
            }

            ApplyTextElementFactory(listItem, random);
            HomelessTestHelpers.Merge(listItem.Blocks, Children);
            listItem.BorderBrush          = BorderBrush;
            listItem.BorderThickness      = BorderThickness;
            listItem.FlowDirection        = random.NextEnum <FlowDirection>();
            listItem.LineHeight           = CreateValidLineHeight(LineHeight);
            listItem.LineStackingStrategy = random.NextEnum <LineStackingStrategy>();
            listItem.Margin        = Margin;
            listItem.Padding       = Padding;
            listItem.TextAlignment = random.NextEnum <TextAlignment>();

            return(listItem);
        }
コード例 #18
0
        public object MakeFromConstraint(Type targetType, string propertyName, DeterministicRandom random)
        {
            //
            ConstrainedDataSource source = constraintsTable.Get(TargetTypeAttribute.FindTarget(targetType), propertyName);

            return(source.GetData(random));
        }
コード例 #19
0
ファイル: ConstrainedSize.cs プロジェクト: dotnet/wpf-test
        public override object GetData(DeterministicRandom r)
        {
            double rangeWidth  = MaxWidth - MinWidth;
            double rangeHeight = MaxHeight - MinHeight;

            return(new Size(MinWidth + rangeWidth * r.NextDouble(), MinHeight + rangeHeight * r.NextDouble()));
        }
コード例 #20
0
        public override ColumnDefinition Create(DeterministicRandom random)
        {
            ColumnDefinition columnDefinition = new ColumnDefinition();

            columnDefinition.Width = Width;
            return(columnDefinition);
        }
コード例 #21
0
        public override MaterialGroup Create(DeterministicRandom random)
        {
            MaterialGroup materialGroup = new MaterialGroup();

            materialGroup.Children = MaterialCollection;
            return(materialGroup);
        }
コード例 #22
0
        public override DatePicker Create(DeterministicRandom random)
        {
            DatePicker datePicker = new DatePicker();

            if (DisplayDate != null)
            {
                datePicker.DisplayDate = (DateTime)DisplayDate.GetData(random);
            }

            if (DisplayDateEnd != null)
            {
                datePicker.DisplayDateEnd = (DateTime)DisplayDateEnd.GetData(random);
            }

            if (DisplayDateStart != null)
            {
                datePicker.DisplayDateStart = (DateTime)DisplayDateStart.GetData(random);
            }

            datePicker.FirstDayOfWeek     = FirstDayOfWeek;
            datePicker.IsTodayHighlighted = IsTodayHighlighted;

            if (SelectedDate != null)
            {
                datePicker.SelectedDate = (DateTime)SelectedDate.GetData(random);
            }

            datePicker.SelectedDateFormat = SelectedDateFormat;
            return(datePicker);
        }
コード例 #23
0
        public Sequence GetNext(IState state, DeterministicRandom random)
        {
            Sequence sequence = null;
            ConvenienceStressState stressState     = (ConvenienceStressState)state;
            Queue <Type>           possibleActions = stressState.GetActions(random);

            while (possibleActions.Count > 0 && sequence == null)
            {
                DiscoverableAction action = (DiscoverableAction)Activator.CreateInstance(possibleActions.Dequeue());
                Trace.WriteLine("[DiscoverableActionSequencer]Populating Action.");

                bool hasValidInputs = PopulateDiscoverableInputs(action, random, stressState, 0);

                //Add action to sequence only CanPerform is true, and input has been created successfully.
                if (hasValidInputs && action.CanPerform())
                {
                    sequence = new Sequence();
                    sequence.AddAction(action);
                }
            }
            if (sequence == null)
            {
                throw new InvalidOperationException("Stress could not find a new Action to perform at this state.");
            }
            return(sequence);
        }
コード例 #24
0
ファイル: BitmapFrameFactory.cs プロジェクト: dotnet/wpf-test
        public override BitmapFrame Create(DeterministicRandom random)
        {
            BitmapFrame bitmapFrame = BitmapFrame.Create(Uri);

            bitmapFrame.Freeze();
            return(bitmapFrame);
        }
コード例 #25
0
        public override FigureLength Create(DeterministicRandom random)
        {
            double randomDouble = random.NextDouble();

            switch (random.NextEnum <FigureUnitType>())
            {
            case FigureUnitType.Auto:
                return(new FigureLength());

            case FigureUnitType.Pixel:
                return(new FigureLength(randomDouble * 300, FigureUnitType.Pixel));

            case FigureUnitType.Column:
                return(new FigureLength(randomDouble * 3, FigureUnitType.Column));

            case FigureUnitType.Content:
                return(new FigureLength(randomDouble, FigureUnitType.Content));

            case FigureUnitType.Page:
                return(new FigureLength(randomDouble, FigureUnitType.Page));

            default:
                goto case 0;
            }
        }
コード例 #26
0
ファイル: TabItemFactory.cs プロジェクト: dotnet/wpf-test
        public override TabItem Create(DeterministicRandom random)
        {
            TabItem tabItem = new TabItem();

            ApplyHeaderedContentControlProperties(tabItem);
            return(tabItem);
        }
コード例 #27
0
        public override InteropBitmap Create(DeterministicRandom random)
        {
            int  width             = random.Next(400) + 1;
            int  height            = random.Next(400) + 1;
            int  bytesPerPixel     = (int)((Format.BitsPerPixel + 7.0) / 8.0);
            uint bufferSizeInBytes = (uint)(width * height * bytesPerPixel);
            int  stride            = (int)(width * bytesPerPixel);

            IntPtr fileHandle = CreateFileMapping(INVALID_HANDLE_VALUE, IntPtr.Zero, PAGE_READWRITE, 0, bufferSizeInBytes, null);

            if (fileHandle == IntPtr.Zero)
            {
                throw new InvalidOperationException("Could not create a file mapping for the Interop Bitmap");
            }

            unsafe
            {
                IntPtr viewHandle = MapViewOfFile(fileHandle, FILE_MAP_ALL_ACCESS, 0, 0, bufferSizeInBytes);
                byte * pixels     = (byte *)viewHandle.ToPointer();

                DrawToBitmap(pixels, bufferSizeInBytes, random);

                UnmapViewOfFile(viewHandle);
            }

            InteropBitmap bitmap = (InteropBitmap)System.Windows.Interop.Imaging.CreateBitmapSourceFromMemorySection(fileHandle, width, height, Format, stride, 0);

            // store the file handle as a dependency property, so that the InteropBitmap action has access to it
            // and so that when the InteropBitmap is garbage collected, the handle will still be closed
            SafeFileHandle section = new SafeFileHandle(fileHandle, true);

            bitmap.SetValue(HandleProperty, section);

            return(bitmap);
        }
コード例 #28
0
ファイル: UIElementFactory.cs プロジェクト: dotnet/wpf-test
        public override UIElement Create(DeterministicRandom random)
        {
            UIElement uIElement = new UIElement();

            uIElement.AllowDrop        = random.NextBool();
            uIElement.ClipToBounds     = random.NextBool();
            uIElement.Focusable        = random.NextBool();
            uIElement.IsEnabled        = random.NextBool();
            uIElement.IsHitTestVisible = random.NextBool();
#if TESTBUILD_CLR40
            uIElement.IsManipulationEnabled = random.NextBool();
#endif
            uIElement.Opacity               = random.NextDouble();
            uIElement.Visibility            = random.NextEnum <Visibility>();
            uIElement.Effect                = Effect;
            uIElement.Clip                  = Geometry;
            uIElement.Opacity               = random.NextDouble();
            uIElement.OpacityMask           = Brush;
            uIElement.RenderSize            = Size;
            uIElement.RenderTransform       = Transform;
            uIElement.RenderTransformOrigin = Point;
            uIElement.SnapsToDevicePixels   = random.NextBool();

#if TESTBUILD_CLR40
            uIElement.CacheMode = BitmapCache;
#endif

            return(uIElement);
        }
コード例 #29
0
        public override BitmapEffectGroup Create(DeterministicRandom random)
        {
            BitmapEffectGroup bitmapEffectGroup = new BitmapEffectGroup();

            bitmapEffectGroup.Children = this.BitmapEffectCollection;
            return(bitmapEffectGroup);
        }
コード例 #30
0
        public override Vector3DAnimation Create(DeterministicRandom random)
        {
            Vector3DAnimation vector3DAnimation = new Vector3DAnimation();

            /*
             * Randomly combinate From, To, By
             */
            if (random.NextBool())
            {
                vector3DAnimation.By = ByValue;
            }

            if (random.NextBool())
            {
                vector3DAnimation.From = FromValue;
            }

            if (random.NextBool())
            {
                vector3DAnimation.To = ToValue;
            }

            vector3DAnimation.IsAdditive   = random.NextBool();
            vector3DAnimation.IsCumulative = random.NextBool();

            ApplyTimelineProperties(vector3DAnimation, random);

            return(vector3DAnimation);
        }