<commit_before>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components;
using osuTK;

namespace osu.Game.Tests.Visual.Editor
{
    public class TestSceneBeatDivisorControl : ManualInputManagerTestScene
    {
        public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(BindableBeatDivisor) };
        private BeatDivisorControl beatDivisorControl;
        private BindableBeatDivisor bindableBeatDivisor;

        [BackgroundDependencyLoader]
        private void load()
        {
            Child = beatDivisorControl = new BeatDivisorControl(bindableBeatDivisor = new BindableBeatDivisor())
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Size = new Vector2(90, 90)
            };
        }

        [Test]
        public void TestBindableBeatDivisor()
        {
            AddStep("Reset", () => reset());
            AddRepeatStep("Move previous", () => bindableBeatDivisor.Previous(), 4);
            AddAssert("Position at 4", () => bindableBeatDivisor.Value == 4);
            AddRepeatStep("Move next", () => bindableBeatDivisor.Next(), 3);
            AddAssert("Position at 12", () => bindableBeatDivisor.Value == 12);
        }

        [Test]
        public void TestMouseInput()
        {
            AddStep("Reset", () => reset());
            AddStep("Move to marker", () =>
            {
                InputManager.MoveMouseTo(beatDivisorControl, new Vector2(38, -18));
                InputManager.PressButton(osuTK.Input.MouseButton.Left);
            });
            AddStep("Mote to divisor 8", () =>
            {
                InputManager.MoveMouseTo(beatDivisorControl, new Vector2(0, -18));
                InputManager.ReleaseButton(osuTK.Input.MouseButton.Left);
            });
            AddAssert("Position at 8", () => bindableBeatDivisor.Value == 8);
            AddStep("Prepare to move marker", () => { InputManager.PressButton(osuTK.Input.MouseButton.Left); });
            AddStep("Trigger marker jump", () =>
            {
                InputManager.MoveMouseTo(beatDivisorControl, new Vector2(30, -18));
            });
            AddStep("Move to divisor ~10", () =>
            {
                InputManager.MoveMouseTo(beatDivisorControl, new Vector2(10, -18));
                InputManager.ReleaseButton(osuTK.Input.MouseButton.Left);
            });
            AddAssert("Position clamped to 8", () => bindableBeatDivisor.Value == 8);
        }

        private void reset()
        {
            bindableBeatDivisor.Value = 16;
            InputManager.MoveMouseTo(beatDivisorControl, new Vector2(beatDivisorControl.Width, beatDivisorControl.Height));
        }
    }
}<commit_msg>Use [SetUp] instead of reset method<commit_after>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components;
using osuTK;

namespace osu.Game.Tests.Visual.Editor
{
    public class TestSceneBeatDivisorControl : ManualInputManagerTestScene
    {
        public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(BindableBeatDivisor) };
        private BeatDivisorControl beatDivisorControl;
        private BindableBeatDivisor bindableBeatDivisor;

        [SetUp]
        public void SetUp() => Schedule(() =>
        {
            Child = beatDivisorControl = new BeatDivisorControl(bindableBeatDivisor = new BindableBeatDivisor(16))
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                Size = new Vector2(90, 90)
            };
        });

        [Test]
        public void TestBindableBeatDivisor()
        {
            AddRepeatStep("Move previous", () => bindableBeatDivisor.Previous(), 4);
            AddAssert("Position at 4", () => bindableBeatDivisor.Value == 4);
            AddRepeatStep("Move next", () => bindableBeatDivisor.Next(), 3);
            AddAssert("Position at 12", () => bindableBeatDivisor.Value == 12);
        }

        [Test]
        public void TestMouseInput()
        {
            AddStep("Move to marker", () =>
            {
                InputManager.MoveMouseTo(beatDivisorControl, new Vector2(38, -18));
                InputManager.PressButton(osuTK.Input.MouseButton.Left);
            });
            AddStep("Mote to divisor 8", () =>
            {
                InputManager.MoveMouseTo(beatDivisorControl, new Vector2(0, -18));
                InputManager.ReleaseButton(osuTK.Input.MouseButton.Left);
            });
            AddAssert("Position at 8", () => bindableBeatDivisor.Value == 8);
            AddStep("Prepare to move marker", () => { InputManager.PressButton(osuTK.Input.MouseButton.Left); });
            AddStep("Trigger marker jump", () =>
            {
                InputManager.MoveMouseTo(beatDivisorControl, new Vector2(30, -18));
            });
            AddStep("Move to divisor ~10", () =>
            {
                InputManager.MoveMouseTo(beatDivisorControl, new Vector2(10, -18));
                InputManager.ReleaseButton(osuTK.Input.MouseButton.Left);
            });
            AddAssert("Position clamped to 8", () => bindableBeatDivisor.Value == 8);
        }
    }
}
{'fraction_non_alphanumeric': 0.11547222708953916, 'fraction_numerical': 0.014543543017347118, 'mean_word_length': 2.2468714448236633, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5561320', 'n_tokens_mistral': 1704, 'n_tokens_neox': 1529, 'n_words': 319}