A game framework written with osu! in mind.
at master 62 lines 2.3 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using System.Linq; 5using NUnit.Framework; 6using osu.Framework.Graphics; 7using osu.Framework.Graphics.UserInterface; 8using osu.Framework.Testing; 9 10namespace osu.Framework.Tests.Visual.UserInterface 11{ 12 public class TestSceneColourPicker : FrameworkTestScene 13 { 14 [Test] 15 public void TestExternalColourSetAfterCreation() 16 { 17 ColourPicker colourPicker = null; 18 19 AddStep("create picker", () => Child = colourPicker = new BasicColourPicker()); 20 AddStep("set colour externally", () => colourPicker.Current.Value = Colour4.Goldenrod); 21 AddAssert("colour is correct", () => colourPicker.Current.Value == Colour4.Goldenrod); 22 } 23 24 [Test] 25 public void TestExternalColourSetAtCreation() 26 { 27 ColourPicker colourPicker = null; 28 29 AddStep("create picker", () => Child = colourPicker = new BasicColourPicker 30 { 31 Current = { Value = Colour4.Goldenrod } 32 }); 33 AddAssert("colour is correct", () => colourPicker.Current.Value == Colour4.Goldenrod); 34 } 35 36 [Test] 37 public void TestExternalHSVChange() 38 { 39 const float hue = 0.34f; 40 const float saturation = 0.46f; 41 const float value = 0.84f; 42 43 ColourPicker colourPicker = null; 44 45 AddStep("create picker", () => Child = colourPicker = new BasicColourPicker 46 { 47 Current = { Value = Colour4.Goldenrod } 48 }); 49 AddStep("hide picker", () => colourPicker.Hide()); 50 AddStep("set HSV manually", () => 51 { 52 var saturationValueControl = this.ChildrenOfType<HSVColourPicker.SaturationValueSelector>().Single(); 53 54 saturationValueControl.Hue.Value = hue; 55 saturationValueControl.Saturation.Value = saturation; 56 saturationValueControl.Value.Value = value; 57 }); 58 59 AddUntilStep("colour is correct", () => colourPicker.Current.Value == Colour4.FromHSV(hue, saturation, value)); 60 } 61 } 62}