  An ultracold atom above a horizontal mirror experiences quantum reflection
from the attractive Casimir-Polder interaction, which holds it against gravity
and leads to quantum levitation states. We analyze this system by using a
Liouville transformation of the Schr\"odinger equation and a Langer coordinate
adapted to problems with a classical turning point. Reflection on the
Casimir-Polder attractive well is replaced by reflection on a repulsive wall
and the problem is then viewed as an ultracold atom trapped inside a cavity
with gravity and Casimir-Polder potentials acting respectively as top and
bottom mirrors. We calculate numerically Casimir-Polder shifts of the energies
of the cavity resonances and propose a new approximate treatment which is
precise enough to discuss spectroscopy experiments aiming at tests of the weak
equivalence principle on antihydrogen. We also discuss the lifetimes by
calculating complex energies associated with cavity resonances.
