コード例 #1
0
        public MetricContextTestFixture()
        {
            ApdexOptions = new ApdexOptions
            {
                Name = "apdex"
            };

            CounterOptions = new CounterOptions
            {
                Name = "counter"
            };

            GaugeOptions = new GaugeOptions
            {
                Name = "gauge"
            };

            HistogramOptions = new HistogramOptions
            {
                Name = "histogram"
            };

            MeterOptions = new MeterOptions
            {
                Name = "meter"
            };

            TimerOptions = new TimerOptions
            {
                Name = "timer"
            };

            var tags = new GlobalMetricTags
            {
                { "key1", "value1" },
                { "key2", "value2" }
            };

            var samplingProvider = new DefaultSamplingReservoirProvider(() => new DefaultForwardDecayingReservoir());

            Registry         = new DefaultMetricContextRegistry("context_label", tags);
            ApdexBuilder     = new DefaultApdexBuilder(samplingProvider);
            HistogramBuilder = new DefaultHistogramBuilder(samplingProvider);
            CounterBuilder   = new DefaultCounterBuilder();
            GaugeBuilder     = new DefaultGaugeBuilder();
            MeterBuilder     = new DefaultMeterBuilder();
            TimerBuilder     = new DefaultTimerBuilder(samplingProvider);
            Clock            = new StopwatchClock();
        }
コード例 #2
0
        public void TestDelayedDelegatesAreScheduledWithCorrectTime()
        {
            var clock = new StopwatchClock();

            scheduler.UpdateClock(clock);

            ScheduledDelegate del = scheduler.AddDelayed(() => { }, 1000);

            Assert.AreEqual(1000, del.ExecutionTime);

            clock.Seek(500);
            del = scheduler.AddDelayed(() => { }, 1000);

            Assert.AreEqual(1500, del.ExecutionTime);
        }
コード例 #3
0
        public void TestVariousUnits()
        {
            AddStep("create various scoreboard times", () => Child = new FillFlowContainer
            {
                RelativeSizeAxes   = Axes.X,
                AutoSizeAxes       = Axes.Y,
                Anchor             = Anchor.Centre,
                Origin             = Anchor.Centre,
                Clock              = new FramedClock(stopwatch = new StopwatchClock()), // prevent time from naturally elapsing.
                Direction          = FillDirection.Vertical,
                ChildrenEnumerable = testCases.Select(dateTime => new ScoreboardTime(dateTime, 24).With(time => time.Anchor = time.Origin = Anchor.TopCentre))
            });

            AddStep("start stopwatch", () => stopwatch.Start());
        }
コード例 #4
0
        public void TestResetTime()
        {
            var stopwatchClock = new StopwatchClock();

            stopwatchClock.Start();

            Thread.Sleep(1000);

            Assert.Greater(stopwatchClock.CurrentTime, 0);

            stopwatchClock.Stop();
            stopwatchClock.Reset();

            Assert.AreEqual(0, stopwatchClock.CurrentTime);
        }
コード例 #5
0
        public void Play(string path)
        {
            videoFile = path;

            InternalChild = video = new Video(store.Store.GetStream(path))
            {
                RelativeSizeAxes = Axes.Both,
                FillMode         = FillMode.Fit,
                Anchor           = Anchor.Centre,
                Origin           = Anchor.Centre,
                Clock            = new FramedClock(clock = new StopwatchClock())
            };

            UpdateColors(true);
        }
コード例 #6
0
        public void StopwatchClock_ClockTicksEqualStopwatchTicks(int sleepSeconds)
        {
            var ticks = 0;
            var clock = new StopwatchClock(10, () => ticks++, 0);

            clock.Start();

            Thread.Sleep(sleepSeconds * 1000);
            //=== Manual Step : Check CPU to see processor efficiency.

            clock.Stop();

            Thread.Sleep(1000);

            Console.WriteLine(ticks);
        }
コード例 #7
0
ファイル: DrawableNotification.cs プロジェクト: Mempler/Qsor
        /// <summary>
        /// Drawable Notification
        /// </summary>
        /// <param name="text"></param>
        /// <param name="colourInfo"></param>
        /// <param name="duration">Hide after X amount of MS, -1 = PositiveInfinity</param>
        /// <param name="clickAction"></param>
        public DrawableNotification(LocalisedString text, ColourInfo colourInfo, int duration = -1, Action clickAction = null)
        {
            _clock             = new StopwatchClock();
            _clickAction       = clickAction;
            _borderColour      = colourInfo;
            _textFlowContainer = new TextFlowContainer
            {
                Direction    = FillDirection.Full,
                AutoSizeAxes = Axes.Both,
                MaximumSize  = new Vector2(290, float.MaxValue),
                Padding      = new MarginPadding(10)
            };
            _duration = duration == -1 ? Math.Max(3000, (double)(text.ToString().Length * 100)) : duration;

            _textFlowContainer.AddText(text);
        }
コード例 #8
0
ファイル: TestCaseOsuGame.cs プロジェクト: weebaka/osu
        public TestCaseOsuGame()
        {
            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            framedClock.ProcessFrame();

            Add(new Box
            {
                RelativeSizeAxes = Axes.Both,
                Colour           = Color4.Black,
            });

            Add(new Loader());

            AddSliderStep("Playback speed", 0.0, 2.0, 1, v => rateAdjustClock.Rate = v);
        }
コード例 #9
0
        /// <summary>
        /// Create a collector for the target thread. Starts in a disabled state (see <see cref="Enabled"/>.
        /// </summary>
        /// <param name="targetThread">The thread to monitor.</param>
        /// <param name="clock">The clock to use for elapsed time checks.</param>
        public BackgroundStackTraceCollector(Thread targetThread, StopwatchClock clock)
        {
            if (Debugger.IsAttached)
            {
                return;
            }

            this.clock        = clock;
            this.targetThread = targetThread;

            logger = new Lazy <Logger>(() =>
            {
                var l = Logger.GetLogger($"performance-{targetThread.Name?.ToLower() ?? "unknown"}");
                l.OutputToListeners = false;
                return(l);
            });
        }
コード例 #10
0
        public void TestSeekWhenNonZero()
        {
            var stopwatchClock = new StopwatchClock();

            stopwatchClock.Start();

            Thread.Sleep(1000);

            stopwatchClock.Stop();
            var stoppedTime = stopwatchClock.CurrentTime;

            Assert.Greater(stoppedTime, 0);

            stopwatchClock.Seek(stoppedTime);

            Assert.AreEqual(stoppedTime, stopwatchClock.CurrentTime);
        }
コード例 #11
0
        public void TestCancelDelayedDelegate()
        {
            var clock = new StopwatchClock();

            scheduler.UpdateClock(clock);

            int invocations = 0;

            ScheduledDelegate del;

            scheduler.Add(del = new ScheduledDelegate(() => invocations++, 1000));
            del.Cancel();

            clock.Seek(1500);
            scheduler.Update();
            Assert.AreEqual(0, invocations);
        }
コード例 #12
0
        public TestSceneSongProgress()
        {
            clock         = new StopwatchClock();
            gameplayClock = new GameplayClock(framedClock = new FramedClock(clock));

            Add(progressContainer = new Container
            {
                RelativeSizeAxes = Axes.X,
                Anchor           = Anchor.BottomCentre,
                Origin           = Anchor.BottomCentre,
                Height           = 100,
                Y     = -100,
                Child = new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = OsuColour.Gray(1),
                }
            });
        }
コード例 #13
0
        public void TestRateUpResetTime()
        {
            var stopwatchClock = new StopwatchClock();

            stopwatchClock.Start();

            Thread.Sleep(1000);

            stopwatchClock.Stop();
            double stoppedTime = stopwatchClock.CurrentTime;

            Assert.Greater(stoppedTime, 0);

            stopwatchClock.Rate = 2.0f;
            Assert.AreEqual(stoppedTime, stopwatchClock.CurrentTime);

            stopwatchClock.Reset();

            Assert.AreEqual(0, stopwatchClock.CurrentTime);
        }
コード例 #14
0
        public void TestCancelAfterRepeatReschedule()
        {
            var clock = new StopwatchClock();

            scheduler.UpdateClock(clock);

            int invocations = 0;

            ScheduledDelegate del;

            scheduler.Add(del = new ScheduledDelegate(() => invocations++, 500, 500));

            clock.Seek(750);
            scheduler.Update();
            Assert.AreEqual(1, invocations);

            del.Cancel();
            clock.Seek(1250);
            scheduler.Update();
            Assert.AreEqual(1, invocations);
        }
コード例 #15
0
        public void TestSeekNegativeAdjustRate()
        {
            var stopwatchClock = new StopwatchClock();

            stopwatchClock.Seek(-5000);
            Assert.AreEqual(-5000, stopwatchClock.CurrentTime);

            stopwatchClock.Rate = 2.0f;
            stopwatchClock.Start();

            Thread.Sleep(1000);

            stopwatchClock.Stop();
            var stoppedTime = stopwatchClock.CurrentTime;

            Assert.Less(stoppedTime, 0);

            stopwatchClock.Seek(stoppedTime);

            Assert.AreEqual(stoppedTime, stopwatchClock.CurrentTime);
        }
コード例 #16
0
        public override void Reset()
        {
            base.Reset();

            AddStep("Hit!", addHitJudgement);
            AddStep("Miss :(", addMissJudgement);
            AddStep("DrumRoll", () => addDrumRoll(false));
            AddStep("Strong DrumRoll", () => addDrumRoll(true));
            AddStep("Swell", () => addSwell());
            AddStep("Centre", () => addCentreHit(false));
            AddStep("Strong Centre", () => addCentreHit(true));
            AddStep("Rim", () => addRimHit(false));
            AddStep("Strong Rim", () => addRimHit(true));
            AddStep("Add bar line", () => addBarLine(false));
            AddStep("Add major bar line", () => addBarLine(true));
            AddStep("Height test 1", () => changePlayfieldSize(1));
            AddStep("Height test 2", () => changePlayfieldSize(2));
            AddStep("Height test 3", () => changePlayfieldSize(3));
            AddStep("Height test 4", () => changePlayfieldSize(4));
            AddStep("Height test 5", () => changePlayfieldSize(5));
            AddStep("Reset height", () => changePlayfieldSize(6));

            var rateAdjustClock = new StopwatchClock(true)
            {
                Rate = 1
            };

            Add(playfieldContainer = new Container
            {
                Anchor           = Anchor.Centre,
                Origin           = Anchor.Centre,
                RelativeSizeAxes = Axes.X,
                Height           = TaikoPlayfield.DEFAULT_PLAYFIELD_HEIGHT,
                Clock            = new FramedClock(rateAdjustClock),
                Children         = new[]
                {
                    playfield = new TaikoPlayfield()
                }
            });
        }
コード例 #17
0
ファイル: TestCaseSongProgress.cs プロジェクト: yazici/osu
        public TestCaseSongProgress()
        {
            clock = new StopwatchClock(true);

            gameplayClock = new GameplayClock(framedClock = new FramedClock(clock));

            Add(progress = new SongProgress
            {
                RelativeSizeAxes = Axes.X,
                Anchor           = Anchor.BottomLeft,
                Origin           = Anchor.BottomLeft,
            });

            Add(graph = new TestSongProgressGraph
            {
                RelativeSizeAxes = Axes.X,
                Height           = 200,
                Anchor           = Anchor.TopLeft,
                Origin           = Anchor.TopLeft,
            });

            AddWaitStep(5);
            AddAssert("ensure not created", () => graph.CreationCount == 0);

            AddStep("display values", displayNewValues);
            AddWaitStep(5);
            AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");

            AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
            AddWaitStep(5);
            AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");

            AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
            AddWaitStep(5);
            AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
            AddRepeatStep("New Values", displayNewValues, 5);

            AddWaitStep(5);
            AddAssert("ensure debounced", () => graph.CreationCount == 2);
        }
コード例 #18
0
        public BackgroundStackTraceCollector(Thread targetThread, StopwatchClock clock)
        {
            if (Debugger.IsAttached)
            {
                return;
            }

            logger = Logger.GetLogger($"performance-{targetThread.Name?.ToLower() ?? "unknown"}");
            logger.OutputToListeners = false;

            this.clock        = clock;
            this.targetThread = targetThread;

            thread = new GameThread(() =>
            {
                if (Enabled && targetThread.IsAlive && clock.ElapsedMilliseconds - LastConsumptionTime > spikeRecordThreshold / 2 && backgroundMonitorStackTrace == null)
                {
                    backgroundMonitorStackTrace = getStackTrace(targetThread);
                }
            }, $"{targetThread}-StackTraceCollector", false);

            thread.Start();
        }
コード例 #19
0
        public void TestRepeatingDelayedDelegateCatchUp(bool performCatchUp)
        {
            var clock = new StopwatchClock();

            scheduler.UpdateClock(clock);

            int invocations = 0;

            scheduler.Add(new ScheduledDelegate(() => invocations++, 500, 500)
            {
                PerformRepeatCatchUpExecutions = performCatchUp
            });

            for (double d = 0; d <= 10000; d += 2000)
            {
                clock.Seek(d);

                for (int i = 0; i < 10; i++)
                {
                    // allow catch-up to potentially occur.
                    scheduler.Update();
                }

                int expectedInovations;

                if (performCatchUp)
                {
                    expectedInovations = (int)(d / 500);
                }
                else
                {
                    expectedInovations = (int)(d / 2000);
                }

                Assert.AreEqual(expectedInovations, invocations);
            }
        }
コード例 #20
0
        private void load(Storage storage, GameHost host)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            rateBindable = new BindableDouble(1)
            {
                MinValue = 0,
                MaxValue = 1,
            };

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(200, 1),
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Color4.DimGray,
                            RelativeSizeAxes = Axes.Both
                        },
                        new ScrollContainer
                        {
                            RelativeSizeAxes         = Axes.Both,
                            ScrollbarOverlapsContent = false,
                            Child = leftFlowContainer = new FillFlowContainer <TestCaseButton>
                            {
                                Padding          = new MarginPadding(3),
                                Direction        = FillDirection.Vertical,
                                Spacing          = new Vector2(0, 5),
                                AutoSizeAxes     = Axes.Y,
                                RelativeSizeAxes = Axes.X,
                            }
                        }
                    }
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = 200
                    },
                    Children = new Drawable[]
                    {
                        toolbar = new Toolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                            Depth            = -1,
                            RunAllSteps      = () => CurrentTest.RunAllSteps(() => toolbar.RunComplete(), toolbar.RunComplete),
                        },
                        testContentContainer = new Container
                        {
                            Clock            = framedClock,
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = 50
                            },
                            Child = compilingNotice = new Container
                            {
                                Alpha        = 0,
                                Anchor       = Anchor.Centre,
                                Origin       = Anchor.Centre,
                                Masking      = true,
                                Depth        = float.MinValue,
                                CornerRadius = 5,
                                AutoSizeAxes = Axes.Both,
                                Children     = new Drawable[]
                                {
                                    new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Colour           = Color4.Black,
                                    },
                                    new SpriteText
                                    {
                                        TextSize = 30,
                                        Text     = @"Compiling new version..."
                                    }
                                },
                            }
                        }
                    }
                }
            };

            backgroundCompiler = new DynamicClassCompiler <TestCase>
            {
                CompilationStarted  = compileStarted,
                CompilationFinished = compileFinished,
            };
            try
            {
                backgroundCompiler.Start();
            }
            catch
            {
                //it's okay for this to fail for now.
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AssemblyDropdown.AddDropdownItem(asm.GetName().Name, asm);
            }

            toolbar.AssemblyDropdown.Current.ValueChanged += updateList;
            toolbar.RateAdjustSlider.Current.BindTo(rateBindable);

            rateBindable.ValueChanged += v => rateAdjustClock.Rate = v;
            rateBindable.TriggerChange();
        }
コード例 #21
0
        private void load(Storage storage, GameHost host, FrameworkConfigManager frameworkConfig)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            exit = host.Exit;

            showLogOverlay = frameworkConfig.GetBindable <bool>(FrameworkSetting.ShowLogOverlay);

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                leftContainer = new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(test_list_width, 1),
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = new Color4(50, 50, 50, 255),
                            RelativeSizeAxes = Axes.Both
                        },
                        new FillFlowContainer
                        {
                            Direction        = FillDirection.Vertical,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                searchTextBox = new TextBox
                                {
                                    OnCommit = delegate
                                    {
                                        var firstVisible = leftFlowContainer.FirstOrDefault(b => b.IsPresent);
                                        if (firstVisible != null)
                                        {
                                            LoadTest(firstVisible.SelectFirst());
                                        }
                                    },
                                    Height           = 20,
                                    RelativeSizeAxes = Axes.X,
                                    PlaceholderText  = "type to search"
                                },
                                new ScrollContainer
                                {
                                    Padding = new MarginPadding {
                                        Top = 3, Bottom = 20
                                    },
                                    RelativeSizeAxes         = Axes.Both,
                                    ScrollbarOverlapsContent = false,
                                    Child = leftFlowContainer = new SearchContainer <TestCaseButtonGroup>
                                    {
                                        Padding          = new MarginPadding(3),
                                        Direction        = FillDirection.Vertical,
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                    }
                                }
                            }
                        }
                    }
                },
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = test_list_width
                    },
                    Children = new Drawable[]
                    {
                        toolbar = new TestBrowserToolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                            Depth            = -1,
                        },
                        testContentContainer = new Container
                        {
                            Clock            = framedClock,
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = 50
                            },
                            Child = compilingNotice = new Container
                            {
                                Alpha        = 0,
                                Anchor       = Anchor.Centre,
                                Origin       = Anchor.Centre,
                                Masking      = true,
                                Depth        = float.MinValue,
                                CornerRadius = 5,
                                AutoSizeAxes = Axes.Both,
                                Children     = new Drawable[]
                                {
                                    new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Colour           = Color4.Black,
                                    },
                                    new SpriteText
                                    {
                                        TextSize = 30,
                                        Text     = @"Compiling new version..."
                                    }
                                },
                            }
                        }
                    }
                }
            };

            searchTextBox.Current.ValueChanged += newValue => leftFlowContainer.SearchTerm = newValue;

            if (RuntimeInfo.SupportsJIT)
            {
                backgroundCompiler = new DynamicClassCompiler <TestCase>
                {
                    CompilationStarted  = compileStarted,
                    CompilationFinished = compileFinished,
                    CompilationFailed   = compileFailed
                };
                try
                {
                    backgroundCompiler.Start();
                }
                catch
                {
                    //it's okay for this to fail for now.
                }
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AddAssembly(asm.GetName().Name, asm);
            }

            Assembly.BindValueChanged(updateList);
            RunAllSteps.BindValueChanged(v => runTests(null));
            PlaybackRate.BindValueChanged(v => rateAdjustClock.Rate = v, true);
        }
コード例 #22
0
        private void createPlayfieldWithNotes(bool inverted = false)
        {
            Clear();

            var rateAdjustClock = new StopwatchClock(true)
            {
                Rate = 1
            };

            var inputManager = new ManiaInputManager(maniaRuleset, 4)
            {
                RelativeSizeAxes = Axes.Both
            };

            Add(inputManager);

            ManiaPlayfield playfield;
            var            stages = new List <StageDefinition>
            {
                new StageDefinition {
                    Columns = 4
                },
            };

            inputManager.Add(playfield = new ManiaPlayfield(stages)
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Clock  = new FramedClock(rateAdjustClock)
            });

            playfield.Inverted.Value = inverted;

            for (double t = start_time; t <= start_time + duration; t += 100)
            {
                var note1 = new Note {
                    StartTime = t, Column = 0
                };
                var note2 = new Note {
                    StartTime = t, Column = 3
                };

                note1.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
                note2.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());

                playfield.Add(new DrawableNote(note1, ManiaAction.Key1));
                playfield.Add(new DrawableNote(note2, ManiaAction.Key4));
            }

            var holdNote1 = new HoldNote {
                StartTime = start_time, Duration = duration, Column = 1
            };
            var holdNote2 = new HoldNote {
                StartTime = start_time, Duration = duration, Column = 2
            };

            holdNote1.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
            holdNote2.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());

            playfield.Add(new DrawableHoldNote(holdNote1, ManiaAction.Key2));
            playfield.Add(new DrawableHoldNote(holdNote2, ManiaAction.Key3));
        }
コード例 #23
0
ファイル: TestCaseHitObjects.cs プロジェクト: yheno/osu
 public TestCaseHitObjects()
 {
     var swClock = new StopwatchClock(true) { Rate = 0.2f };
     Clock = new FramedClock(swClock);
 }
コード例 #24
0
        private void load(Storage storage, GameHost host, AudioManager audio)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            audio.AddAdjustment(AdjustableProperty.Frequency, audioRateAdjust);

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = test_list_width
                    },
                    Children = new Drawable[]
                    {
                        new SafeAreaContainer
                        {
                            SafeAreaOverrideEdges = Edges.Right | Edges.Bottom,
                            RelativeSizeAxes      = Axes.Both,
                            Child = testContentContainer = new Container
                            {
                                Clock            = framedClock,
                                RelativeSizeAxes = Axes.Both,
                                Padding          = new MarginPadding {
                                    Top = 50
                                },
                                Child = compilingNotice = new Container
                                {
                                    Alpha        = 0,
                                    Anchor       = Anchor.Centre,
                                    Origin       = Anchor.Centre,
                                    Masking      = true,
                                    Depth        = float.MinValue,
                                    CornerRadius = 5,
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new Drawable[]
                                    {
                                        new Box
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Colour           = Color4.Black,
                                        },
                                        new SpriteText
                                        {
                                            Font = FrameworkFont.Regular.With(size: 30),
                                            Text = @"Compiling new version..."
                                        }
                                    },
                                }
                            }
                        },
                        toolbar = new TestBrowserToolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                        },
                    }
                },
                leftContainer = new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(test_list_width, 1),
                    Masking          = true,
                    Children         = new Drawable[]
                    {
                        new SafeAreaContainer
                        {
                            SafeAreaOverrideEdges = Edges.Left | Edges.Top | Edges.Bottom,
                            RelativeSizeAxes      = Axes.Both,
                            Child = new Box
                            {
                                Colour           = FrameworkColour.GreenDark,
                                RelativeSizeAxes = Axes.Both
                            }
                        },
                        new FillFlowContainer
                        {
                            Direction        = FillDirection.Vertical,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                searchTextBox = new TestBrowserTextBox
                                {
                                    Height           = 25,
                                    RelativeSizeAxes = Axes.X,
                                    PlaceholderText  = "type to search",
                                    Depth            = -1,
                                },
                                new BasicScrollContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Masking          = false,
                                    Child            = leftFlowContainer = new SearchContainer <TestGroupButton>
                                    {
                                        AllowNonContiguousMatching = true,
                                        Padding = new MarginPadding {
                                            Top = 3, Bottom = 20
                                        },
                                        Direction        = FillDirection.Vertical,
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                    }
                                }
                            }
                        }
                    }
                },
            };

            searchTextBox.OnCommit += delegate
            {
                var firstTest = leftFlowContainer.Where(b => b.IsPresent).SelectMany(b => b.FilterableChildren).OfType <TestSubButton>()
                                .FirstOrDefault(b => b.MatchingFilter)?.TestType;
                if (firstTest != null)
                {
                    LoadTest(firstTest);
                }
            };

            searchTextBox.Current.ValueChanged += e => leftFlowContainer.SearchTerm = e.NewValue;

            if (RuntimeInfo.IsDesktop)
            {
                HotReloadCallbackReceiver.CompilationFinished += compileFinished;
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AddAssembly(asm.GetName().Name, asm);
            }

            Assembly.BindValueChanged(updateList);
            RunAllSteps.BindValueChanged(v => runTests(null));
            PlaybackRate.BindValueChanged(e =>
            {
                rateAdjustClock.Rate  = e.NewValue;
                audioRateAdjust.Value = e.NewValue;
            }, true);
        }
コード例 #25
0
ファイル: TestCaseHitObjects.cs プロジェクト: revam/osu
 public TestCaseHitObjects()
 {
     rateAdjustClock             = new StopwatchClock(true);
     framedClock                 = new FramedClock(rateAdjustClock);
     playbackSpeed.ValueChanged += delegate { rateAdjustClock.Rate = playbackSpeed.Value; };
 }
コード例 #26
0
ファイル: GameNoteTests.cs プロジェクト: maxrchung/S2VX
 public void SetUpSteps()
 {
     AddStep("Clear score", () => PlayScreen.ScoreProcessor.Reset());
     AddStep("Reset story", () => Story.Reset());
     AddStep("Reset clock", () => Story.Clock = new FramedClock(Stopwatch = new StopwatchClock()));
 }
コード例 #27
0
 public DecoupleableInterpolatingFramedClock()
 {
     decoupledClock = new FramedClock(decoupledStopwatch = new StopwatchClock());
 }
コード例 #28
0
        private void createPlayfieldWithNotes(bool gravity, bool inverted = false)
        {
            Clear();

            var rateAdjustClock = new StopwatchClock(true)
            {
                Rate = 1
            };

            var inputManager = new ManiaInputManager(maniaRuleset, 4)
            {
                RelativeSizeAxes = Axes.Both
            };

            Add(inputManager);

            ManiaPlayfield playfield;

            inputManager.Add(playfield = new ManiaPlayfield(4)
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Clock  = new FramedClock(rateAdjustClock)
            });

            playfield.Inverted.Value = inverted;

            if (!gravity)
            {
                playfield.Columns.ForEach(c => c.Add(createTimingChange(0, false)));
            }

            for (double t = start_time; t <= start_time + duration; t += 100)
            {
                if (gravity)
                {
                    playfield.Columns.ElementAt(0).Add(createTimingChange(t, true));
                }

                playfield.Add(new DrawableNote(new Note
                {
                    StartTime = t,
                    Column    = 0
                }, ManiaAction.Key1));

                if (gravity)
                {
                    playfield.Columns.ElementAt(3).Add(createTimingChange(t, true));
                }

                playfield.Add(new DrawableNote(new Note
                {
                    StartTime = t,
                    Column    = 3
                }, ManiaAction.Key4));
            }

            if (gravity)
            {
                playfield.Columns.ElementAt(1).Add(createTimingChange(start_time, true));
            }

            playfield.Add(new DrawableHoldNote(new HoldNote
            {
                StartTime = start_time,
                Duration  = duration,
                Column    = 1
            }, ManiaAction.Key2));

            if (gravity)
            {
                playfield.Columns.ElementAt(2).Add(createTimingChange(start_time, true));
            }

            playfield.Add(new DrawableHoldNote(new HoldNote
            {
                StartTime = start_time,
                Duration  = duration,
                Column    = 2
            }, ManiaAction.Key3));
        }
コード例 #29
0
        public TestCaseManiaPlayfield()
        {
            Action <int, SpecialColumnPosition> createPlayfield = (cols, pos) =>
            {
                Clear();
                Add(new ManiaPlayfield(cols)
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    SpecialColumnPosition = pos,
                    Scale = new Vector2(1, -1)
                });
            };

            const double start_time = 500;
            const double duration   = 500;

            Func <double, bool, SpeedAdjustmentContainer> createTimingChange = (time, gravity) => new ManiaSpeedAdjustmentContainer(new MultiplierControlPoint(time)
            {
                TimingPoint = { BeatLength = 1000 }
            }, gravity ? ScrollingAlgorithm.Gravity : ScrollingAlgorithm.Basic);

            Action <bool> createPlayfieldWithNotes = gravity =>
            {
                Clear();

                var rateAdjustClock = new StopwatchClock(true)
                {
                    Rate = 1
                };

                ManiaPlayfield playField;
                Add(playField = new ManiaPlayfield(4)
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    Scale  = new Vector2(1, -1),
                    Clock  = new FramedClock(rateAdjustClock)
                });

                if (!gravity)
                {
                    playField.Columns.ForEach(c => c.Add(createTimingChange(0, false)));
                }

                for (double t = start_time; t <= start_time + duration; t += 100)
                {
                    if (gravity)
                    {
                        playField.Columns.ElementAt(0).Add(createTimingChange(t, true));
                    }

                    playField.Add(new DrawableNote(new Note
                    {
                        StartTime = t,
                        Column    = 0
                    }, new Bindable <Key>(Key.D)));

                    if (gravity)
                    {
                        playField.Columns.ElementAt(3).Add(createTimingChange(t, true));
                    }

                    playField.Add(new DrawableNote(new Note
                    {
                        StartTime = t,
                        Column    = 3
                    }, new Bindable <Key>(Key.K)));
                }

                if (gravity)
                {
                    playField.Columns.ElementAt(1).Add(createTimingChange(start_time, true));
                }

                playField.Add(new DrawableHoldNote(new HoldNote
                {
                    StartTime = start_time,
                    Duration  = duration,
                    Column    = 1
                }, new Bindable <Key>(Key.F)));

                if (gravity)
                {
                    playField.Columns.ElementAt(2).Add(createTimingChange(start_time, true));
                }

                playField.Add(new DrawableHoldNote(new HoldNote
                {
                    StartTime = start_time,
                    Duration  = duration,
                    Column    = 2
                }, new Bindable <Key>(Key.J)));
            };

            AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal));
            AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal));
            AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left));
            AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right));
            AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal));
            AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal));
            AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left));
            AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right));

            AddStep("Notes with input", () => createPlayfieldWithNotes(false));
            AddWaitStep((int)Math.Ceiling((start_time + duration) / TimePerAction));

            AddStep("Notes with gravity", () => createPlayfieldWithNotes(true));
            AddWaitStep((int)Math.Ceiling((start_time + duration) / TimePerAction));
        }
コード例 #30
0
        private void load(Storage storage, GameHost host, FrameworkConfigManager frameworkConfig, FontStore fonts, Game game, AudioManager audio)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            exit = host.Exit;

            audio.AddAdjustment(AdjustableProperty.Frequency, audioRateAdjust);

            var resources = game.Resources;

            //Roboto
            game.AddFont(resources, @"Fonts/Roboto/Roboto-Regular");
            game.AddFont(resources, @"Fonts/Roboto/Roboto-Bold");

            //RobotoCondensed
            game.AddFont(resources, @"Fonts/RobotoCondensed/RobotoCondensed-Regular");
            game.AddFont(resources, @"Fonts/RobotoCondensed/RobotoCondensed-Bold");

            showLogOverlay = frameworkConfig.GetBindable <bool>(FrameworkSetting.ShowLogOverlay);

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = test_list_width
                    },
                    Children = new Drawable[]
                    {
                        new SafeAreaContainer
                        {
                            SafeAreaOverrideEdges = Edges.Right | Edges.Bottom,
                            RelativeSizeAxes      = Axes.Both,
                            Child = testContentContainer = new Container
                            {
                                Clock            = framedClock,
                                RelativeSizeAxes = Axes.Both,
                                Padding          = new MarginPadding {
                                    Top = 50
                                },
                                Child = compilingNotice = new Container
                                {
                                    Alpha        = 0,
                                    Anchor       = Anchor.Centre,
                                    Origin       = Anchor.Centre,
                                    Masking      = true,
                                    Depth        = float.MinValue,
                                    CornerRadius = 5,
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new Drawable[]
                                    {
                                        new Box
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Colour           = Color4.Black,
                                        },
                                        new SpriteText
                                        {
                                            Font = new FontUsage(size: 30),
                                            Text = @"Compiling new version..."
                                        }
                                    },
                                }
                            }
                        },
                        toolbar = new TestBrowserToolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                        },
                    }
                },
                leftContainer = new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(test_list_width, 1),
                    Masking          = true,
                    Children         = new Drawable[]
                    {
                        new SafeAreaContainer
                        {
                            SafeAreaOverrideEdges = Edges.Left | Edges.Top | Edges.Bottom,
                            RelativeSizeAxes      = Axes.Both,
                            Child = new Box
                            {
                                Colour           = FrameworkColour.GreenDark,
                                RelativeSizeAxes = Axes.Both
                            }
                        },
                        new FillFlowContainer
                        {
                            Direction        = FillDirection.Vertical,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                searchTextBox = new TestBrowserTextBox
                                {
                                    OnCommit = delegate
                                    {
                                        var firstTest = leftFlowContainer.Where(b => b.IsPresent).SelectMany(b => b.FilterableChildren).OfType <TestSubButton>()
                                                        .FirstOrDefault(b => b.MatchingFilter)?.TestType;
                                        if (firstTest != null)
                                        {
                                            LoadTest(firstTest);
                                        }
                                    },
                                    Height           = 25,
                                    RelativeSizeAxes = Axes.X,
                                    PlaceholderText  = "type to search",
                                    Depth            = -1,
                                },
                                new BasicScrollContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Masking          = false,
                                    Child            = leftFlowContainer = new SearchContainer <TestGroupButton>
                                    {
                                        Padding = new MarginPadding {
                                            Top = 3, Bottom = 20
                                        },
                                        Direction        = FillDirection.Vertical,
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                    }
                                }
                            }
                        }
                    }
                },
            };

            searchTextBox.Current.ValueChanged += e => leftFlowContainer.SearchTerm = e.NewValue;

            if (RuntimeInfo.SupportsJIT)
            {
                backgroundCompiler = new DynamicClassCompiler <TestScene>();
                backgroundCompiler.CompilationStarted  += compileStarted;
                backgroundCompiler.CompilationFinished += compileFinished;
                backgroundCompiler.CompilationFailed   += compileFailed;

                try
                {
                    backgroundCompiler.Start();
                }
                catch
                {
                    //it's okay for this to fail for now.
                }
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AddAssembly(asm.GetName().Name, asm);
            }

            Assembly.BindValueChanged(updateList);
            RunAllSteps.BindValueChanged(v => runTests(null));
            PlaybackRate.BindValueChanged(e =>
            {
                rateAdjustClock.Rate  = e.NewValue;
                audioRateAdjust.Value = e.NewValue;
            }, true);
        }
コード例 #31
0
ファイル: TestBrowser.cs プロジェクト: Aikoyori/osu-framework
        private void load(Storage storage, GameHost host)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            exit = host.Exit;

            rateBindable = new BindableDouble(1)
            {
                MinValue = 0,
                MaxValue = 2,
            };

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                leftContainer = new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(test_list_width, 1),
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Color4.DimGray,
                            RelativeSizeAxes = Axes.Both
                        },
                        new FillFlowContainer
                        {
                            Direction        = FillDirection.Vertical,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                searchTextBox = new TextBox
                                {
                                    OnCommit = delegate
                                    {
                                        var firstVisible = leftFlowContainer.FirstOrDefault(b => b.IsPresent);
                                        if (firstVisible != null)
                                        {
                                            LoadTest(firstVisible.TestType);
                                        }
                                    },
                                    Height           = 20,
                                    RelativeSizeAxes = Axes.X,
                                    PlaceholderText  = "type to search"
                                },
                                new ScrollContainer
                                {
                                    Padding = new MarginPadding {
                                        Top = 3, Bottom = 20
                                    },
                                    RelativeSizeAxes         = Axes.Both,
                                    ScrollbarOverlapsContent = false,
                                    Child = leftFlowContainer = new SearchContainer <TestCaseButton>
                                    {
                                        Padding          = new MarginPadding(3),
                                        Direction        = FillDirection.Vertical,
                                        Spacing          = new Vector2(0, 5),
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                    }
                                }
                            }
                        }
                    }
                },
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = test_list_width
                    },
                    Children = new Drawable[]
                    {
                        toolbar = new Toolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                            Depth            = -1,
                        },
                        testContentContainer = new Container
                        {
                            Clock            = framedClock,
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding {
                                Top = 50
                            },
                            Child = compilingNotice = new Container
                            {
                                Alpha        = 0,
                                Anchor       = Anchor.Centre,
                                Origin       = Anchor.Centre,
                                Masking      = true,
                                Depth        = float.MinValue,
                                CornerRadius = 5,
                                AutoSizeAxes = Axes.Both,
                                Children     = new Drawable[]
                                {
                                    new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Colour           = Color4.Black,
                                    },
                                    new SpriteText
                                    {
                                        TextSize = 30,
                                        Text     = @"Compiling new version..."
                                    }
                                },
                            }
                        }
                    }
                }
            };

            searchTextBox.Current.ValueChanged += newValue => leftFlowContainer.SearchTerm = newValue;

            backgroundCompiler = new DynamicClassCompiler <TestCase>
            {
                CompilationStarted  = compileStarted,
                CompilationFinished = compileFinished,
            };
            try
            {
                backgroundCompiler.Start();
            }
            catch
            {
                //it's okay for this to fail for now.
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AssemblyDropdown.AddDropdownItem(asm.GetName().Name, asm);
            }

            toolbar.AssemblyDropdown.Current.ValueChanged += updateList;
            toolbar.RunAllSteps.Current.ValueChanged      += v => runTests(null);
            toolbar.RateAdjustSlider.Current.BindTo(rateBindable);

            rateBindable.ValueChanged += v => rateAdjustClock.Rate = v;
            rateBindable.TriggerChange();
        }