You’ve received some great answers, and I’m not sure I can add much, but I don’t believe flirting is always ‘testing the waters’ for a love affair. It can also be an acknowledgement or acceptance of friendship or just a compliment. An innocent flirter may just be attempting to make the flirtee (is that a word?) feel good, and it is often only that.
Obviously you would not flirt with someone you didn’t like and think attractive. Flirting will be taken as an insult if you are ingenuous. You wouldn’t ‘test the waters’ with the ugly or stupid guy/girl in the room (unless you’re desperate). That’s what makes flirting a compliment.
When the flirter and flirtee exceed the friendship/compliment line, it crosses the plutonic barrier. If you can’t define that line for both yourself and your flirtee, it is best to not flirt at all, unless you actually are ‘testing the waters’.
It crosses the line from innocence the moment the flirter clearly understands he/she is attracted beyond friendship and continues flirting. That is the definition of ‘testing the waters’. If both you and your flirtee are single and uncommitted, there is nothing wrong with that, and hopefully the water’s warm.
There are two places all flirting is inappropriate, at work and anywhere your better half is present. Innocent or not, it will assuredly lead to problems, with one exception. A salesperson will sometimes flirt with a prospect to maintain interest in the proposal. Usually it is clearly understood as a gesture, and is not a serious attempt to ‘test the waters’, although I know of many instances where the technique hugely backfired. Even trained salespeople can’t always define the line correctly. Sex sells, but not always.
Flirting is an American pastime. There should be an organized National Association of Flirters (NAF) with contests, trophies, and huge audiences. Opps, except for the organizational name, there already is one, the local singles bar.