Viewport tests

I'm at another good stopping point for these, so here's another pull request. I'm trying to not put them all in one enormous code review, just for sanity's sake.
Just to see what happens, I guess. I can remove them if it's outside the scope of what the unit tests should do.