The following correct information to the best of my knowledge, but is generally based on my own gameplay experience and memory, and not backed with SCIENCE (TM). I'm happy to correct any errors noted in comments.
General Line of Sight and Cover
This Image (it's large) provides a great guide to cover and it's effects on line of sight(LOS). I found it via reddit, but I'm not sure of it's original source.
Based on my experience, low cover doesn't block line of sight, and high cover does block line of sight. However, it's important to note that if your unit is peeking around the edge of a piece of high cover, the enemy can see them peeking out, and can still establish a line of sight, even though most of your unit is behind high cover.
When thinking about cover and line of sight, it's important to consider that your soldiers are "active" at all times, looking over their shoulders, peeking out from cover, sometimes even automatically sidestepping a space to take a better shot. Being active in such a way allows your units to maintain a 360 degree line of sight, but also exposes them to enemy fire. Your unit may be in cover, but they're peeking out from it constantly to maintain line of sight on the enemy, and that gives the enemy a line of sight on your soldier.
A good rule of thumb is, if you can see your enemy, there's some kind of line of sight between him and you. If you're being shot at from within the fog of war, then I'm not sure what's going on there. I've only seen that happen when I'm hunkered down (which reduces a unit's line of sight).
Unfortunately, when all your soldiers are bunched together, it's hard to know which particular soldier is giving you visibility on any particular square. The game doesn't provide any way to determine a soldier's individual LOS when multiple soldiers have overlapping fields of view.
The Hill Scenario
For the "Hill Scenario" you described, here's what I'm imagining (side view from ground)
H: Hill (terrain)
F: Fountain (cover object)
Let's assume that the fountain is a half-cover object for now. In the above section, we assume that half-cover doesn't affect line of sight. This should always be true on flat ground. However, in three dimensions, the relevant question seems to be, "if the terrain is a half-step up, and the fountain is a piece of half-cover, shouldn't that equal full cover, and block line of sight?" The image I linked to above does not address this scenario.
Realistically, line of sight should probably be blocked in this scenario. However, you got shot, so it obviously wasn't.
I'd theorize that the game simply treats low cover objects as not blocking line of sight, and doesn't actually calculate total "height" of cover.
If this is the case, we can completely disregard the fountain (pretend it's invisible and immaterial). This means that the elevation of the Hill would be the key to determining LOS.
If the side of the hill is the height of low cover, then there would still be line of sight across the hill, when ignoring the fountain.
If the hill is the height of full cover, then I feel like it should block line of sight, and this is probably a bug. I could see a possible argument that the soldier could be actively peeking his head out over the hill, creating a LOS across the hill. However, based on the unit height and animations of the soldiers, it seems like it would be very difficult for one of them to fire over a piece of high cover.
If the hill is higher than a full-cover object, then there should definitely be no line of sight across the hill, even ignoring the fountain.
If the fountain is full-height cover, then it should block LOS between the two units regardless of the hill height.