Unit tests for precision slider finally

Captain's Log: Stardate 77621.1

Today was one of those days where I began with an "quick" task and it ended up consuming the whole day. All I wanted to do was add the musical interval text next to the number for the semitone slider that transposes an oscillator's note. So instead of "3" and "7" it would display "3:m3" and "7:P5". respectively. This was really easy, of course, but while testing it I noticed that the slider was doing weird things.

The thing about the semitone slider is that it snaps to integers, instead of full floating point like most other sliders. And ultimately I found that the implementation for the new interval sliders was broken w.r.t. snap-to-grid. It's a bit of a tricky thing, because when you change the lower/upper bound on an interval slider, it tries to linearly scale each value in between the bounds. So there's a transformation function that gets applied to each selected entity's parameter value, mapping from the current value to the scaled value. Basically the problem was that it was snapping some values in the formula for the scaling transform, but not others, which lead to super weird behavior.

And so... it's time for PrecisionSlider to get some unit tests. It's 1,500 lines of code with really tricky edge cases like "snap-to-grid with an exponential interval but leave out the thumbwheel". I don't have many GUI unit tests, but it's a good time to start on that.

After I get some units tests going for PrecisionSlider, I really want to spend some time working on a GUI fuzz test. I've gotten incredible value out of fuzz tests for the physics simulation / data model code. So I want to see if I can do the same for the GUI. The first one I want to do is a simple "chaos monkey" which generates random mouse and keyboard events at the top-level. My hope is that I can run this overnight and see if it crashed. There are some open questions here, like... do we need to e.g. bias random mouse clicks to happen on known UI elements?


© 2024 Anukari LLC, All Rights Reserved
Contact Us|Legal